UniBasic Commands Reference - Rocket Software
UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software
FUNCTION Syntax FUNCTION function.name [([MAT] arg.1[, [MAT] arg.2]...)] RETURN var Description The UniBasic FUNCTION command begins the definition of a user-written function. The FUNCTION command must be the first noncomment line in the file, which must be cataloged locally or globally. The cataloged file name must be included in the DEFFUN statement in the calling program. The calling program must specify the same number and type of arguments in the calling statement as are included in the FUNCTION statement. Note: UniData triggers are UniBasic subroutines or functions that are called when a user attempts to update or delete a record. For more information about coding a UniBasic function that is called by a trigger, see Developing UniBasic Applications. 1-278 UniBasic Commands Reference
Parameters The following table describes each parameter of the syntax. Parameter Description function.name Specifies the name of the function (for documentation purposes only). It need not be the same as the name used to call the function. You must include this function’s cataloged file name in the DEFFUN statement in the calling program. (MAT arg.1 ,MAT arg.2...) Examples Specifies the arguments to be passed from the calling program. Arguments must be enclosed in parentheses and separated by commas. Precede an argument with MAT to indicate that the argument is an array. Up to 254 arguments can be passed. RETURN var Returns control to the calling program. Can pass back an argument. FUNCTION Parameters The following function performs calculations on a dimensioned array, returning values in the function arguments and return value, r. The name of the cataloged file that contains this function definition is yourfunc. This name must be used in the DEFFUN statement in the calling program. Notice that the function definition uses yet a different name (anotherfunc). The name anotherfunc is not referenced anywhere. FUNCTION anotherfunc(a, MAT b, c) ;* Start function definition. DIM b(-1) ;* Declare array. r = 0 ;* Initialize return value. c = 1 ;* Initialize value passed back. FOR i = 1 TO a ;* To the upper bound passed in: r += b(i) ;* Sum array members. c *= b(i) ;* Multiply array members. NEXT i RETURN r ;* Return value. FUNCTION 1-279
- Page 266 and 267: Examples In the following example,
- Page 268 and 269: EQU Syntax EQU constant1 TO value1
- Page 270 and 271: In the next example, UniData replac
- Page 272 and 273: EXECUTE Syntax EXECUTE "str.expr" [
- Page 274 and 275: Parameter Description Reminder: The
- Page 276 and 277: Related Commands UniBasic COMMON, E
- Page 278 and 279: Parameter Description Examples In t
- Page 280 and 281: The program output is: 1-274 UniBas
- Page 282 and 283: EXP Syntax EXP(expr) Description Th
- Page 284 and 285: Examples The following program segm
- Page 286 and 287: In the next example, the program se
- Page 288 and 289: Options The value of option determi
- Page 290 and 291: FILEINFO Syntax FILEINFO(file.var,
- Page 292 and 293: Code 9 Merge factor percentage 10 S
- Page 294 and 295: FILELOCK Syntax FILELOCK [file.var]
- Page 296 and 297: FILEUNLOCK Syntax FILEUNLOCK [file.
- Page 298 and 299: FIND Syntax FIND expr IN dyn.array[
- Page 300 and 301: Related Commands UniBasic [], FINDS
- Page 302 and 303: Parameter Description Examples In t
- Page 304 and 305: FMT Syntax FMT(expr, "len [f.char]
- Page 306 and 307: STATUS Function Return Values After
- Page 308 and 309: FOOTING Syntax FOOTING [ON num.expr
- Page 310 and 311: Related Commands UniBasic GETPTR, H
- Page 312 and 313: This program segment produces the f
- Page 314 and 315: Parameter Description Examples The
- Page 318 and 319: The following program calls the pre
- Page 320 and 321: GE Syntax expr1 GE expr2 Synonyms #
- Page 322 and 323: generateKey Syntax generateKey(priv
- Page 324 and 325: Return Code Status 1-286 UniBasic C
- Page 326 and 327: GET Syntax GET[X] var[,length] [SET
- Page 328 and 329: Example In the following example, t
- Page 330 and 331: Parameters The following table desc
- Page 332 and 333: getHTTPDefault Syntax getHTTPDefaul
- Page 334 and 335: GETLIST Syntax GETLIST list.name [,
- Page 336 and 337: UniData SQL SELECT - For informatio
- Page 338 and 339: STATUS Function Return Values After
- Page 340 and 341: GETQUEUE Syntax GETQUEUE() Descript
- Page 342 and 343: GETREADU Syntax GETREADU() Descript
- Page 344 and 345: getResponseHeader Syntax getRespons
- Page 346 and 347: The following table describes each
- Page 348 and 349: Parameters The following table desc
- Page 350 and 351: GETUSERGROUP Syntax GETUSERGROUP(ui
- Page 352 and 353: GETUSERNAME Syntax GETUSERNAME(uid)
- Page 354 and 355: 1-316 UniBasic Commands Reference
- Page 356 and 357: Related Commands UniBasic GOSUB, ON
- Page 358 and 359: Examples In the following example,
- Page 360 and 361: Parameter Description The replace.n
- Page 362 and 363: This next example compiles and runs
- Page 364 and 365: Related Command UniBasic GTS 1-326
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
function.name Specifies the name of the function (for documentation purposes<br />
only). It need not be the same as the name used to call the<br />
function.<br />
You must include this function’s cataloged file name in the<br />
DEFFUN statement in the calling program.<br />
(MAT arg.1 ,MAT<br />
arg.2...)<br />
Examples<br />
Specifies the arguments to be passed from the calling program.<br />
Arguments must be enclosed in parentheses and separated by<br />
commas. Precede an argument with MAT to indicate that the<br />
argument is an array. Up to 254 arguments can be passed.<br />
RETURN var Returns control to the calling program. Can pass back an<br />
argument.<br />
FUNCTION Parameters<br />
The following function performs calculations on a dimensioned array, returning<br />
values in the function arguments and return value, r. The name of the cataloged file<br />
that contains this function definition is yourfunc. This name must be used in the<br />
DEFFUN statement in the calling program. Notice that the function definition uses<br />
yet a different name (anotherfunc). The name anotherfunc is not referenced<br />
anywhere.<br />
FUNCTION anotherfunc(a, MAT b, c) ;* Start function<br />
definition.<br />
DIM b(-1) ;* Declare array.<br />
r = 0 ;* Initialize return value.<br />
c = 1 ;* Initialize value passed<br />
back.<br />
FOR i = 1 TO a ;* To the upper bound passed<br />
in:<br />
r += b(i) ;* Sum array members.<br />
c *= b(i) ;* Multiply array members.<br />
NEXT i<br />
RETURN r ;* Return value.<br />
FUNCTION 1-279