Page 1 of 1

can't delete card

Posted: Sat Aug 09, 2014 10:42 pm
by robm80
here the script that will not remove a card:

Code: Select all

command verwijderkaart
   answer "remove card selected: hit OK"&cr&\
   "not yet selected: hit Cancel, select card, after that hit OK" with Cancel and OK
   if it="OK" then
      put selectedtext of fld index into tSLT
      put lineoffset(tSLT,fld index) into tLO
   else
      break
   end if
   go card tSLT
   delete this card      ----------errormessage, see below
   sort lines of fld "index"
end verwijderkaart
errormessage
stack "NAW": execution error at line n/a (Object: stack locked, or object's script is executing)
As far as I may understand I remove the line "go card tSLT": now the errormessage is:
"stack "NAW": execution error at line 31 (Chunk: can't find card), char 4
But card tSLT is still there :!:

What's wrong :?:

Re: can't delete card

Posted: Sun Aug 10, 2014 12:59 am
by dunbarx
Hi.

Have you tested this by stepping through the handler? I am thinking that maybe the reference to the card in field "index" may not be valid, and that there is no card to delete. If you step through, you will see if your navigation really sent you to the right place.

Not sure about this, but do check...

Craig newman

Re: can't delete card

Posted: Sun Aug 10, 2014 6:56 am
by robm80
Have you tested this by stepping through the handler?
I did: nothing abnormal.
Suddenly I rememerd another stack, where it worked fine (thanks to Klaus).
I copied it.
Bingo.

Thanks anyway, Rob

Re: can't delete card

Posted: Sun Aug 10, 2014 7:24 am
by SparkOut
It may not be related to the problem you had originally, but please please get into the habit of putting quotes around object references. They are *not* variables, ie

Code: Select all

put selectedtext of fld index into tSLT
should be

Code: Select all

put the selectedtext of fld "index" into tSLT

Re: can't delete card

Posted: Sun Aug 10, 2014 7:32 am
by robm80
I have corrected my lifestyle already :lol:

Re: can't delete card

Posted: Mon Aug 11, 2014 12:15 pm
by Klaus
Hi Rob,

the error dialog is correct: You cannot delete a card where an object's script is currently executing!

Do something like this:
Add a new handler to your stack script:

Code: Select all

command delete_card the_card
  delete card the_card
end delete_card
Then in the handler "verwijderkaart"

Code: Select all

 ...
  ## User a littel delay to give the script the time to finish.
  ## We use the card number as a paramer for the new handler
  put the number of this cd into tNumber
  send "delete_card tNumber" to me in 100 milisecs
  sort lines of fld "index"
end verwijderkaart
Best

Klaus

P.S.
No need to change your lifestyle, change the way you think and script! 8)

Re: can't delete card

Posted: Mon Aug 11, 2014 1:25 pm
by robm80
Hi Kluas,
for the moment there is this script in the menubuilder:

Code: Select all

case "deletecard"
         global tLO,tSLT
         answer "te verwijderen kaart al geselecteerd: klik op OK"&cr&\
         "kaart nog niet geselecteerd: klik op Cancel, selecteer de kaart en klik daarna op OK" with Cancel and OK
         if it="OK" then
            put selectedtext of fld index into tSLT
            put lineoffset(tSLT,fld index) into tLO
            send "delete_card" to this stack in 1
         end if
         break
and in the stackscript:

Code: Select all

command delete_card
global tSLT,tLO
delete card tSLT
delete line tLO of fld "index"
end delete_card
This works well. Any reason to change ?

Re: can't delete card

Posted: Mon Aug 11, 2014 2:28 pm
by Klaus
Hi Rob,
robm80 wrote:Hi Kluas,...
Sigh :(
robm80 wrote:This works well. Any reason to change ?
Not that I knew of!


Best

Klaus