Trouble With Relitive Paths.. Thread last updated on 2008-06-22 22:55:13

Posted by member 378340 on 2008-06-10 22:54:54

using LS on a portable device, i don't want to hard-code the paths of the apps, witch are also on that device. however, relitive paths do not seem to work correctly. for example, with
AnApp "..\this\will\not\execute\if\you\try.exe"

in evars.rc and
*Popup "An App" "$AnApp$"

in popup.rc, the app will show in the popup menu, with the correct icon, but will not execute when clicked. using xpopup 2.0.5 and the latest (non-beta) LS core. i have reported this as a bug here. thanks in advance for any help or suggestions.

Posted by member 1 on 2008-06-11 08:11:15 link

I think it has to do with the path being relative to a location you don't know. Try doing something like
AnApp ".."
and then
!msgbox $AnApp$
and see if you get a location different than the one you are thinking of.

Posted by member 378340 on 2008-06-11 18:28:06 link

!alert $AnApp$

with AnApp set as
AnApp ".."

returns an msgbox with "Litestep" as the caption, and
..

as the text. litestep does not autocomplete the directory.

for now, i'm thinking of just using a batch file that will run relitive files based on command-line auguments. hopfully i convince them to impliment it as LSDev though :)

Posted by member 1 on 2008-06-11 21:01:00 link

Try doing \ instead of .. and see if it likes that. You could also do $LiteStepDir$programs\anapp.exe

Posted by member 378340 on 2008-06-11 21:15:22 link

for now, i'm using a batch file
*Popup "$Browsername$" !execute ["Run.bat" "$Browser$"]

with one line in the batch file
%1

works, although it is not ideal. the cmd window pops up, and there is no icon.

as for doing \ instead of .., you'll have to explain what you mean. i don't quite understand.

and yes, i can do it relitive to the litestep dir, but my apps are elsewere, and i have other things pointing to them and would rather not change thier relitive location.

Posted by member 1 on 2008-06-11 21:36:50 link

AppName \path\to\executable.exe instead of ..\path\to\executable.exe

Posted by member 378340 on 2008-06-11 21:45:18 link

relitive to the litestep dir?
i want to go up one dir, to the root of the drive, then run an app from there. is there another way i can find the root of the drive that litestep is on?

Posted by member 1 on 2008-06-11 22:22:06 link

\ is the root folder. And have you tried $LiteStepDir$..\this\will\not\execute\if\you\try.exe?

Posted by member 378340 on 2008-06-11 23:46:17 link

i will try \ later, $Litestepdir$\..\this\will\not\execute\if\you\try.exe does not work.

Posted by member 378340 on 2008-06-12 18:29:13 link

\path\to\executable.exe does NOT work.

Posted by member 1 on 2008-06-12 19:40:41 link

Have you tried doing cmd /c ..\path\to\executable.exe instead of your run.bat?

Posted by member 378340 on 2008-06-12 20:00:43 link

/C Carries out the command specified by string and then terminates

that works fine at home, with administrator privileges. i will try it at school with much less :)

Posted by member 378340 on 2008-06-12 20:02:06 link

but the command window still remains open while the app is running, so it's not much help.

Posted by member 378340 on 2008-06-12 20:10:34 link

@echo off
Start "..." %1

seems to work, at least at home. will try at school.

Posted by member 1 on 2008-06-12 20:21:16 link

I can't remember...is there a fork command in windows? Like if you were to do it in Linux you would do something like "command &" and you would get sent back to the prompt and in this case it would close the window. And another weird note...when I run it from console it doesn't show the command window whereas if I do it from !Run it does. Weird!

Posted by member 378340 on 2008-06-12 20:26:20 link

eh, just m$ messing with your mind.
and i don't think there is a fork command with windows, maybe there is though...

Posted by member 1 on 2008-06-12 22:04:25 link

How about a startup script that does "cmd /c "cd $LiteStepDir$ && cd \ && cd > $LiteStepDir$root.rc"? Don't have LS on this machine so I can't test it..but it should work if you ran it from LS since you need the translation of $LiteStepDir$

Posted by member 378340 on 2008-06-13 18:53:17 link

wait, what would that do?
how do i do that?

what about parsing the $litestepdir$ variable to get the drive letter?
how can i do that?

Posted by member 1 on 2008-06-13 20:43:32 link

That will export the drive letter that LS was run from into a file called root.rc. Then you will need to parse it so you can use it.

You have to run the string I gave you from LiteStep. LiteStep is the only thing that understands what $litestepdir$ is and will parse it to whatever folder LS is in. So basically you will need to use mzscript to run it and parse it into an evar.

Posted by member 378340 on 2008-06-14 19:02:04 link

after an interesting conversation on irc, i came up with the following batch file:
@echo off
SET lsdir=%cd%
cd \
SET root=%cd%
cd %lsdir%
echo Lsd "%root%">drive.rc

it makes a file in the litestepdir (provided it is run from the litestep dir) called drive.rc that sets a variable (Lsd) to the drive letter of the drive LS is run off of.

thanks for your help!

i declare this issue solved. it would still be nice if they stuck .. functionality in the core though.

Posted by member 1 on 2008-06-14 21:52:30 link

Note...that only works if you put the bat file in your LS Directory. Put it anywhere else and you get whatever folder you ran it from.

Posted by member 378340 on 2008-06-14 23:18:09 link

yes.

Posted by member 212670 on 2008-06-15 23:43:29 link

Using xLabel/Stats? Try this in a command:
!ParseEvars !SetEvar lsd %[between('$LitestepDir$', 1, 3, index)]%

Then check the var...
!alert $lsd$

Posted by member 1 on 2008-06-16 10:58:47 link

Does LSLUA support a LEFT() function?

Posted by member 212670 on 2008-06-16 15:35:42 link

Yup, you could use string.sub(string, start, stop).

Posted by member 31 on 2008-06-21 09:29:12 link

AppPath "$LiteStepDir$..\Programs\App\app.exe"

works just fine...

http://www.lsdev.org/bugs/view.php?id=54

Posted by member 212670 on 2008-06-22 01:55:56 link

That looks too easy. I prefer more complicated solutions.

Posted by member 378340 on 2008-06-22 22:55:13 link

xcal:
your solution actually works better for finding the drive letter, since the ".." will go up only as many directories as you tell it to.

bolth usefull solutions, although i have implemented neither :)
still using the batch file, though i will change when i get around to it :)