Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PRIVATE vs Hard-coding cursor name
Message
 
 
To
15/03/2019 05:18:15
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01667233
Message ID:
01667255
Views:
46
>>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
>
>You are saying "have to be in scope inside MyXRFX() function". Any variable declared as LOCAL or PRIVATE, inside that function would be in scope of that function. So using LOCAL is fine. The error you are getting doesn't make sense.
>
>Also, I think hard coding a cursor name is always fine. Cursor names are private to the data session that they are created in and their file names are sys(2015) values implicitly.

I probably didn't express my question correctly. Here are more details:
I have a function MyReport() where the local variables were declared and the value of SYS(2015) assigned. Then these cursors were populated.
Then, in order, to convert the report to a PDF, another function MyXfrx() was called. Inside the function MyXfrx() the report was being changed to PDF.
The problem, I realized later was that in the report I was using the names of the cursors. E.g.
evaluate( cursorBand1 + ".myfield" )
and it would cause a run-time error.
I changed the variables (in MyReport()) to PRIVATE and it got around the problem.
I am not comfortable with a PRIVATE. So, when I have time, I will change the variables to hard-coded cursors.
Then, I will change - in the report - everywhere where there is EVALUATE() to using the cursor name and the field name. E.g. MYCURSOR.MYFIELD
Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform