Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing between objects using FOR-END FOR 1

Status
Not open for further replies.

govindalopez

Programmer
Dec 12, 2008
4
Hi,

Can anyone please help me on this. I want to place a value in the text property of a single line edit. The thing is that I have 10 single line edit's and I want to take the values from an array.

Basically what I need is something like this:

FOR x = 1 TO 10
sle_option(x).text = ls_array[x]
END FOR

The sle_option is a single line edit and the ls_array[] is a local string array.

When I try using this example I get a sintax error. Can anyone please help?

By the way I can´t use an IF or a CHOOSE CASE for this. Only a FOR or any other way to change between objects to insert in their text property a value.

Thanks.
 
The simplest way I've found for referencing objects is to create a window function...

wf_sle( Long al_sle ) Returns SingleLineEdit

//this example uses 3 single line edits...

SingleLineEdit sle_ref

CHOOSE CASE al_sle
CASE 1
sle_ref = sle_option_1
CASE 2
sle_ref = sle_option_2
CASE 3
sle_ref = sle_option_3
END CHOOSE

RETURN sle_ref


At that point, you can replace the sle_option(x) in your posted code with wf_sle(x).

Another option would be to load the single line edits into a variable... That's the only way I know of that you will be able to reference them in an array.

/*sample code*/
SingleLineEdit sle_option[]

sle_option[1] = sle_option_1
sle_option[2] = sle_option_2
sle_option[3] = sle_option_3
 
Thanks for your answer. I found another way, yet similar to yours, to do it.

SingleLineEdit sle_box[]
INTEGER li_x = 0

FOR li_x = 1 TO 5
sle_box[li_x] = CREATE SingleLineEdit
sle_box[li_x].width = 180
sle_box[li_x].height = 60
sle_box[li_x].text = string(ii_variable[li_x])
w_example.OpenUserObject(sle_box[li_x], 200* li_x, 200)
END FOR

Or something like that. I put the example here so that if anyone has the same question they can see it right here. Thanks again for your answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top