Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PRIVATE vs Hard-coding cursor name
Message
From
14/03/2019 15:14:19
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01667233
Message ID:
01667242
Views:
55
>Hi,
>
>I have a function that uses XFRX to convert a report to a PDF format.
>
>The report to be converted to PDF has multiple bands. XFRX handle it fine but the cursor names that are used for the bands have to be in scope inside the MyXFRX() function. And I used local variable. For example:
>
>local  Band1Cursor, Band2Cursor
>Band1Cursor = sys(2015)
>Band2Cursor = sys(2015)
>
>
>With the above scenario the MyXFRX function gives an error that variable Band1Cursor does not exist.
>
>The solution - so far - is to either make the variables Private or hard coded. That is, do not use variables but instead use names like CUR_Band1, CUR_band2
>
>Which approach would be a better practice?
>
>TIA

Variables declared as LOCAL are only visible in the procedure/function context where they are declared.
Variables declared as PRIVATE are available in the procedure/function context where they are created as well as in context of called procedure/function. When a PRIVATE is used, variables listed In the PRIVATE statement that already exist as PUBLIC or as PRIVATE within the calling procedure/function will be "hidden" and assignment to the variable will create new instance at that level where the assignment takes place. Variables are implicitly declared as PRIVATE.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform