PDA

View Full Version : help with multiple buttons


sawyer
01-21-2008, 08:43 AM
hi all it has been a while since i used APMS
so if anyone can help me with this it would be much appreciated

i have 7 buttons and 7 images on a page.
i would like to be able to click button 7 and check if button 1 is enabled if it is
then set image 1 enabled and visible,if it not then check if button 2 is enabled
if it is then set image 2 enabled and visible,if its not then check if button 3 is enabled if it is then set image 3 enabled and visible,if not then check 4,if not then check 5 and so on

if anyone has an example how to do this or any help it is much appreciated

Thanks sawyer

RizlaUK
01-21-2008, 09:38 AM
ok, heres how i would do it,

first make 2 tables containing the button and image names

tblButtons={}
tblButtons[1]="Button1"
tblButtons[2]="Button2"
tblButtons[3]="Button3"
tblButtons[4]="Button4"
tblButtons[5]="Button5"
tblButtons[6]="Button6"
tblButtons[7]="Button7"

tblImages={}
tblImages[1]="Image1"
tblImages[2]="Image2"
tblImages[3]="Image3"
tblImages[4]="Image4"
tblImages[5]="Image5"
tblImages[6]="Image6"
tblImages[7]="Image7"

then use a for loop to check the buttons
for index, Button in tblButtons do
if Button.IsEnabled(Button) then
tbImageProps={}
tbImageProps.Enabled=true
tbImageProps.Visible=true
Image.SetProperties(tblImages[index], tbImageProps);
break
end
end

the above code is not tested, its off the top of my head but it should work

sawyer
01-21-2008, 12:09 PM
thanks for your help but i i havn't done any work with tables or scripts just basic actions with buttons objects etc (click and do) dont suppose you have an example apz lying around ? It would be very appreciated,i will see if i can get your code to work for me either way

thanks a lot for your help sawyer

clueless
01-21-2008, 10:36 PM
Another way you could do it is name the buttons but1,but2 etc and name the images img1,img2,img3 etc.
Then in your Global functions have;-

function CheckButtons()
local inc =0;
for inc=1,7 do
if Button.IsEnabled("but"..inc) == true then
Image.SetVisible("img"..inc, true)
return
end
end
end


Then just link the function to button7.