Jump to content

#include Question


Recommended Posts

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

  • Developers

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,"")

:D

Edited 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

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,"")

:D

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

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.

:D

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...