File paths in web-based stacks

Jim Ault JimAultWins at yahoo.com
Fri Nov 3 13:02:35 EST 2006


> Of course, when you read your stack from a web server, it resides
> completely in memory, so the filename is empty. So the routine above
> does nothing.
The defaultFolder is the one with the Rev app at startup.  You could start
there and get the user name and path to that folder, then create a folder
where you want.

Add 'try' to the defaultFolder
or 'if the filename of this stack is empty'

..code
setDefaultFolder
..code

on setDefaultFolder
  > set the itemDelimiter to "/"
  > get the [effective] filename of this stack
  if it is not empty then
     > set the defaultFolder to item 1 to -2 of it
  else
    --> use the base URL of the stack on the server
  end if
end setDefaultFolder

I use three routines in all of my business apps, since I don't know which
computer will be hosting the stacks.

global zFtpPathhAssets, zFtpPathhTemp
on preopenstack
  set the defaultFolder to rootLocalFolder()
  put ftpRootFolder() into zFtpPathhAssets
  put ftpRootFolder() &"temp/" into zFtpPathhTemp
end preopenstack

function rootLocalFolder() --local hard drive
function rootFolder() --app location where ever
function ftpRootFolder()  --obvious

Hope this is close to what you need.

Jim Ault
Las Vegas

On 11/3/06 10:49 AM, "Devin Asay" <devin_asay at byu.edu> wrote:

> Greetings earthlings!
> 
> I am teaching my students about launching stacks from a web server
> using 'go stack url ...'. I mentioned to them that they can launch
> any stack on any web server as long as they know the URL (and
> assuming permissions are set correctly, etc.) But I ran into a
> conundrum that I'm trying to figure out.
> 
> When I write stacks that are intended to run from the web, I avoid
> using relative file paths for accessing external resources, instead I
> store the base URL in a custom property and make everything relative
> to that. But what if, as I told my students, one of them is sitting
> at home and launches an example stack from our classroom discussion
> from my web server, and one of the things in that example stack is a
> handler that sets the defaultFolder to the folder containing the
> current stack? You know the drill...
> 
> set the itemDelimiter to "/"
> get the [effective] filename of this stack
> set the defaultFolder to item 1 to -2 of it
> 
> Of course, when you read your stack from a web server, it resides
> completely in memory, so the filename is empty. So the routine above
> does nothing.
> 
> So I started thinking, could I write a handler and put it in a
> library or frontscript  that would check to see if the called stack
> sets the defaultFolder, and if it does, would somehow substitute a
> base URL for the defaultFolder? Then every time a relative file path
> was used in the called stack it would look instead at the URL. I can
> see two problems with this:
> 
> 1. How to thoroughly search the stack for the presence of the command
> 'set the defaultFolder' (or 'set the folder' or 'set the directory').
> Is there a 'search all scripts in a stack' command? It's obviously
> possible, because the Search and Replace utility in the IDE can do
> that. (Yes, I know I can loop through the entire stack and check
> every script, but is there something that already does this?)
> 
> 2. How to intercept references to file paths in handlers and "recast"
> them as URLs. Short of adding decision structures in all of the
> stacks I might want to launch from a server, which would defeat the
> purpose, is there any conceivable way to do this from a calling stack
> or compiled app?
> 
> Before I spend hours trying to script this, what do you all think? Is
> such a thing feasible? A pipe dream? So blatantly obvious that you're
> all snickering at me?
> 
> Thanks for any ideas.
> 
> Devin
> 
> Devin Asay
> Humanities Technology and Research Support Center
> Brigham Young University
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list