can't delete card

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
robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

can't delete card

Post by robm80 » Sat Aug 09, 2014 10:42 pm

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 :?:

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: can't delete card

Post by dunbarx » Sun Aug 10, 2014 12:59 am

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

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

Re: can't delete card

Post by robm80 » Sun Aug 10, 2014 6:56 am

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

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: can't delete card

Post by SparkOut » Sun Aug 10, 2014 7:24 am

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

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

Re: can't delete card

Post by robm80 » Sun Aug 10, 2014 7:32 am

I have corrected my lifestyle already :lol:

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

Re: can't delete card

Post by Klaus » Mon Aug 11, 2014 12:15 pm

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)

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

Re: can't delete card

Post by robm80 » Mon Aug 11, 2014 1:25 pm

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 ?

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

Re: can't delete card

Post by Klaus » Mon Aug 11, 2014 2:28 pm

Hi Rob,
robm80 wrote:Hi Kluas,...
Sigh :(
robm80 wrote:This works well. Any reason to change ?
Not that I knew of!


Best

Klaus

Post Reply