Is it possible to bind to an array element instead of to an individual field?
I have a situation where I need a horizontal row of fields. Since I can't have a horizontal subfile, these have all become individual fields. There are 4 x 20 fields, each with a bunch of display attributes. The program behind will load and processing everything using arrays. I'd really like to bind directly to the array elements.
Fortunately RPG allows arrays to be associated with data structures, making use of individual fields feasible, but I'm hoping for a more elegant solution. Any ideas?
Bind to array element?
-
- Profound User
- Posts: 20
- Joined: Wed Aug 22, 2012 11:30 am
- First Name: Jeff
- Last Name: Wurst
- Company Name: BBCS
- State / Province: Washington
- Country: United States
- Contact:
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Bind to array element?
Jeff,
Open Access works by creating a DDS-defined record layout that's used to communicate between an RPG program and the Profound UI handler. So when you're defining the field in the binding dialog, you're not really defining it directly in your RPG program, instead you're defining it in a DDS-described display file object.
DDS does not have the concept of arrays. Therefore, we can't possibly support them directly in a binding dialog. (Just like in green-screen...)
The trick that people have used for this sort of thing is to define the DDS fields like MYFIELD01, MYFIELD02, MYFIELD03, etc and then overlay them with an array in your RPG program. (Which, I think is what you're already doing if I understand correctly.)
That's about the best way I can think of.
Open Access works by creating a DDS-defined record layout that's used to communicate between an RPG program and the Profound UI handler. So when you're defining the field in the binding dialog, you're not really defining it directly in your RPG program, instead you're defining it in a DDS-described display file object.
DDS does not have the concept of arrays. Therefore, we can't possibly support them directly in a binding dialog. (Just like in green-screen...)
The trick that people have used for this sort of thing is to define the DDS fields like MYFIELD01, MYFIELD02, MYFIELD03, etc and then overlay them with an array in your RPG program. (Which, I think is what you're already doing if I understand correctly.)
That's about the best way I can think of.
-
- Profound User
- Posts: 20
- Joined: Wed Aug 22, 2012 11:30 am
- First Name: Jeff
- Last Name: Wurst
- Company Name: BBCS
- State / Province: Washington
- Country: United States
- Contact:
Re: Bind to array element?
Thanks. Its good to know whats possible.
I've been working on this all afternoon, struggling because some properties only allow me to bind to indicators. I have 20 fields in my on-screen field array. I needed 80 indicators in 4 groups of 20. I found a nice workaround that I think would work for any output property, not just for indicators.
I have 20 fields so I define a field that is 20 characters long and associate it with a data structure in the RPG code.
I bind that char(20) field to a single field on the screen and then in my screen's onload I run this:
In the RPG:
"rsls" is the prefix on the 20 fields (rsls1, rsls2, ..., rsls20)
In the program all I have to do is say "eval RIList(x) = *on" to set one of these fields to reverse image.
I've been working on this all afternoon, struggling because some properties only allow me to bind to indicators. I have 20 fields in my on-screen field array. I needed 80 indicators in 4 groups of 20. I found a nice workaround that I think would work for any output property, not just for indicators.
I have 20 fields so I define a field that is 20 characters long and associate it with a data structure in the RPG code.
I bind that char(20) field to a single field on the screen and then in my screen's onload I run this:
Code: Select all
var str = getElementValue("RIListFld");
var riid = "";
for (i = 0; i < 20; i++) {
riid = str.substring(i,i+1);
if(riid=='1') {
applyProperty("rsls"+(i+1),"css class 2","RI");
}
}
Code: Select all
d RIList 1 20 dim(20)
d RIListFld 1 20
In the program all I have to do is say "eval RIList(x) = *on" to set one of these fields to reverse image.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Bind to array element?
That should work just fine.
I don't think CSS class has to be an indicator, though? So another possibility would be to bind each field's CSS class to something like rslsCSS01, rslsCSS02, rslsCSS03, etc. Then you could overlay the rslsCSSxx with an array in RPG, and just assign "RI" to the ones where you want reverse image, or *BLANKS to the others. That would eliminate the need for special Javascript.
I don't think CSS class has to be an indicator, though? So another possibility would be to bind each field's CSS class to something like rslsCSS01, rslsCSS02, rslsCSS03, etc. Then you could overlay the rslsCSSxx with an array in RPG, and just assign "RI" to the ones where you want reverse image, or *BLANKS to the others. That would eliminate the need for special Javascript.
-
- Profound User
- Posts: 20
- Joined: Wed Aug 22, 2012 11:30 am
- First Name: Jeff
- Last Name: Wurst
- Company Name: BBCS
- State / Province: Washington
- Country: United States
- Contact:
Re: Bind to array element?
You're right. Its only "read only" and "set focus" that I am otherwise stuck with indicators on.
But it seems focus isn't working. I tried a slightly different method for that one. I tried sending the name of the field to receive focus over in a bound field.
But this isn't working. Neither does
getObj(focusid).focus();
Nor
applyProperty(focusid,"set focus","true");
It seems like something is grabbing focus after "onload" runs. This works if I try it in a button click event.
But it seems focus isn't working. I tried a slightly different method for that one. I tried sending the name of the field to receive focus over in a bound field.
Code: Select all
var focusid = getElementValue("FocusID");
if(focusid.trim().length > 0) {
getObj(focusid).select();
}
getObj(focusid).focus();
Nor
applyProperty(focusid,"set focus","true");
It seems like something is grabbing focus after "onload" runs. This works if I try it in a button click event.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Bind to array element?
Yes, the onload runs after we've built the screen but before we show it to the user. Obviously, we need to do the 'set focus' at the time that we show the display to the user, so your code will end up running before ours does -- and the focus won't be set.
We could look into, perhaps, fixing it so tht applyProperty() would work here, but I don't think there's much we can do about .focus() or .select(), just because of the timing of it.
If you think we should look into updating applyProperrty() so you can set the focus this way, please start a support ticket on this by e-mailling support@profoundlogic.com.
We could look into, perhaps, fixing it so tht applyProperty() would work here, but I don't think there's much we can do about .focus() or .select(), just because of the timing of it.
If you think we should look into updating applyProperrty() so you can set the focus this way, please start a support ticket on this by e-mailling support@profoundlogic.com.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Bind to array element?
Also, keep in mind that when it says "indicators", it doesn't necessarily mean "numbered indicators".
So you could have indicators named "focus01", "focus02", "focus03", and could overlay these with an array in your RPG program.
So you could have indicators named "focus01", "focus02", "focus03", and could overlay these with an array in your RPG program.
Who is online
Users browsing this forum: No registered users and 1 guest