Sign in to follow this  
Followers 0
bouzzi

Problem using #include

6 posts in this topic

We have built a little script that installs requested network printers with full configuration...

Have an autoIt able to create an autoIt file for each printer:

ex.: PRNT_LEX-T632-0100A.au3

Those files are use in an other autoIt for complete installation...

This AutoIt is the main program in witch I need to find a way to include those printer files...

ex.:

- - - - - - - - - - - - - - - - -

(...)

Dim $IprinterNDPS[2]

Dim $FicInf[2]

Dim $FicInfNmImp[2]

$i = 1

Pro = ProFicDat

$Dest = "Pro"

#include "PRNT_LEX-T632-0100A.au3"

#include "_Make1Dat.au3"

-+-+-+-+-+-+-+-+-

How could I replace "PRNT_LEX-T632-0100A" by a variable?

I have try a lot but did not find the way...

Can you help me..... ? PLZ


_______________________________________[font="Arial"] Bouzzi[/font]Bouzzi@yahoo.comLive From Quebec

Share this post


Link to post
Share on other sites



When an AutoIt script is run, one of the very first things is that the #include statements are replaced with the corresponding code. This is before AutoIt looks up any variables.....

What you might be able to do is put the #include inside an IF or SELECT CASE block. This has no benefit performance-wise, but it makes code organization better.

Select
Case $var = "one"
  #include <PRNT_LEX-T632-0100A.au3>
Case $var = "two"
  #include <ANOTHER.au3>
Case $var = "whatever"
  #include <And_so_on.au3>
End Select

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

How would that even be possible if the script were compiled?


Who else would I be?

Share this post


Link to post
Share on other sites

When an AutoIt script is run, one of the very first things is that the #include statements are replaced with the corresponding code.  This is before AutoIt looks up any variables.....

What you might be able to do is put the #include inside an IF or SELECT CASE block.  This has no benefit performance-wise, but it makes code organization better.

Select
Case $var = "one"
  #include <PRNT_LEX-T632-0100A.au3>
Case $var = "two"
  #include <ANOTHER.au3>
Case $var = "whatever"
  #include <And_so_on.au3>
End Select

<{POST_SNAPBACK}>

A line '#include' within a loop? :)

This could show an error, if the included file contains some loop too. :)

Share this post


Link to post
Share on other sites

How would that even be possible if the script were compiled?

<{POST_SNAPBACK}>

It wouldn't, obviously. There's no parsing engine in the compiler, so how would the variable be resolved?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

A line '#include' within a loop?  :)

This could show an error, if the included file contains some loop too.  :)

<{POST_SNAPBACK}>

Just make sure two files do not "include" each other ;)

I'd put #include-once at the top of each file just in case....

But you can #include the same file all you want, of course.

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
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
Sign in to follow this  
Followers 0