command not send / puzzle

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

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

command not send / puzzle

Post by robm80 » Wed Jul 09, 2014 10:37 am

Comand not send:
The menuitem item is "send foo" ; in the stackscript there is a command "foo"; when clicked the answer is: can't find handler.
This error is in every send-call.
Don't understand, because when I put the command "foo" in the menuitem and delete the sendstring, it funtions !

Puzzle:

Code: Select all

put number of cards into tNum
   repeat with i=1 to tNum
      put label of button pagnam of cd i into tVar
      put tVar & cr after fld index
   end repeat
tNum=20
I get 20 times the same label in tVar and never the label of cd i

Help please

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

Re: command not send / puzzle

Post by Klaus » Wed Jul 09, 2014 11:13 am

Hi Rob,

is that really the script of your menu:
...
send foo
...
?
Please post the complete script of your menu.

NOT the solution to your problem, but in your own interest, avoid "sloppy" scripting:

Code: Select all

put the number of cards into tNum
repeat with i=1 to tNum
      put the label of button "pagnam" of cd i into tVar
      put tVar & cr after fld "index"
end repeat
:D


Best

Klaus

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: command not send / puzzle

Post by robm80 » Wed Jul 09, 2014 12:47 pm

Your correction in the not sloppy way was tried already and I did it again: same problem:
In the menu:

Code: Select all

 on menuPick itemChosen
  switch itemChosen
 case "deletecard"
  send deletecard
    break

 case "createcard"
    global tName
    ask "welke naam"
    put it into tName
    send "create_card"
    break

 case "zoek"
     global  tIndex
   put fld "index" into tIndex
   ask "zoek welke lettercombinatie?"
   put it into tCombi
   put number of lines of fld index into tNum
   repeat with i = 1 to tNum
      if tCombi is in line i of fld "index"  then
         put line i of fld "index" & cr after tResult
         end if
      end repeat
      if number of lines of tResult=1
      then go cd (line 1 of tResult) 
      else
         put tResult into fld "index"
         end if
        break

     case "herstel index"
          send "herstelindex"
      break
   end switch
end menuPick
In the stackscript:

Code: Select all

command herstelindex
    put number of cards into tNum
   repeat with i=1 to tNum
      put line i of fld "index" into tInd
      put label of button "pagnam" of cd tInd into tVar
      put tVar & cr after fld "index"
   end repeat
   sort lines of fld "index"
end herstelIndex
I don't understand: the label of button "pagnam" of cd i is always the label of button"pagnam" of the chosen card: (f.i. "Klaus")
and not the label of button "pagnam" of cd i.
so the result is 25 times "Klaus: in field "Index"

Moreover:
In the stackscript:

Code: Select all

command fictie
   answer "fictie"
end fictie
In the messagebox: send Fictie
answer :can't find handler :?: :?:

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

Re: command not send / puzzle

Post by Klaus » Wed Jul 09, 2014 1:02 pm

AHA!

OK:
1. When you have the handlers in the stack script, then there is no need to SEND anything, just call the handler:

Code: Select all

...
case "deletecard"
  deletecard
break
case "createcard"
    global tName
    ask "welke naam"
    put it into tName
    create_card
break
case "herstel index"
   herstelindex
break
...
2. If you really nee to SEND something, then you need to also supply the addressee just like a letter that you send!
...
send "Name of handler" to cd XYZ
...

Sorry, no idea what is going wrong with your index.
Did you debug that ahdler and check all variables?


Best

Klaus

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: command not send / puzzle

Post by magice » Wed Jul 09, 2014 1:18 pm

In the stackscript:


command herstelindex
put number of cards into tNum
repeat with i=1 to tNum
put line i of fld "index" into tInd
put label of button "pagnam" of cd tInd into tVar
put tVar & cr after fld "index"
end repeat
sort lines of fld "index"
end herstelIndex
shouldn't the word "command" be "on", or is this something i have been missing?

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

Re: command not send / puzzle

Post by Klaus » Wed Jul 09, 2014 1:50 pm

No, "command" is correct! :D

RunRev introduced this some versions ago to distinguish LCs own handlers
like "on mouseup" from custom (user defined) handlers.

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: command not send / puzzle

Post by magice » Wed Jul 09, 2014 2:03 pm

Klaus wrote:No, "command" is correct! :D

RunRev introduced this some versions ago to distinguish LCs own handlers
like "on mouseup" from custom (user defined) handlers.
Great....another "old habit" I probably need to break. I suppose it will help readability though.

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

Re: command not send / puzzle

Post by Klaus » Wed Jul 09, 2014 2:16 pm

Hi Rob,

Code: Select all

command herstelindex
    put number of cards into tNum
   repeat with i=1 to tNum
      put line i of fld "index" into tInd
      put label of button "pagnam" of cd tInd into tVar
      put tVar & cr after fld "index"
   end repeat
   sort lines of fld "index"
end herstelIndex
This will only work if the number of lines of fld "index" is really the number of cards.
But with this script, this is not the case, because it will have an empty line in it,
caused by the last CR that our are adding.

and you do not completely replace the text of fld "index" so all your cards may appear several times in that field!

Not sure what exactly you are trying to do, but if you want a list of all your card names in the field "indx" (and thus
as the label of your button "pagnum") I would suggest to use "the cardnames" of stack XYZ :D

Try something like this, using the actualy card names as the "references" and NOt the content of fld "index":

Code: Select all

command herstelindex
    put the cardnames of this stack into tListOfCards

   ## Do not access fields in a a repeat loop, that will slow down the thing! Use a variable first and then put it into the field:
   put empty into tIndex
   repeat for each line tCard in tListOfCards
      put the label of button "pagnam" of cd tCArd into tVar
      put tVar & cr after tIndex
   end repeat

   ## Now get rid of trailing CR!!!
   delete char -1 of tIndex
   sort tIndex
   put tIndex into fld "index"
  ## or maybe AFTER fld "index" if you really want to :-)
end herstelIndex
But maybe I misunderstood you completely :D


Best

Klaus

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: command not send / puzzle

Post by robm80 » Wed Jul 09, 2014 6:56 pm

Code: Select all

command herstelindex
          put number of cards into tNum
          repeat with i=1 to tNum
             put label of button pagnam of cd i  &cr after tVar
          end repeat
          delete char -1 of tVar
   sort tVar
     put tVar into fld "index"
      ##put tVar & cr after fld index
   sort lines of fld index
end herstelIndex
I followed it in the debugger: the script stops after repeat and tVar is empty.
Probably I did not understand your script well!

But:
I created nearly the same stack, where I replaced button "pagnam" by a field "pagnam".
No problem at all with nearly the same scripts:
command herstelindex
filter fld index with empty
put number of cards into tNum
repeat with i=1 to tNum
put fld pagnam of cd i into tVar
put tVar & cr after fld index
end repeat
sort lines of fld index
filter fld index without empty
end herstelIndex
No send anymore: fictie-problem solved!!

Very interested in your comment
Rob

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

Re: command not send / puzzle

Post by Klaus » Wed Jul 09, 2014 7:35 pm

Dag Rob,

hm, molto misterioso :D
I'm out of ideas!

Could you eventually post the stack here?
You need to ZIP it first.


Best

Klaus

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: command not send / puzzle

Post by robm80 » Wed Jul 09, 2014 8:31 pm

Could you eventually post the stack here? You need to ZIP it first.
Which one? The one with the button and problems or the one with the field whithout any problem.
What do you mean with "post here? where is here? Attachment perhaps?

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

Re: command not send / puzzle

Post by Klaus » Wed Jul 09, 2014 9:54 pm

robm80 wrote:The one with the button and problems or the one with the field whithout any problem.
The first of course 8)
robm80 wrote:What do you mean with "post here? where is here? Attachment perhaps?
"Here" is the forum, and yes, please note the button "Upload attachment" under the text entry field when you post "here" :D

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: command not send / puzzle

Post by robm80 » Wed Jul 09, 2014 11:09 pm

Coming....
Probus.zip
(8.41 KiB) Downloaded 266 times

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

Re: command not send / puzzle

Post by Klaus » Thu Jul 10, 2014 1:11 am

NONE of your buttons "pagnam" has a LABEL! 8)

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: command not send / puzzle

Post by robm80 » Thu Jul 10, 2014 6:52 am

My fault starts in the "createcard": set label of button "pagnam" to tName, where in the problemless version the statement is "put tName into fld "pagnam"".
What should it be in LC? Name of button is wrong as is label of button.
I am used to the word "caption", but that word is not in the dictionary

Well, what is in LC-language a "caption" of a button? :shock:

Post Reply