File paths in web-based stacks

Jim Ault JimAultWins at yahoo.com
Fri Nov 3 19:23:20 EST 2006


On 11/3/06 1:21 PM, "Devin Asay" <devin_asay at byu.edu> wrote:

> In my case, I have dozens of example stacks that I have created over
> the years for my classes, none of which were written with the idea
> that they would someday be called from a web server. Now that I'm
> starting to do that, I don't really want to rewrite them all. So what
> I'm really asking is, is there a way to examine these stacks from the
> calling stack or standalone, check to see whether the default folder
> is set anywhere in the stack, then override the 'set the
> defaultFolder' so that the stack looks at the web server for external
> files, instead of in the relative file path as normally determined by
> the defaultFolder property.
> 
> I can't think of a simple way to do it.

I don't think there is an easy way to do it by a simple override.
Of course, with your power and influence, you could make it an assignment
for your students to modify the scripts :-)

seriously...
To find the stack files that contain the word "defaultFolder" I would use
the batch search in BBEdit, thus getting a short list of those stacks that
need to be updated.  This works because the scripting is visible to a word
processor

You can always get and set the script of objects.

on openstack
insert the script of this card into back --always available now
put "http://server.com/folderA/folderB/" into newString

repeat with lnNum = 1 to the number of lines in fld oldStkList
  go stack url ("http://etc.com/"& line lnNum of fld oldStkList
   doScanAndReplaceDefaultF --located in the card script=>back
end repeat


put the script of this stack into oldScript
put 0 into pos

--simple -----
replace "defaultFolder" with newString in oldScript
set the script of this stack to oldScript
save this stack

--more complex logic
put 1 into pos
repeat until pos = 0
   put lineoffset("defaultFolder", oldScript) into pos
   put line 1 to pos-1 of oldScript into preLines

   put line pos of oldScript into currLine
   --decide if replace is the right thing to do
   replace "defaultFolder" with newString in currLine

   put cr & preLines & cr & currLine after newScript
   delete line 1 to pos of oldScript

end repeat
set the script of this stack to newScript
save this stack

Depending on where the scripting is located......................
script of this stack
repeat with gg = 1 to the number of groups

repeat with dd = 1 to the number of cards

repeat with cc = 1 to the number of controls
if the long name of control x contains "card" then --it is a card control
if the long name of control x contains "group" then --it is a bg control


Hope this gives you some ideas.



Jim Ault
 





More information about the use-livecode mailing list