develop wherever and whenever you want...

Docs > Global Functions Reference

Global Functions Reference

Summary 
Jasic provides a number of global functions

object require(file) 
number parseInt(text) 
number parseFloat(text)

Example 
// test.js module 
(function() { 
var obj = { }; 
obj.println = function(s) { 
document.writeln(s); 

return obj; 
})();

// calling file var sys = require("test.js"); sys.println("Hello"); 

require 
Is used to allow a script file to call and handle the result of another script file. This mechanism provides the foundation for building reusable modules and supporting complex projects. See the Jasic tutorial samples for examples of how require() is used.

object require(file) 
Parameters 
file .... File and path for file to call 
Return Value 
Any value returned from the module but most typically (and recommended) the object value forming the root of the namespace. See notes

Notes 
Modules should be built using the anonymous function operation returning an object which contains properties and methods that can then be called by the calling script. This conforms to the common require.js and node.js patterns commonly used on the web and provides for encapsulation, namespace, and composability.

Please also note that it is not recommended that modules themselves require other modules, rather demand their callers require such dependencies before calling them.

The module / anonymous function pattern is shown in the example above.

Also please note that the file path references can be relative to the current folder (recommended) or absolute against the Jasic iPad storage root.


parseInt 
Parse a string and return integer numeric value from the string

number parseInt(text) 
Parameters 
text .... string to parse 
Return Value 
Integer value of the text


parseFloat 
Parse a string and return floating point numeric value from the string

number parseInt(text) 
Parameters 
text .... string to parse 
Return Value 
Floating point value of the text