Jump to content

Is 'reload' possible in AutoIt?


Recommended Posts

Looking at opportunities to port an existing test framework over to AutoIt from WinRunner.

I noticed that several WR scripts used a reload statement to load constants into memory.

I have not seen anything like this in the forum, and the following experiment failed:

test.au3

#include <File.au3>

Func CallScript( $path )
    Local $script
    _FileReadToArray( $path, $script )
    
    If IsArray( $script ) = 0 then 
        ConsoleWrite( "Not an array" & @CRLF)
        return false
    EndIf
    
    For $i = 1 to $script[0]
        Execute( $script[$i] )  
    Next    
EndFunc

CallScript( "readme.au3" )

; IsDeclared returns 0.
ConsoleWrite( IsDeclared( "$a" ) & @CRLF)

readme.au3

$a = "Hello World"

Maybe this is not possible and declaring the constants in an include would not be a horrible work-around.

If I was dead set, I guess I could parse the called script, split the lines and pass the elements to Assign().

But smarter people than I lurk here; any more elegant suggestions?

Edited by zfisherdrums
Link to comment
Share on other sites

Looking at opportunities to port an existing test framework over to AutoIt from WinRunner.

I noticed that several WR scripts used a reload statement to load constants into memory.

I have not seen anything like this in the forum, and the following experiment failed:

Maybe this is not possible and declaring the constants in an include would not be a horrible work-around.

If I was dead set, I guess I could parse the called script, split the lines and pass the elements to Assign().

But smarter people than I lurk here; any more elegant suggestions?

Loading constants into memory is not the same thing as assigning them to variables. More likely they are stored in an array or even some kind of database object.

What about #include<> is "a horrible work-around"? Ever heard of GuiConstants.au3? Seems to work very well! :rolleyes:

Anyway, if there is some reason you can't use an array or #include, you might take a look at a scripting.dictionary instead of variables.

I would just go with an #include, but that's me...

:rambo:

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

PsaltyDS,

Thanks for the quick reply!

More likely they are stored in an array or even some kind of database object.

You're right, they were using a database object.

What about #include<> is "a horrible work-around"? Ever heard of GuiConstants.au3? Seems to work very well! :rolleyes:

I believe I said it would NOT be a horrible work around. And yes, I have heard of GUIconstants.au3.

Anyway, if there is some reason you can't use an array or #include, you might take a look at a scripting.dictionary instead of variables.

I really like your idea and implementation here. I'll give it a spin. Thanks again.
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...