Page 1 of 1
switch help (solved)
Posted: Tue Dec 17, 2013 2:24 pm
by vedus
i am bit confused with this one so i need a little help

i have a group with 5 buttons and is shared in all my cards (something like dashboard)
when i click the first button i have the script to change the state to other button (if is armed)
is more simple way to have all together in the stack (script) and NO in every button because is to many of them?
like when i press btn 1 do this, and disable the others..
i have the mainstack and 12 cards.
i am try to make it work with switch like the code bellow but is no working.
Code: Select all
//SWITCH MENUS
put the short name of the target into tTarget
switch tTarget
case "m1_btn"
//show the bar and btn
show graphic "grp_btn1"
show btn "savebtn" with visual effect scroll right fast
show btn "start1" with visual effect scroll right fast
break
case "m2_btn"
//change the icon and color label
set the icon of btn "m2"_btn" to 1096
set the textcolor of fld "m2_lbl" to "#f26c4f"
break
// case "m3_btn"
// case "m4_btn"
// case "m5_btn"
// case "m6_btn"
// case "m7_btn"
end switch
Re: switch help
Posted: Tue Dec 17, 2013 2:44 pm
by Klaus
Hi vedus,
"is not working" is no valid error description, please supply some DETAILS, thanks!
What exactly does not work? Or what does happen, that should not happen? etc...
Best
Klaus
Re: switch help
Posted: Tue Dec 17, 2013 2:55 pm
by vedus
Hi Klaus

Well i put the above code to the stack with the on mouseUp like this
Code: Select all
//SWITCH MENUS
put the short name of the target into tTarget
switch tTarget
answer "btn1"
break
case "m2_btn"
answer "btn2"
break
// case "m3_btn"
// case "m4_btn"
// case "m5_btn"
// case "m6_btn"
// case "m7_btn"
end switch
put the short name of the target into tTarget <-- to get the btn names
every button is empty only the on mouseup - mouse end.
the result i get is nothing..like no btn pressed.
when i test the code above in a new empty project is working
the mainstack have the bellow code
Code: Select all
on preOpenStack
-- use switch with "the environment" property to determine if the app is running on mobile or in development
switch the environment
-- if its development, do pretty much what andre was already doing
case "development"
-- set default folder
set the itemdel to "/"
set the defaultfolder to item 1 to -2 of the effective filename of this stack
put "databin.sqlite" into tDatabase -- using a variable to store the path to the database file rather than using the path directly in revopendatabase
break
case "mobile"
-- if its mobile, point to where the database should be.
-- the documents folder is readable and writable.
-- the engine folder path is only readable.
-- when the file was included using the "copy files" pane
-- of the standalone settings, it will end up in the engine folder, next to the executable
-- but since the engine folder isn't writable you have to copy it to the right place if its not already there.
put specialfolderpath("documents") & "/databin.sqlite" into tDatabase
-- see if the database is already in the documents folder
-- if not, copy it there from the engine folder
if there is not a file tDatabase then
put URL ("binfile:" & specialfolderpath("engine") & "/databin.sqlite") into URL ("binfile:" & tDatabase)
end if
break
end switch
-- since aagDBLib should now be a substack you don't hvae to specify a
-- path to the file. Just the stack name.
start using stack "aagDBLib"
-- open the database using the variable tDatabase to point to the file
-- if its on mobile the tdatabase will point to the file in specialfolderpath(documents)
-- otherwise it will point to a file sitting next to the demo stack.
get revOpenDatabase("sqlite",tDatabase,,,)
-- catch any errors as andre already did.
if it is a number then
dbSetDefaultConnectionID it
else
answer error it
end if
end preOpenStack
//SWITCH MENUS
on mouseUp
//put the short name of the target into tTarget
switch tTarget
case "m1_btn"
//show the bar and btn
answer "test"
visual effect curl up
go to card recpel
set the useUnicode to true
-->label
put uniDecode(the unicodetext of fld "rec100","UTF8") into tText
set the unicodelabel of this stack to uniEncode (tText,"UTF8")
break
case "m2_btn"
answer "testing"
break
// case "m3_btn"
// case "m4_btn"
// case "m5_btn"
// case "m6_btn"
// case "m7_btn"
end switch
end mouseUp
Re: switch help
Posted: Tue Dec 17, 2013 3:07 pm
by Klaus
Hi vedus,
OK, we are getting nearer
every button is empty only the on mouseup - mouse end.
And that seems to be the problem, because even an EMPTY "mouseup" handler will catch the "mosueup!
So to solve ypur problem you can
1. REMOVE alle empty "mouseup" handlers form the buttons completely!
My favourite!
OR
2. add a "pass mouseup" to your otherwise empty "mouseup" handlers!
Code: Select all
on mouseup
pass mouseup
end mouseup
Not my favourite, too much typing and makes no sense in the end
Best
Klaus
Re: switch help (solved)
Posted: Tue Dec 17, 2013 3:11 pm
by vedus
That was the trick

really thank you klaus,like always problem solved
