Stack Directory?

Ken Ray kray at sonsothunder.com
Wed Sep 11 23:08:00 EDT 2002


Actually, with MC 2.4.2 and above, you can use regular expressions (yeah,
it's the RegEx guy again... ;-) to do this:

function AppPath
  local tPath
  get matchText(the effective fileName of this stack,"(.*\/)",tPath)
  return tPath
end AppPath

For those of you trying to pick up RegEx, the code here:

  (.*\/)

Means this:

  .* => Match all characters starting from the first character of the string
(the effective filename of this stack)...

  \/  => ... until you match a '/' (the '\' is to 'escape' the forward
slash), and then keep going until you match the last '/' in the string.

  ( )  => ... and return what you found in the first variable supplied to
the matchText function (tPath).

The key here is that .* is a "greedy match", which means it will match
everything until the *last* match of the forward slash. If you use .*?, it
will only go to the first match of the forward slash (which would return the
volume the stack was on).

Examples:

If "the effective filename of this stack" is
"C:/Development/MyStuff/MyProject.mc", then:

using (.*\/) would return:

   C:/Development/MyStuff/

and using (.*?\/) would return:

   C:/

Yes, yes, I know... I'm still working on putting together a RegEx
tutorial... :-)

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


----- Original Message -----
From: "Dominique" <mcdomi at free.fr>
To: <metacard at lists.runrev.com>
Sent: Wednesday, September 11, 2002 3:00 PM
Subject: Re: Stack Directory?


> >  function AppPath
> >    put the filename of <mainstackName> into tPath
> >    set the delimiter to "/"
> >    delete last item of tPath
> >    return tPath &"/"
> >  end AppPath
>
> Beautiful :-)
>
>
> --
> Regards,
> (-8 Dominique
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>




More information about the metacard mailing list