Simple question from a new Progress programmer

shaveyh10

New Member
I know this is probably pretty simple, but being a newbie to Progress, it's confused me a bit.

How can I substitute the value of a field within a display? (See sample code below) I want to display pt_domain, not disp_field.

***
DEFINE VAR disp_field AS CHAR FORMAT "X(20)" NO-UNDO.
ASSIGN disp_field = "pt_domain".

for each pt_mstr:
display pt_part pt_desc1 disp_field pt_abc pt_um.
end.
***

Thanks for the help.
 

tsspdx

New Member
It's not clear from your comments or your example what you're trying to do.

If you have a variable or field named "pt_domain" and you want to display it where the variable "disp-field" is usually shown, then you can use the "@" operator:

DISPLAY
pt_domain @ disp-field
.

RLR
 

shaveyh10

New Member
In this particular case, I want to actually display the value of the field "pt_domain". "pt_domain" is a field in a table.

For simplicity sake, I just ASSIGNed the variable disp_field to a value.

I want to be able to use the value of disp_field in the display statement, rather than actually using, in this example, "pt_domain".

In the real world, the variable disp_field could be set to any one of the fields on the pt_mstr table.

Does that clear things up a bit?
 

Casper

ProgressTalk.com Moderator
Staff member
Do you mean:

Code:
DEFINE VAR disp_field AS CHAR FORMAT "X(20)" NO-UNDO.
 
for each pt_mstr:
   ASSIGN disp_field = pt_mstr.pt_domain.
   display pt_part pt_desc1 disp_field pt_abc pt_um.
end.

provided the field comes from this table, otherwise just let the quotes out and you assign the value of the field to the variable.
Now you assign the string value 'pt_domain' to the variable.

Casper.
 

shaveyh10

New Member
Let me provide the scenario and see if that helps...

I have a table created that lists table field names that are required for, in this case, "displaying".

So, I read a table that has 3 fields stored for numerous parts. They are:

fld1 = "pt_domain"
fld2 = "pt_desc1"
fld3 = "pt_um"

Now, in my "display" program, I read this table and see that the 3 fields I need to display for this particular part, from the pt_mstr, are pt_domain, pt_desc1, and pt_um.

In the calling program, my display statement would look like this...

for each pt_mstr:
display fld1 fld2 fld3.
end.

The fields (fld1, fld2, fld3) do not actually exist in the pt_mstr. I want to substitute the values read from the previous table, into the display statement so that I, in effect, am executing the following statement:

for each pt_mstr:
display pt_domain pt_desc1 pt_um.
end.

Does this help?
 

FrancoisL

Member
Here you go , it works in Version 10 tho.

Code:
ASSIGN
    fld1 = "pt_domain"
    fld2 = "pt_desc1"
    fld3 = "pt_um"

for each pt_mstr:

    display 
       BUFFER pt_mstr:BUFFER-FIELD(fld1):BUFFER-VALUE
       BUFFER pt_mstr:BUFFER-FIELD(fld2):BUFFER-VALUE
       BUFFER pt_mstr:BUFFER-FIELD(fld3):BUFFER-VALUE.

end.
 

Casper

ProgressTalk.com Moderator
Staff member
That explains a lot :)

The example FrancoisL gave you, will work also in V9.


Casper.
 
Top