Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Doing away with Private variables
Message
From
26/01/2023 06:16:51
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01685958
Message ID:
01685965
Views:
49
>Hi,
>
>I have 2-band report. The 2nd band relies on records in a cursor. The cursor name is lcLaborCursor. The cursor is created as follows:
>
>lcLaborCursor = SYS(2015)
>
>So the variable lcLaborCursor has to be in scope when the report is produced. But the cursor (lcLaborCursor) is created and populated two functions before the report is produced. So, I declare the variable lcLaborCursor as PRIVATE. And it works.
>
>Another way I can do it is to declare the variable as Local (my desired goal) and then pass it from one function to another, and then to another.
>
>My question: Can I declare the variable lcLaborCursor LOCAL, not pass it from one function to another, but then still make the cursor in scope within the report?
>Some of the text in the report is using the following syntax:
>
>EVALUATE( lcLaborCursor + ."FLD_NAME")
>
>The above requires that the lcLaborCursor be in scope.
>
>What else can I do?

To expand on what Lutz said, the only reason you ever need to create a random name for a cursor is if a _single_ user can run the code that creates more than once at the same time. For example, if a form that isn't using private data sessions creates a cursor and the user can run that form more than once.

Since a report is essentially a modal activity (well, preview is modal and running the report prevents the user from doing anything else until it completes, so is functionally modal), there's no reason to use a random name for a cursor for a report.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform