blademonkey Posted January 15, 2008 Share Posted January 15, 2008 I have a script that is including another au3 file. in the include file there's a piece of code that uses @scriptdir path which, when included into another script, ends up not being the intended path. for instance, let's say we have : \\server1\share\File1.au3 \\server2\share\file2.au3 we're including file1.au3 in file2.au3 so file2 will look like this #include "\\server1\share\File1.au3" [...] and file1 looks like this: $sFilename = @scriptdir & '\' & stringtrimright(@scriptname,3) & '.ini') $sSection = "user1" $sKey = "password" $sPWD = iniread($sFilename, $sSection, $sKey,"") When i compile file2, the path for @scriptdir is \\server2\share\ but i want to reference \\server1\share\ (so that i dont have to copy the file to every program folder that i have). any recommendation would be appreciated. thanks. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
herewasplato Posted January 16, 2008 Share Posted January 16, 2008 I do not know what the best solution to that would be, but I see that some smart folk are on the forum atm - so maybe this will be a timely bump. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2008 Developers Share Posted January 16, 2008 (edited) mmm could be me not thinking strait but i don't understand it .... I would think that this should work since you hardcode server1 anyways: File2.au3$ServerPath = "\\server1\share" #include "\\server1\share\File1.au3" File1.au3 $sFilename = $ServerPath & '\' & stringtrimright(@scriptname,3) & '.ini') $sSection = "user1" $sKey = "password" $sPWD = iniread($sFilename, $sSection, $sKey,"") Edited January 16, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
blademonkey Posted January 16, 2008 Author Share Posted January 16, 2008 mmm could be me not thinking strait but i don't understand it .... I would think that this should work since you hardcode server1 anyways: File2.au3$ServerPath = "\\server1\share" #include "\\server1\share\File1.au3" File1.au3 $sFilename = $ServerPath & '\' & stringtrimright(@scriptname,3) & '.ini') $sSection = "user1" $sKey = "password" $sPWD = iniread($sFilename, $sSection, $sKey,"") Well I'm not sure what you mean to do by adding the server path. What I'm saying is that at compile time, the @scriptdir will point to the path for file2 (because i'm including the file1 code inside it) and not file1. What I would like to do is to reference, in some variable way (so i do not have to hardcode the location everytime), the path of for file1, again without hardcoding. not possible? ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 16, 2008 Share Posted January 16, 2008 When i compile file2, the path for @scriptdir is \\server2\share\ ...You are broken already with that assumption.<Insert favorite wise crack about assumptions here.>The value of a macro like @ScriptDir IS NOT interpreted at all at compile time! The script is not being run while it is being "compiled", so no value is being substituted for the text "@ScriptDir". The text file is being parsed into something else that you wouldn't recognize if you could see it.I think the best you'll get is some kind of "PreProcessor" to dynamically update the text of a static Global variable assignment just before you compile. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2008 Developers Share Posted January 16, 2008 Still don't understand why my provided solution wouldn't work .... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
blademonkey Posted January 16, 2008 Author Share Posted January 16, 2008 Alright, thanks for the correction on the assumption and pointing me in the right direction. From looking at that thread it seems more complicated to code a solution than hardoding the path manually. So i will deal. Thanks. -Blademonkey ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
blademonkey Posted January 16, 2008 Author Share Posted January 16, 2008 Still don't understand why my provided solution wouldn't work .... I was trying to get away from hardcoding a path in the include file, as that path is subject to change. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
Bert Posted January 17, 2008 Share Posted January 17, 2008 you could use a ini as a director as a workaround The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now