11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Examples<br />

In the following example, the main program prompts the user for two numbers. These<br />

are sent to the subroutine COMP, together with an empty variable C. The subroutine,<br />

COMP, renames the passed arguments, calculates their average, and returns the result<br />

in the third variable.<br />

This is the main program:<br />

REM Main program<br />

PRINT "Enter A,B:":; INPUT A; INPUT B<br />

CALL COMP(A,B,C)<br />

PRINT "Average = ":C<br />

STOP<br />

This is the subroutine:<br />

REM Calculates average of two numbers<br />

SUBROUTINE COMP(X,Y,Z)<br />

Z = (X+Y)/2<br />

RETURN<br />

END<br />

The sample program in Appendix A, “Sample Program,” in Developing <strong>UniBasic</strong><br />

Applications includes the following subroutine, which is called by the main program<br />

to display messages on the screen:<br />

SUBROUTINE DISPLAY_MESSAGE(MESSAGE)<br />

DISPLAY @(5,20):MESSAGE<br />

DISPLAY @(5,21):"Press the (Return) key.":<br />

INPUT PAUSE,1_<br />

RETURN<br />

Related <strong>Commands</strong><br />

<strong>UniBasic</strong><br />

CALL, PROGRAM, SUBROUTINE (Update Trigger), SUBROUTINE (Delete<br />

Trigger)<br />

UniData<br />

BASIC, CATALOG – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />

SUBROUTINE 1-879

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

Saved successfully!

Ooh no, something went wrong!