AndrewMozley
Programmer
I am converting an accounting application which includes a function “Mypost” which updates several tables when an invoice for a customer is to be posted to the system.
In the original application, all of the tables were open during the whole session, so that the function Mypost could Append or Update records in the several tables as necessary.
However I have now put these functions into a session class :
At the start of my main program, I instantiate this glass as a global object :
goProcs = NewObject(“MyProcs”, “Myproc.prg”)
Then when I want to call function My post, I write :
goProcs.MyPost(Param1, @Param2 . . .)
These parameters will be variables such as customer account, date &c or arrays such as the line details.
This works up to a point. I have two concerns :
1. Does it matter that this way of working could be considered mildly inefficient, since, for example, in Mypost() I may have to re-open the customer table, which was already open and positioned on the right record? Likewise does it matter that I believe I am opening and closing the tables (there are 6) each time I call MyPost().?
2. One of the parameters that I wish to pass over is a two-dimensional array of line details. In fact it is stored as a cursor tDetail (containing six fields) in the main program, but I believe that I need to make it into an array to pass it across as a parameter : MyPost(@aDetail, . . .). How do I then interpret it as a two-dimensional array in function MyPost(vDetail). At present I thought I was extracting (say) the second line of details by writing :
aLine = vDetail[2]
This executes OK, but when I try to extract a single field from this line, evaluating aLine[1], this error message is displayed :
File ‘aline.prg’ does not exist.
3. Even though MyPost() is running in a separate data session, could there still be some means of passing my original cursor tdetail across as a parameter?
Thank you all.
In the original application, all of the tables were open during the whole session, so that the function Mypost could Append or Update records in the several tables as necessary.
However I have now put these functions into a session class :
Code:
DEFINE CLASS Myprocs AS SESSION
FUNCTION MyPost(Param1, Param2 . . )
. . .
ENDFUNC
At the start of my main program, I instantiate this glass as a global object :
goProcs = NewObject(“MyProcs”, “Myproc.prg”)
Then when I want to call function My post, I write :
goProcs.MyPost(Param1, @Param2 . . .)
These parameters will be variables such as customer account, date &c or arrays such as the line details.
This works up to a point. I have two concerns :
1. Does it matter that this way of working could be considered mildly inefficient, since, for example, in Mypost() I may have to re-open the customer table, which was already open and positioned on the right record? Likewise does it matter that I believe I am opening and closing the tables (there are 6) each time I call MyPost().?
2. One of the parameters that I wish to pass over is a two-dimensional array of line details. In fact it is stored as a cursor tDetail (containing six fields) in the main program, but I believe that I need to make it into an array to pass it across as a parameter : MyPost(@aDetail, . . .). How do I then interpret it as a two-dimensional array in function MyPost(vDetail). At present I thought I was extracting (say) the second line of details by writing :
aLine = vDetail[2]
This executes OK, but when I try to extract a single field from this line, evaluating aLine[1], this error message is displayed :
File ‘aline.prg’ does not exist.
3. Even though MyPost() is running in a separate data session, could there still be some means of passing my original cursor tdetail across as a parameter?
Thank you all.