recognize variable name

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

recognize variable name

Post by pascalh4 » Sun Sep 15, 2013 4:35 pm

Hello to all

I can not write code to say:
After adding 1 to variable
if the name of the stack with this variable exists then go to the stack, otherwise erase the button.
(Note: names have already incremented with this method)
To do the same with "add -1 to tNum" I have no problem because the final tNum is 0, but in this direction tNum is variable and is not known before.

I tried this kind of reasoning, but without success.

Code: Select all

  add 1 to tNum
   If the name of stack ("F" & tNum & "  " & Nvar) = true 
   then  go stack ("F" & tNum & "  " & Nvar)
   else hide button 2
 
Pascal

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: recognize variable name

Post by Klaus » Sun Sep 15, 2013 6:27 pm

Hi Pascal,

a name never resolves to TRUE or FALSE, except its name is really "TRUE" or "FALSE",
which would be a bad idea anyway :D

Try this:

Code: Select all

...
add 1 to tNum
put ("F" & tNum & "  " & Nvar) into tStackName
If there is a stack tStackName then
      go stack tStackName
   else 
     hide button 2
end if
...
Best

Klaus

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: recognize variable name

Post by pascalh4 » Mon Sep 16, 2013 8:36 am

Hi Klaus,

THERE, "mais bon sang c'est bien sûr!" Translate: obviously


But there is still a problem.
  while displaying the last stack, the "next" button is always visible.
I must click again for it to disappear.
Accordingly:
to return to the previous stack, must be 2 click on the "back" button.

I tried to reverse the order by:

"there is not, then hide button, else go stack"
but the result remains the same.
you have an idea of why?

Pascal

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: recognize variable name

Post by Klaus » Mon Sep 16, 2013 12:08 pm

Hi Pascal,
pascalh4 wrote:But there is still a problem.
while displaying the last stack, the "next" button is always visible.
I must click again for it to disappear.
Accordingly:
to return to the previous stack, must be 2 click on the "back" button.
you will need to check if that current stack is the "last" one.
Since I still have no idea how you mange the order of your substacks, I have no idea.
pascalh4 wrote:I tried to reverse the order by:

"there is not, then hide button, else go stack"
but the result remains the same.
you have an idea of why?
Because that is identical to my script above!

Code: Select all

...
If there is a stack tStackName then
      go stack tStackName
   else 
     hide button 2
end if
...
## is the same as:
...
If there is NOT a stack tStackName then
      hide btn 2
    else 
     go stack tStackName
end if
...
8)


Best

Kaus

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: recognize variable name

Post by pascalh4 » Mon Sep 16, 2013 1:17 pm

Hi Klaus,

here is the piece of code in which I increment the stacks.

Code: Select all

on mouseUp
   -- affichage boutons, incrementation de variable, creation new substack
   hide button "Nouvelle Fiche"
   show button "Sauver la fiche"
   
   hide stack ( "F" & tNum  & "  " &  Nvar)
   clone stack ( "F" & tNum  & "  " &  Nvar)
   
   set the mainstack of it to  the mainstack of stack ( "F0"  & "  " &  Nvar)
   add 1 to tNum
   set the name of it to ( "F" & tNum  & "  " &  Nvar)

   set the loc of stack ( "F" & tNum  & "  " &  Nvar) to (650,350)
   go to "Outils de création"
    
   end mouseUp
soon

Pascal

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: recognize variable name

Post by Klaus » Tue Sep 17, 2013 10:44 am

Hi Pascal,

please answer this question:
What is the LAST stack in your examples?
I do not see any reference to this, nor any definiton of a MAX number etc.
so I cannot tell what to do.

You can put the "last" number into a global variable and query this
every time befor you do whatever you do :D


Best

Klua

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: recognize variable name

Post by pascalh4 » Tue Sep 17, 2013 7:56 pm

Hi Klaus

Exactly that is the problem. I don't have a limit, which is defined. And there is no last known stack. The number of stack is incremented following an indefinite need (may be stack5 or stack 10, or...) and precisely I don't know how to recognize it. :?:

Pascal

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: recognize variable name

Post by Klaus » Tue Sep 17, 2013 8:04 pm

Hmmm, can't you make tNum also a global variable like Nvar?
Maybe that helps?

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: recognize variable name

Post by pascalh4 » Tue Sep 17, 2013 8:39 pm

Hi Klaus,

it's already done.

But in fact the solution works, except that the first condition even if it is not true generates a?? (movement) before clearing the button.

It is for this reason that I had to imagine a negative condition in the first, for the acion ELSE be ignored, but apparently this is not true.

Pascal

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: recognize variable name

Post by pascalh4 » Sun Sep 29, 2013 9:13 am

Hi Klaus,
I found a solution:

Code: Select all

on mouseUp
   hide this stack
   add 1 to tNum
   go to stack ("F" & tNum & "  " & Nvar)
   show stack ("F" & tNum & "  " & Nvar)
      
   If there is  not a stack ("F" & tNum + 1 & "  " & Nvar) of stack ("F0" & "  " & Nvar)  then
      hide button 2
end if
end mouseUp
This response was in line: there is not a stack ("F" & tNum + 1 & " " & Nvar)

I do not know if this is true, but it works.

Soon

Pascal

Post Reply