Page 1 of 2
command not send / puzzle
Posted: Wed Jul 09, 2014 10:37 am
by robm80
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
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 11:13 am
by Klaus
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
Best
Klaus
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 12:47 pm
by robm80
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

Re: command not send / puzzle
Posted: Wed Jul 09, 2014 1:02 pm
by Klaus
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
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 1:18 pm
by magice
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?
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 1:50 pm
by Klaus
No, "command" is correct!
RunRev introduced this some versions ago to distinguish LCs own handlers
like "on mouseup" from custom (user defined) handlers.
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 2:03 pm
by magice
Klaus wrote:No, "command" is correct!
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.
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 2:16 pm
by Klaus
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
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
Best
Klaus
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 6:56 pm
by robm80
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
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 7:35 pm
by Klaus
Dag Rob,
hm, molto misterioso
I'm out of ideas!
Could you eventually post the stack here?
You need to ZIP it first.
Best
Klaus
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 8:31 pm
by robm80
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?
Re: command not send / puzzle
Posted: Wed Jul 09, 2014 9:54 pm
by Klaus
robm80 wrote:The one with the button and problems or the one with the field whithout any problem.
The first of course
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"

Re: command not send / puzzle
Posted: Wed Jul 09, 2014 11:09 pm
by robm80
Re: command not send / puzzle
Posted: Thu Jul 10, 2014 1:11 am
by Klaus
NONE of your buttons "pagnam" has a LABEL!

Re: command not send / puzzle
Posted: Thu Jul 10, 2014 6:52 am
by robm80
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?
