Local variable

From BR Wiki
Jump to: navigation, search

In BR, all variables are global variables, even those used in User Defined Functions. In other words, if your program sets x=4, and your library function includes the line x=7, then if your original program uses x again, it will use the value 7.

However, there is a way to get around this: make X a optional parameter in your user defined function, and do not bring it in.

Program contains:

let X=4

Library function definition includes X after the semi-colon:

def fnModifyRec(FileNumber,SubscriptToRead,RecordNumber;X)

Program calls the fnModifyRec function, without bringing in the variable X:


Back in the program, X is still 4.

In contrast, the following call would make X work like a global variable and alter the value of X in the program, since it uses the optional variable:




Back in the program, X will contain the value of 8 or NewNum.