Get scriptlines per card in a stack

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Get scriptlines per card in a stack

Post by mrcoollion » Fri Mar 18, 2016 5:26 pm

I again have a question.

I want to go through all the script lines per card in a stack and get information from those scriptlines.
I will be using this to make a translation routine that filters all scriptlines on e.g. message texts and puts those in a database for translation purposes.

How can i make this possible :?:

PS. I have made a routine that gets all objects from all cards and puts those in a database so I can make a translation.

Regards,

Paul

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Get scriptlines per card in a stack

Post by mrcoollion » Fri Mar 18, 2016 6:29 pm

Already found the answer myself. See example script I made below.

Code: Select all

on mouseUp
   put the name of this stack into tCurrentStack
   put the short name of this stack into tCurrentStackShort
   put the id of this stack into tCurrentStackID
   put the cardNames of stack tCurrentStack into tCards
   repeat with tCardIndex = 1 to the number of lines in tCards
      put line tCardIndex of tCards into tCurrentCard
      put the id of card tCurrentCard into tCurrentCardID
      put the script of card tCurrentCard into CardScriptLines
      answer the number of lines in CardScriptLines
      repeat with tLineIndex = 1 to the number of lines in CardScriptLines
         answer "Stack: "& tCurrentStackShort & lf & "Card: " &tCurrentCard & lf & "Script line: "& line tLineIndex in CardScriptLines
         put "breakpoint"into tempVar// Just to enable me to put a breakpoint here here
      end repeat
   end repeat
end mouseUp

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

Re: Get scriptlines per card in a stack

Post by dunbarx » Fri Mar 18, 2016 8:05 pm

I made a script analyzer for another purpose. Generically, you can (pseudo):

Code: Select all

repeat with y = 1 to the number of cds
    doSomething with the script of cd y
    repeat with u = 1 to the number of controls of cd y
      doSomething with the script of control u of cd y
    end repeat
   doSomething with the script of this stack
end repeat
Craig Newman

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Get scriptlines per card in a stack

Post by mrcoollion » Fri Mar 18, 2016 8:38 pm

Thx for the support Craig :D

Post Reply