If I have a button, instead of changing the caption using code like this:
main_win.button_1.caption = '12345'
could I do something like this:
button_1 [x] = '12345'
Can I access the data in a control via an array?
Moderator: Rathinagiri
Re: Can I access the data in a control via an array?
I don't know.metron9 wrote:If I have a button, instead of changing the caption using code like this:
main_win.button_1.caption = '12345'
could I do something like this:
button_1 [x] = '12345'
But you can use it in this way:
Code: Select all
SetProperty("Main_Win", "button_1","caption","'12345")
Code: Select all
for i:=1 to 10
cButtonName := "button_"+alltrim(str(i))
SetProperty("Main_Win", cButtonName","caption", str(1,2))
Regards, Marek
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Can I access the data in a control via an array?
Hi Mark
For an example please refer here.
For naming and assigning properties to controls, in addition to Marek's suggestion (using SetProperty() function), you may use also macro substitution (with & operator).metron9 wrote:If I have a button, instead of changing the caption using code like this:
main_win.button_1.caption = '12345'
could I do something like this:
button_1 [x] = '12345'
For an example please refer here.
Viva INTERNATIONAL HMG 
Re: Can I access the data in a control via an array?
Both replies I needed to implement.
I was trying to use a macro in the ACTION like this:
function anewbutton(parm1,Parm2,Parm3,Parm4)
N_Button= 'col'+ltrim(str(parm1))+'_B'
A_ct = 'virt_board.job_'+ltrim(str(Parm1))+'.caption'
DEFINE BUTTON &N_button
PARENT VIRT_BOARD
ROW Parm2
COL Parm3
WIDTH 80
HEIGHT 25
CAPTION parm4
ACTION virtbutton1(&A_ct)
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .T.
END BUTTON
return nil
So I changed the ACTION to
ACTION virtbutton1(Parm1)
and then changed the function virtbutton to:
function virtbutton1(parm1) /* Save last job button pushed */
lastBpushed := parm1
N_Button= 'col'+ltrim(str(parm1))+'_B'
lastJpushed = GETProperty("virt_board", N_button,"caption")
msgbox(N_button+' '+lastJpushed)
return nil
I had actually wrote a program to generate the code to make the buttons and put it in a file.ch
then included it inside the window declaration.
got to go , dentist appointment
Thank you.
I was trying to use a macro in the ACTION like this:
function anewbutton(parm1,Parm2,Parm3,Parm4)
N_Button= 'col'+ltrim(str(parm1))+'_B'
A_ct = 'virt_board.job_'+ltrim(str(Parm1))+'.caption'
DEFINE BUTTON &N_button
PARENT VIRT_BOARD
ROW Parm2
COL Parm3
WIDTH 80
HEIGHT 25
CAPTION parm4
ACTION virtbutton1(&A_ct)
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .T.
END BUTTON
return nil
So I changed the ACTION to
ACTION virtbutton1(Parm1)
and then changed the function virtbutton to:
function virtbutton1(parm1) /* Save last job button pushed */
lastBpushed := parm1
N_Button= 'col'+ltrim(str(parm1))+'_B'
lastJpushed = GETProperty("virt_board", N_button,"caption")
msgbox(N_button+' '+lastJpushed)
return nil
I had actually wrote a program to generate the code to make the buttons and put it in a file.ch
then included it inside the window declaration.
got to go , dentist appointment
Thank you.