Script View Thoughts

Want to talk about something that isn't covered by another category?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Script View Thoughts

Post by richmond62 » Mon Dec 26, 2022 10:39 am

It is entirely possible that I am so out of the loop that I have missed this, but, at the risk of
being told I am out of the loop, here goes:

About 19 years ago I was doing what was called a Master's degree in Computers and IT (and
was most definitely NOT up to anything that in my experience was at Masters' degree level),
and had to "learn" Visual BASIC 5 (meaning that the son of a taxi-driver from India and I spent
most of the time explaining to the lecturer where she was getting things wrong). Anyway, to cut
a short story long, I was not enamoured of Visual B 5 in the slightest: the only fun being that
I would go home every evening and duplicate the exercises we were given in what was at that time
called Runtime Revolution (and, boy-oh-boy, did the lecturer rise beautifully to the bait when
I demonstrated this to my fellow students the nexy day).

The ONLY thing, and that is after 19 years, that suddenly occurred to me for no obvious reason,
that was interesting was that as Visual B 5 is, supposedly, object-based, objects, unlike in
Runtime Revolution, do not contain their own code/scripts, and the script of a "stack"
(for want of another word) was presented as a continuous affair with each script relating
to each object presented sequentially. This, in fact, was the first thing that made me feel
that RunRev was a 'superior beast' to Visual B 5.

HOWEVER, having stated that, I was wondering if there is an easy way to view all the scripts of all the objects
in a LiveCode project (and I am using 'project' rather than 'stack' for the simple reason that a LiveCode stack
can contain many substacks) as a continuous list.
-
VB5.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Script View Thoughts

Post by richmond62 » Mon Dec 26, 2022 11:12 am

BBEdit:
-
SShot 2022-12-26 at 12.15.17.png
-
is messy . . .

no indication of where objects are located (cards) . . .

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Script View Thoughts

Post by richmond62 » Mon Dec 26, 2022 12:40 pm

I would just suppose it would be entirely possible to write a LiveCode stack
that could import other stacks as text into a field.

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Script View Thoughts

Post by stam » Mon Dec 26, 2022 1:27 pm

There are a number of ways of doing this; you could use the built-in project browser - every object/card/stack script is a click away. But it can be temperamental. You need to enable showing front- and backscripts if you want access to these as well, but all doable within the PB.

Alternatively I there is a stack out there that is like the project browser on steroids - but very compact/powerful = learning curve. Can't remember the name of the particular stack, but I did find it a bit too complex and actually the PB does all that I need - when it works ;)

To some extent, Richard's Devolution plugin does this well (if you don't have this already it's at https://www.fourthworld.com/products/de ... index.html).
This has a nice feature call 'messagePath' that basically shows you card, stack, library, front- and backscripts in an accessible manner. Works well, but not as complete as the PB, as you don't get object scripts (buttons etc). It also does not iterate through substacks, so if you use these as behaviours you're out of luck... but it may work for your purposes:
mpath.jpg
Or I guess just wait for the new IDE as the little I've seen of it suggests that the project browser will have a central role, as it should be...

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7239
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Script View Thoughts

Post by jacque » Mon Dec 26, 2022 6:10 pm

richmond62 wrote:
Mon Dec 26, 2022 12:40 pm
I would just suppose it would be entirely possible to write a LiveCode stack
that could import other stacks as text into a field.
I have a script that does that, someone on the HC team wrote it 35 years ago. I'd have to dig for it if you're interested. It should be somewhere in my archives.

Or you could write one yourself. It just loops through a stack, all the cards and their controls, and writes the name and script to a text file.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Script View Thoughts

Post by dunbarx » Mon Dec 26, 2022 11:08 pm

Richmond.

You know how to do this.

I wrote a HC utility that is as old as Jacque's, and ported it over to LC. In a large project, it takes a few seconds, and the trick is not to navigate much. From the main stack, though it hardly matters, (pseudo):

Code: Select all

put the script of this stack & return after scriptAccum
 repeat with y = 1 to the number of cards
    put the script of  card y & return after scriptAccum
       repeat with z = 1 to the number of controls of cd y
           put the script of control z of  card y & return after scriptAccum
        end repeat
    end repeat

  repeat with x = 1 to the number of subStacks of this stack
    put the script of subStack x & return after scriptAccum
     repeat with y = 1 to the number of cards of subStack x of this stack
      put the script of cd y of subStack x of this stack & return after scriptAccum
       repeat with z = 1 to the number of controls of cd y of subStack x of this stack
         put the script of control z of  card y of stack x & return after scriptAccum
      end repeat
    end repeat
  end repeat
That sort of thing. I am not sure that the designation "subStack x of this stack" will be resolved properly by LC. This is untested, and I bet there are errors in the hierarchy I threw together in a hurry, but you surely get the point. It may not organize the script list the way you want it...

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Script View Thoughts

Post by dunbarx » Mon Dec 26, 2022 11:17 pm

Richmond.

No surprise, one cannot:

Code: Select all

get the name of sub stack 2 of this stack
or anything like that. You will have to collect "the substacks" of the mainStack, and work from that list, as opposed to the presumptuous thinking in my original post.

Craig

NoN'
Posts: 84
Joined: Thu Jul 03, 2008 9:56 pm
Location: Paris
Contact:

Re: Script View Thoughts

Post by NoN' » Wed Jan 11, 2023 3:03 pm

Hello,

First of all, I send my best wishes to the readers of this forum for the new year.

I got my hands on this tool that I programmed a long time ago but that continues to be very useful. The name is explicit: "ScriptExtract".
It's time to share...
Only one constraint: the stack must not be protected by a password!
I already put the script online and I don't doubt for a second that it can be greatly improved (not me, not much time...).

Code: Select all

on openStack
  choose browse tool
end openStack


on importStOb
   answer file "Quelle pile ?"
   if it <> "" then
      put it into lefich
      put it into fld "Mainstackpath"
      set lockmessages to true
      set cursor to watch
      lock screen
      go lefich in a new window
      set itemdelimiter to "/"
      put last item of lefich into ron
      
      put the substacks of stack lefich into stackliste
      put "  +++++++++++++++++  " into lesep
      put "  -------  " into lesep2
      
      put "Sauvegarde des script du projet : " & ron & "  à la date du " & the short date & return & return into scriptLitter
      
      if script of stack lefich is not "" then ---  on s'occupe de la pile principale...
         put lesep & "Script de la pile : " & lefich & lesep & return & script of stack lefich & return after scriptLitter
      end if
      
      
      repeat with i = 1 to the number of cds in stack lefich
         
         put the long name of cd i of stack lefich into ron
         put script of cd i of stack lefich into lescript 
         
         if lescript is not "" then ---script des cartes
            put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
         end if
         
         
         repeat with z = 1 to the number of btns in cd i of stack lefich  --- script des boutons
            put the long name of btn z of cd i of stack lefich into ron
            put script of btn z of cd i of stack lefich into lescript
            if lescript is not "" then
               put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
            end if
         end repeat
         
         
         repeat with z = 1 to the number of flds in cd i of stack lefich  --- script des champs
            put the long name of fld z of cd i of stack lefich into ron
            put script of fld z of cd i of stack lefich into lescript
            if lescript is not "" then
               put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
            end if
         end repeat
         
         
         repeat with z = 1 to the number of images in cd i of stack lefich  --- script des images
            put the long name of image z of cd i of stack lefich into ron
            put script of image z of cd i of stack lefich into lescript
            if lescript is not "" then
               put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
            end if
         end repeat
         
      end repeat
      
      unlock screen
      set the thumbPosition of scrollbar "LigneTraitement" of stack "ScriptExtract" to 10
      lock screen
      
      repeat with lap = 1 to the number of lines in stackliste  --- on s'occupe des sous-piles
         put line lap of stackliste into lac
         put the long name of stack lac into ron
         
         put script of stack lac into lescript  --- script des sous-piles
         if lescript is not "" then
            put lesep & "Script de la pile : " & ron & lesep & return & script of stack lac & return after scriptLitter
         end if
         
         repeat with i = 1 to the number of cds in stack lac
            put the long name of cd i of stack lac into ron
            put script of cd i of stack lac into lescript  --- script des cartes de sous-piles
            if lescript is not "" then
               put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
            end if
            
            repeat with z = 1 to the number of btns in cd i of stack lac
               put the long name of btn z of cd i of stack lac into ron
               put script of btn z of cd i of stack lac into lescript  --- script des boutons de sous-piles
               if lescript is not "" then
                  put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
               end if
            end repeat
            
            
            repeat with z = 1 to the number of flds in cd i of stack lac
               put the long name of fld z of cd i of stack lac into ron
               put script of fld z of cd i of stack lac into lescript  --- script des champs de sous-piles
               if lescript is not "" then
                  put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
               end if
            end repeat
            
            
            repeat with z = 1 to the number of images in cd i of stack lac
               put the long name of image z of cd i of stack lac into ron
               put script of image z of cd i of stack lac into lescript  --- script des images de sous-piles
               if lescript is not "" then
                  put lesep2 & "Script de : " & ron & lesep2 & return & lescript & return after scriptLitter
               end if
            end repeat
            
         end repeat
         
      end repeat
      
      close stack lefich
      go stack "ScriptExtract"
      
      unlock screen
      set the thumbPosition of scrollbar "LigneTraitement" of stack "ScriptExtract" to 20
      lock screen
      put the number of lines in scriptLitter into nblines
      
      put scriptLitter into fld "TousleScripts" of stack "ScriptExtract"
      put nblines into fld "NbLignes" of stack "ScriptExtract"
      put the number of chars in fld "TousleScripts" of stack "ScriptExtract" into fld "NbCaract" of stack "ScriptExtract"
      
      put "on end if" into ron
      put 20 into laposition
      repeat with i = 1 to nblines --- of stack "ScriptExtract"
         if word 1 of line i of fld "TousleScripts" is in ron then---- of stack "ScriptExtract"
            set textstyle of word 1 to 2 of line i of fld "TousleScripts" of stack "ScriptExtract" to bold
         end if
      end repeat
      
      set the thumbPosition of scrollbar "LigneTraitement" to 0
      
   end if
   
end importStOb
See attached files...

The execution time can be greatly accelerated by deleting the last command (that modify, in bold, the format of the lines that frame the commands or functions).

Renaud
Attachments
Screen ScriptExtract.jpg
ScriptExtract.zip
(2.84 KiB) Downloaded 57 times

Post Reply

Return to “Off-Topic”