Focal Point
Mainatin - how to do dynamic expressions

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6671051432

June 25, 2007, 09:29 AM
K Mann
Mainatin - how to do dynamic expressions
I have an error table which holds a column name on another table where an error occurred. I would like to build a compute expression to pull the offending column's value into an edit box for correction. How do you build a dynamic compute substituting a column name into a stack call. Example below:

compute editvalue = 'Form1.EditBoxCorrection.Text = HNPStk(HNPStk.focindex).'||'FormErrorStk(FormErrorStk.focindex).ERROR_COLUMN_NAME';

compute Form1.EditBoxCorrection.Text = ?editvalue;


Thanks
K Mann
wf 7.1.6 win


K Mann
WF 7.1.4 Win
June 25, 2007, 10:07 AM
Alan B
Directly, I don't believe you can.

Indirectly, the approach I've used in the past is to EXEC a table request to return the data, passing the column name as a variable to a TABLE request that returns the column data.

EXEC getColumnData from columnName into columnDataStack;

where columnDataStack has one field, columnInfo, which is then referenced in the compute.

The TABLE would be something like:

TABLE FILE fileName
PRINT &1
ON TABLE PCHOLD
END

You might be able to do something with classes, but I would have to think about that first.

Or you may be able to pass the 2 stacks to another maintain that can then return the value. Again I would have to think about that one.


Alan.
WF 7.705/8.007
June 25, 2007, 10:09 AM
Maintain Wizard
This is actually easier than it seems. You don't have to worry about creating dynamic stack values. Just compute the value from one stack to another.

For example, assume that MOVIESTK.TITLE has the offending value. We can create a temporary field to contain and display the error value to correct. You can go:


Compute ErrorStk.EditField/a50;
Compute ErrorStk.EditField = Moviestk.Title;

Once the user makes the correction you have:

Compute Moviestk.title = ErrorStk.EditField;

This assumes single edit fields. If you are using a multi-row stack, just use indices:

Compute ErrorStk.EditField/a50;
Compute ErrorStk.EditField = Moviestk().Title;

Once the user makes the correction you have:

Compute Moviestk().title = ErrorStk.EditField;

I hope this helps.

Mark
June 25, 2007, 11:21 AM
Alan B
Don't know if I'm missing something here. If there is one stack holding values:
colstk(1).columnName='COUNTRY';
colstk(2).columnName='CAR';
colstk(3).columnName='MODEL';

and another stack:
datastk(1).COUNTRY='ENGLAND';
datastk(1).CAR='JENSEN';
datastk(1).MODEL='INTERCEPTOR';

I thought the question was how to relate colstk(n) to datastk column n. An error has occurred and colstk.focindex eq 2, columnName eq 'CAR', so there is a need to place datastk(1).CAR into the variable editValue.

e.g.
editValue=datastk(1).colstk(2);
which cannot be done directly.

Or am I having a wrinkly moment.


Alan.
WF 7.705/8.007
June 25, 2007, 11:43 AM
Maintain Wizard
On Mainframe, there use to be the command:
WINFORM GET FORM.FOCUS INTO var
and Var would contain the name of the object that currently had focus. This does not seem to be available anymore. However, if you are going to validate when on Change or Blur, you can compute the name of the current field into a variable.

In the Change trigger:
COMPUTE CURFIELD = "Fieldname";
Perform Validate

You would have to compute the name for every object, but it would work.

Mark
June 25, 2007, 04:27 PM
K Mann
Thanks everyone, looks like there isn't an easy way to do this. I will end up hardcoding the colums with errors, turns out there only is about a dozen that have to be edited. Not elegant but it will work.

Kim


K Mann
WF 7.1.4 Win