Reading Calling Task's Data


JK Heydt
 

Hi Magic People,

I need to create a batch program that I can call in the record suffix of multiple on line programs with different data views. The called batch program will need to read through all the edited controls in the parent/calling program to get their current values and take appropriate action. All I need is the field name and its current value to do what needs to be done.

How can I get the all the field names and values in the data view of the calling program?

Thanks in advance!


Wes Hein
 

Call a batch task with these variables mine has a parent task that receives the variables) = send 'VR'var as the expression (use the starting variable you want to use)





Express 27


Put the results in a vector

The End task condition I used was 'HT'VAR-Counter (0)=0 don't quick recall why but it works!
I looked for a sample program in the Files section that Todd might have posted, I know I developed my audit trail program from the tips he gave me.

Wes


JK Heydt
 

Thanks for the idea Wes!

I was looking around and I a couple functions that might work even better: 

DataViewVarsIndex(1,2) 
and  VecGet(bn,1)

The first one seems to generate a vector, but I am having trouble getting anything out of VecGet.


JK Heydt
 

I created a virtual vector string in the batch task.

In the task suffix I update the vector with DataViewVarsIndex(1,2) and get a NULL result.

Close?


Hans Brussaard
 

The function DataViewVarsIndex returns a vector with numeric values (the indexes of the variables)

 

Use VarName(VecGet(Vector,1)) to get the name of the first variable

VarCurr(VecGet(Vector,1)) to get the value of the first variable

 

Van: main@magicu-l.groups.io <main@magicu-l.groups.io> Namens JK Heydt
Verzonden: woensdag 5 oktober 2022 21:15
Aan: main@magicu-l.groups.io
Onderwerp: Re: [magicu-l] Reading Calling Task's Data

 

I created a virtual vector string in the batch task.

In the task suffix I update the vector with DataViewVarsIndex(1,2) and get a NULL result.

Close?


JK Heydt
 

Thank you Hans. I'll try that as soon as I figure out how to populate the vector. I'll create a sample project and ask support. Will update here when I figure out.


Steve Greenfield
 

Isn't this the methodology used in debuggers and CSV output programs, both have examples in the Files section of the group - search  "Pretty Cute Debugger Ver 0.03 for Magic 9.4 SP4d.zip" or "CSVExportV9.zip".

We have both as part of our core programs which get included in every application. I've also adapted the method to output data from database fields linked to document bookmarks in Word so from the same data set you can table drive the output for any selected document template.


Wes Hein
 

Wonder if that call needs to be done in the record suffix


JK Heydt
 

Doesn't see to matter. Just finished the project for support.


JK Heydt
 

I found the answer: The vector must be numeric.  Here's a summary of how the whole thing works:

Generic calling program can be any on-line or batch program. Call the '- See Parent Vars" (or whatever you call it) program in the Record Suffix

In the "- See Parent Vars" program, set up as follows:
  • In task properties, End task based on counter or some other condition of your choosing
  • In the Data View,
    • Declare a virtual vector of type numeric (v_Vector)
    • Declare a virtual counter variable of type numeric (v_Counter)
  • In the Task Prefix, update the vector with DataViewVarsIndex(1,2) -- see the documentation for how to set the parameters
  • In the Record Suffix, use VarName and VarCurr with the vector and counter variables to work the data in the parent program
    • VarName(VecGet(v_Vector,v_Counter))
    • VarCurr(VecGet(v_Vector,v_Counter))  - Be mindful of the type of data using VarAttr()
The result might look something like this:


Cool beans!