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.

In the next example, the program segment creates two named common areas. The<br />

second COMMON statement continues on a second line. The comma (,) continuation<br />

character ends the continued line.<br />

COMMON /MENU/ X,Y,XDIM,YDIM,S.CHAR<br />

COMMON /CALC/ RATE(10),AMOUNT(10),DATE1,<br />

DATE2,LATE<br />

In the following example, the program segment is invalid because COMMON is not<br />

the first statement in the called program, and because variables in COMMON cannot<br />

be reassigned new values in a called program:<br />

VALUE = 253<br />

COMMON VALUE,SUBVALUE,ATTRIBUTE<br />

The following two programs demonstrate passing a variable through common. The<br />

FIRST_PROG establishes the common variable VAR, and then NEXT_PROG<br />

declares this variable, adds 1 to it, and prints it.<br />

FIRST_PROG<br />

COMMON VAR<br />

VAR = 1<br />

PRINT "IN FIRST_PROG"<br />

PRINT VAR<br />

CALL NEXT_PROG<br />

NEXT_PROG<br />

*Program NEXT_PROG<br />

COMMON VAR<br />

PRINT "IN NEXT_PROG"<br />

VAR = VAR+1<br />

PRINT VAR<br />

Here is the output from these programs:<br />

:RUN BP FIRST_PROG<br />

IN FIRST_PROG<br />

1<br />

IN NEXT_PROG<br />

2<br />

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

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

CLEAR, CLEARCOMMON<br />

COMMON 1-162

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

Saved successfully!

Ooh no, something went wrong!