Relative Paths

Ken Ray kray at sonsothunder.com
Wed Apr 7 14:01:22 EDT 2004


> SRC
>   TRANSCRIPT
>       COMMON
>           ALGO
>               MATH.REV (CONTAINS EXPMOVAVG, SCALE?)
>   FINANCIAL
>       INDICATORS.REV (CONTAINS MACD, PTP?)
>   DATABASE
>       EARNINGS.REV (CONTAINS INTERFACE TO EARNINGS DB)
>       HLCV.REV (CONTAINS INTERFACE TO HLCV DB)
> 
>   ANALYZER
> ANALYZER.REV (A APPLICATION)

Based on the tree above, there was a space before ANALYZER.REV, so for my
example I'm assuming it's inside the ANALYZER folder at the same level as
the FINANCIAL folder, as in:

>   ANALYZER
>       ANALYZER.REV (A APPLICATION)

If your application "ANALYZER.REV" is running and needs to get access to
INDICATORS.REV (let's say you want to open it), then all you need to do is
to say:

  open stack "../financial/indicators.rev"

Since there is no preceding "/" or volume identifier (like "C:" as in
Windows), Rev assumes that this is a relative path to the current working
directory. The "../" functions like in URL paths and goes "up" a level.

The CWD is initially defined as the location of the running Revolution
engine, but may be redefined by setting "the directory" (or "the
defaultFolder"). 

Now when a stack is running as a standalone app, "the directory" is the
location of the standalone. When it is running as a stack in the Rev IDE,
"the directory" is the location of the Revolution application. For
development purposes, it makes sense to always make "the directory"
correspond to where the initial stack is because eventually that stack will
become a standalone itself and so "the directory" will be in the same
relative location.

To do this, I have this handler I run on preOpenStack of the stack that will
become my standalone application:

on preOpenStack
  set the directory to MyFolder()
end preOpenStack

function MyFolder
  put the filename of this stack into tPath
  set the itemDel to "/"
  if (the platform = "MacOS") and isOSX() and (the environment <>
"development") then
    delete item -4 to -1 of tPath
    return tPath
  else
    return item 1 to -2 of tPath
  end if
end MyFolder

function isOSX
  set the itemDel to "."
  return (item 1 of the systemVersion >=10)
end isOSX

This way, even if the stack is running in the IDE, "the directory" is set to
the folder where the stack is, and all relative paths will be calculated
from that location. And when the stack becomes a standalone application,
nothing changes and all is well.

Hope this helps,


Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


> From:     "Kevin" <nnoydb at excite.com>
> Reply-To: nnoydb at excite.com, How to use Revolution
> <use-revolution at lists.runrev.com>
> Date: Wed,  7 Apr 2004 13:38:08 -0400 (EDT)
> To:     use-revolution at lists.runrev.com
> Subject: Re: Relative Paths
> 
> 
> I use source control and develop/test my Revolution application in different
> IDEs (Windows, OS X, Linux, Sun Solaris, AIX).  I maintain and
> application/projects library directory tree similar to below.
> 
> SRC
>   TRANSCRIPT
>       COMMON
>           ALGO
>               MATH.REV (CONTAINS EXPMOVAVG, SCALE?)
>   FINANCIAL
>       INDICATORS.REV (CONTAINS MACD, PTP?)
>   DATABASE
>       EARNINGS.REV (CONTAINS INTERFACE TO EARNINGS DB)
>       HLCV.REV (CONTAINS INTERFACE TO HLCV DB)
> 
>   ANALYZER
> ANALYZER.REV (A APPLICATION)
> 
> This type of project/application/library management is common in large
> development projects.  The constructs of module inclusion provided in Runtime
> Revolution do not seem to allow this source management technique.  I realized
> you are quite experienced in developing products using Runtime Revolution.  I
> may not properly understand the construct Runtime Revolution provides I would
> appreciate a education if you have the time.  However, I have seen very few
> postings from developers involved in large projects.  My application is
> extremely large and requires reusable interfaces for any number of
> applications.  I see no simple way if implementing this with the given
> constructs.   
> 
> 
> NOTE:  Every popular language C,C++,Visual Basic? has some form of file
> inclusion by way of relative paths.
> 
> Kevin
> 
> 
> 
> -==-=-=-=-=-=-==-=-=-=-=-=-=-=-==-=-=-=-=-=-
> Disclaimer:
> 
> Any resemblance between the above views and those of my
> employer, my terminal, or the view out my window are purely
> coincidental. 
> Any resemblance between the above and my own views is non-deterministic.
> 
> The question of the existence of views in the absence of anyone to hold
> them
> is left as an exercise for the reader. The question of the existence of
> the reader
> is left as an exercise for the second god coefficient.
> (A discussion of non-orthogonal, non-integral polytheism is beyond the
> scope of this article.)
> 
> 
> 
> --- On Wed 04/07, Ken Ray < kray at sonsothunder.com > wrote:
> From: Ken Ray [mailto: kray at sonsothunder.com]
> To: use-revolution at lists.runrev.com
> Date: Wed, 07 Apr 2004 11:26:27 -0500
> Subject: Re: Relative Paths
> 
> Kevin,<br><br>Why do you need to add stacks to the stackFiles property? I've
> been using<br>MC/Rev for years and never needed to do this to open other
> stacks. When you<br>open a stack in the IDE, it automatically defaults to the
> path where the<br>executable lies, and only changes when you set "the
> directory" (or the<br>"defaultFolder"). All relative paths are from
> ther<br>e.<br><br>Does this help?<br><br>Ken Ray<br>Sons of Thunder
> Software<br>Email: kray at sonsothunder.com<br>Web Site:
> http://www.sonsothunder.com/<br><br><br>> From:     "Kevin"
> <nnoydb at excite.com><br>> Reply-To: nnoydb at excite.com, How to use
> Revolution<br>> <use-revolution at lists.runrev.com><br>> Date: Wed,  7 Apr 2004
> 04:52:15 -0400 (EDT)<br>> To:     use-revolution at runrev.com<br>> Subject:
> Relative Paths<br>> <br>> <br>> <br>> I am a bit confused.  How does one
> create applications that can be used in the<br>> IDE on multiple platforms
> without relative paths.  When I add a satck file to<br>> the the stackFiles p
> roperty (in the property explorer) the fully qualified<br>> path is used.
> When I copy the stack to another platform the path (something<br>> like
> "/Users/me/src/transcript/common/xxx.rev") will not function.  Please<br>>
> someone explain how this is supposed to work?<br>> <br>> <br>> Kevin<br>>
> <br>> <br>> -==-=-=-=-=-=-==-=-=-=-=-=-=-=-==-=-=-=-=-=-<br>> Disclaimer:<br>>
> <br>> Any resemblance between the above views and those of my<br>> employer,
> my terminal, or the view out my window are purely<br>> coincidental. <br>> Any
> resemblance between the above and my own views is non-deterministic.<br>>
> <br>> The question of the existence of views in the absence of anyone to
> hold<br>> them<br>> is left as an exercise for the reader. The question of the
> existence of<br>> the reader<br>> is left as an exercise for the second god
> coefficient.<br>> (A discussion of non-orthogonal, non-integral polytheism is
> beyond the<br>> scope of this article.)<br>> <br>> <br>> <br>> _______________
> ________________________________<br>> Join Excite! -
> http://www.excite.com<br>> The most personalized portal on the Web!<br>>
> _______________________________________________<br>> use-revolution mailing
> list<br>> use-revolution at lists.runrev.com<br>>
> http://lists.runrev.com/mailman/listinfo/use-revolution<br><br>_______________
> ________________________________<br>use-revolution mailing
> list<br>use-revolution at lists.runrev.com<br>http://lists.runrev.com/mailman/lis
> tinfo/use-revolution<br>
> 
> _______________________________________________
> Join Excite! - http://www.excite.com
> The most personalized portal on the Web!
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list