UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

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

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

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!