UniBasic Commands Reference - Rocket Software
UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software
The preceding program calls the following function. The name of this cataloged file is yourfunc. This is the name that must match the DEFFUN statement in the program above. Notice that the function definition uses yet another name for the function (anotherfunc). 1-199 UniBasic Commands Reference 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. The following screen example shows the command that runs the program and the output from the program: :RUN BP FUNCTION.CALL r from FUNCTION: 3 c from FUNCTION: 2 The following example calls a user-defined function named CALC.SALES.TAX: PRINT @(-1) DEFFUN CALC.SALES.TAX(arg.1,arg.2) PROMPT '' PRINT 'Enter county name':;INPUT COUNTY.NAME PRINT 'Enter sales amount ':;INPUT SALES.AMT TAX.AMT=0 TAX.AMT=CALC.SALES.TAX(COUNTY.NAME,SALES.AMT) PRINT 'County name =':COUNTY.NAME PRINT 'Sales amount =':SALES.AMT PRINT 'Tax amount =':TAX.AMT END Related Command UniBasic FUNCTION
DEL Syntax DEL dyn.array.var Description The UniBasic DEL command deletes an attribute, value, or subvalue from a dynamic array. The corresponding delimiter is also removed. The DELETE function and the DEL command perform the same action. Warning: DEL destroys the data and the corresponding delimiters. Use the DEL command with caution. Parameters The following table describes each parameter of the syntax. Parameter Description dyn.array.var Specifies the dynamic array on which to perform the delete operation. attrib.expr Specifies which attribute of the dynamic array to delete. If val.expr is omitted, DEL deletes the entire attribute, including all values and subvalues. ,val.expr Specifies which value of the dynamic array attribute to delete. If subval.expr is omitted, DEL deletes the entire value, including the subvalues. ,subval.expr Specifies which subvalue of the dynamic array attribute value to delete. DEL Parameters DEL 1-200
- Page 148 and 149: CLOSE Syntax CLOSE [file.var] [ON E
- Page 150 and 151: CLOSESEQ Syntax CLOSESEQ seq.file.v
- Page 152 and 153: closeSocket Syntax closeSocket(sock
- Page 154 and 155: COL1 Syntax COL1( ) Description The
- Page 156 and 157: COMMON Syntax COMMON [/common.name/
- Page 158 and 159: 1-161 UniBasic Commands Reference
- Page 160 and 161: UniData DELETECOMMON, STACKCOMMON -
- Page 162 and 163: Related Command UniBasic EXIT 1-165
- Page 164 and 165: In the next example, the program se
- Page 166 and 167: In the next example, the program se
- Page 168 and 169: COUNT Syntax COUNT(str.expr1, str.e
- Page 170 and 171: COUNTS Syntax COUNTS(expr,str.expr)
- Page 172 and 173: createCertificate Syntax createCert
- Page 174 and 175: createCertRequest Syntax createCert
- Page 176 and 177: Parameter Description The following
- Page 178 and 179: The following table describes the a
- Page 180 and 181: createSecureRequest Syntax createSe
- Page 182 and 183: Method Description The following ta
- Page 184 and 185: Parameters The following table desc
- Page 186 and 187: DATA Syntax DATA expr1 [,expr2]...
- Page 188 and 189: DBTOXML Syntax DBTOXML(xml_document
- Page 190 and 191: DCOUNT Syntax DCOUNT(str,delim) Des
- Page 192 and 193: DEACTIVATEKEY Syntax DEACTIVATEKEY
- Page 194 and 195: STATUS Code Example The following e
- Page 196 and 197: DEFFUN Syntax DEFFUN function.name
- Page 200 and 201: Examples The following program segm
- Page 202 and 203: Examples The following program stat
- Page 204 and 205: In the next example, the program st
- Page 206 and 207: UniData SQL SELECT - For informatio
- Page 208 and 209: Examples In the following example,
- Page 210 and 211: Parameters The following table desc
- Page 212 and 213: DIGEST Syntax DIGEST(algorithm, dat
- Page 214 and 215: DIR Syntax DIR(file.expr) Descripti
- Page 216 and 217: STATUS Codes DISABLEDEC has the fol
- Page 218 and 219: DISPLAYWIDTH Syntax DISPLAYWIDTH (s
- Page 220 and 221: DQUOTE DQUOTE is a synonym for the
- Page 222 and 223: Related Commands UniBasic PRECISION
- Page 224 and 225: ECHO Syntax ECHO [ON | OFF | expr]
- Page 226 and 227: EDADRV_CloseStmt Syntax RETCODE EDA
- Page 228 and 229: EDADRV_Connect Syntax RETCODE EDADR
- Page 230 and 231: EDADRV_Disconnect Syntax RETCODE ED
- Page 232 and 233: 1-226 UniBasic Commands Reference
- Page 234 and 235: Return Codes The following table de
- Page 236 and 237: Output Variable The following table
- Page 238 and 239: Output Variables The following tabl
- Page 240 and 241: EDADRV_GetDBInfo Syntax RETCODE EDA
- Page 242 and 243: EDADRV_GetEDAAttr Syntax RETCODE ED
- Page 244 and 245: EDADRV_GetErrmsg Syntax RETCODE EDA
- Page 246 and 247: Input Variables The following table
The preceding program calls the following function. The name of this cataloged file<br />
is yourfunc. This is the name that must match the DEFFUN statement in the program<br />
above. Notice that the function definition uses yet another name for the function<br />
(anotherfunc).<br />
1-199 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><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 />
The following screen example shows the command that runs the program and the<br />
output from the program:<br />
:RUN BP FUNCTION.CALL<br />
r from FUNCTION: 3<br />
c from FUNCTION: 2<br />
The following example calls a user-defined function named CALC.SALES.TAX:<br />
PRINT @(-1)<br />
DEFFUN CALC.SALES.TAX(arg.1,arg.2)<br />
PROMPT ''<br />
PRINT 'Enter county name':;INPUT COUNTY.NAME<br />
PRINT 'Enter sales amount ':;INPUT SALES.AMT<br />
TAX.AMT=0<br />
TAX.AMT=CALC.SALES.TAX(COUNTY.NAME,SALES.AMT)<br />
PRINT 'County name =':COUNTY.NAME<br />
PRINT 'Sales amount =':SALES.AMT<br />
PRINT 'Tax amount =':TAX.AMT<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
FUNCTION