Jump to content

FileInstall doesn't work in includes ?


Recommended Posts

Moin,

I have a problem with FileInstall.

In my include script I have a FileInstall call and if I compile just the include script all is righty right, but if I compile the main script I get an error message:

Invalid FileInstall() function:

post-20093-1211905030_thumb.jpg

I could call the FileInstall() in the main script but it's not a good/clean solution.

So, please, could somebody out there tell me a better solution ?

Thx.

Greetz

Greenhorn

Link to comment
Share on other sites

Moin,

I have a problem with FileInstall.

In my include script I have a FileInstall call and if I compile just the include script all is righty right, but if I compile the main script I get an error message:

Invalid FileInstall() function:

post-20093-1211905030_thumb.jpg

I could call the FileInstall() in the main script but it's not a good/clean solution.

So, please, could somebody out there tell me a better solution ?

Thx.

Greetz

Greenhorn

What's your data structure like? That is, what is the relationship between the folder location of your #include script and the file you're trying to package? Are you using the full file path for your FileInstall usage?

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

It is all in the same folder:

main.au3

include.au3

Au3Zipc.dll

The include.au3 has the FileInstall call.

Greetz

I don't think that you can do this with autoit. I think that when the program is compiled, the includes need to be with the rest of the program. It looks as though you are trying to create modules like a css in HTML or Java. I would put it all in one file and create function calls for different parts of the program. Am I understanding what you are doing?

RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!!

Link to comment
Share on other sites

  • Developers

It is all in the same folder:

main.au3

include.au3

Au3Zipc.dll

The include.au3 has the FileInstall call.

Greetz

Just tried this and works fine as far as I can tell. please show some code to replicate the issue.

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

Moin,

I have a problem with FileInstall.

In my include script I have a FileInstall call and if I compile just the include script all is righty right, but if I compile the main script I get an error message:

Invalid FileInstall() function:

I could call the FileInstall() in the main script but it's not a good/clean solution.

So, please, could somebody out there tell me a better solution ?

Thx.

Greetz

Greenhorn

Are the main script, include file, and "installed" file in different directories? Then a relative path that works from the include's directory might not be valid from the main script's directory.

For example:

I have a script at C:\Test\Script.au3:

#include <SubTest\Include.au3>

MsgBox(64, "Done", "Done")

The include file is at C:\Test\SubTest\Include.au3:

If FileInstall("MyInstalledFile.txt", @ScriptDir & "\MyTextFile.txt") Then
    MsgBox(64, "Success", "Successfully installed file.")
Else
    MsgBox(16, "Failure", "Failed to install file.")
EndIf

The text file to be installed is at C:\Test\SubTest\MyInstalledFile.txt (contents are irrelevant).

If I compile Include.au3, it finds the file MyInstalledFile.txt because it is located in the same directory with the include.

If I compile Script.au3 it fails because from that directory, the text file does not exist.

The fix is to fully path out your source file path. If I change that line in Include.au3 to the following, both files compile successfully:

If FileInstall("C:\Test\SubTest\MyInstalledFile.txt", @ScriptDir & "\MyTextFile.txt") Then[code=auto:0]

:)

Edit: Added demo.

Edited by PsaltyDS
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

OK, fourth try to edit the post ...

In the main.au3 the function DownloadAutoIt3(@ScriptDir & '\' & $szAppFolder, 1)

Func GetAppDir()
    
    Local $szDir, $iMsg
    
    ; IniRead AutoIt3pDir ...
    $szDir = IniRead($szAppIniFile, 'Settings', 'AutoIt3pDir', '')
    If $szDir Then
        If FileExists($szDir & '\AutoIt3.exe') Then Return $szAppDir
    EndIf
    
    ; Pfad zum Ordner der Startdatei suchen.
    $szDir = FolderSearch($szDrive, $szAppFolder)
    
    If Not $szDir Then
        
        $iMsg = MsgBox(266308, $szAppName, 'Es wurde kein Ordner "' & $szAppFolder & '" auf Laufwerk "' & $szDrive & '" gefunden.' & @TAB & @CRLF & @CRLF & _
                                           'Möchtest Du die erforderlichen Dateien aus dem Internet herunterladen ?' & @CRLF & @CRLF)
        If $iMsg = 6 Then
            $szDir = DownloadAutoIt3(@ScriptDir & '\' & $szAppFolder, 1)
            If Not $szDir Then
                SetError(1, 0, '')
            Else
                Return $szDir
            EndIf
        Else
            SetError(1, 0, '')
        EndIf
        
    Else
        Return $szDir
    EndIf
    
EndFuncoÝ÷ Øíè§r[y«·jëh×6Func DownloadAutoIt3($szDestDir, $bArchive)

    If $bArchive Then
        
        $sAutoItFile = 'autoit-v3-sfx.exe'
        $sSciTEFile  = 'SciTE4AutoIt3.zip'
        
    ElseIf Not $bArchive Or $bArchive = 0 Or $bArchive = Default Then
    
        $sAutoItFile = 'autoit-v3-setup.exe'
        $sSciTEFile  = 'SciTE4AutoIt3.exe'
    EndIf

    If Not FileExists($szDestDir) Then DirCreate($szDestDir)
    
    Local $hPluginDll, $szArchiveDir, $arDestDir, $szDirWGet, $szDirAutoIt, $szDirSciTE
    ; Au3Zip.dll entpacken.
    If Not FileExists($szDestDir & '\Au3Zipc.dll') Then FileInstall('Au3Zipc.dll', $szDestDir & '\Au3Zipc.dll')
    Sleep(500)
    $hPluginDll = PluginOpen('Au3Zipc.dll')
    
    $ProgressWnd = CreateProgressWindow()
    Sleep(1000)

    If Not FileExists($szDestDir & '\WGet\wget.exe') Then
        $szDirWGet = GetWGet($szDestDir, Default, Default, 1)
    Else
        $szDirWGet = $szDestDir & '\WGet'
    EndIf
        
    If Not FileExists($szDestDir & '\AutoIt3.exe') Then
        $szDirAutoIt = GetAutoIt3($szDestDir, $szDirWGet, Default, $sAutoItFile, 1)
        GetSciTE($szDirAutoIt, $szDirWGet, Default, $sSciTEFile, 1)
    Else
        If Not FileExists($szDestDir & '\SciTE\LUA\') Then
            GetSciTE($szDirAutoIt, $szDirWGet, Default, $sSciTEFile, 1)
        EndIf
    EndIf
    
    If Not FileExists($szDestDir & '\Extras\ResHacker\ResHacker.exe') Then
        GetResHacker($szDestDir & '\Extras\ResHacker', $szDirWGet, Default, 1)
    EndIf
    
    DirMove($szDirWGet, $szDestDir & '\Extras\WGet', 1)
    Sleep(2500)
;   GUIDelete($ProgressWnd[0][0])
    PluginClose($hPluginDll)
    Return $szDirAutoIt


EndFunc   ;==>DownloadPackage

I hope this try is better...

Greetz

Greenhorn

Edited by Greenhorn
Link to comment
Share on other sites

Sorry, problems with the editor ...

Just use code tags or codebox for longer stuff. The autoit tags are buggy and Jon doesn't have time to fix them and keep them up to date with current syntax.

:)

Anyway, this is the code that bombs:

If Not FileExists($szDestDir & '\Au3Zipc.dll') Then FileInstall('Au3Zipc.dll', $szDestDir & '\Au3Zipc.dll')

Likely Au3Zipc.dll is in the directory with the Include.au3, but would be a different path from where your main script is. You didn't bother to show the #include line from the main script, so we are still left guessing...

:)

Edited by PsaltyDS
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

Anyway, this is the code that bombs:

If Not FileExists($szDestDir & '\Au3Zipc.dll') Then FileInstall('Au3Zipc.dll', $szDestDir & '\Au3Zipc.dll')

Likely Au3Zipc.dll is in the directory with the Include.au3, but would be a different path from where your main script is. You didn't bother to show the #include line from the main script, so we are still left guessing...

:)

I tried it also without the if case = same result ! :)

And if I compile only the include.au3 all is ok, with If ... Then and without If ... Then

Edited by Greenhorn
Link to comment
Share on other sites

I tried it also without the if case = same result ! :)

And if I compile only the include.au3 all is ok, with If ... Then and without If ... Then

Did you read my previous posts after I edited them? The If/Then has nothing to do with the problem.

You still haven't shown what the #include line looks like and stated if the files are ALL in the same directory or not.

You also haven't said you tried giving the full path to the source file.

:)

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

Sorry,

OK, yes I tried it also with absolute path like: FileInstall('D:\AutoIt\Projekte\AutoIt potable\Au3Zipc.dll', $szDestDir & '\Au3Zipc.dll')

the include line in AutoIt3pEx.au3 ('main.au3'):

#Include 'GetAutoIt3p.au3'

GetAutoIt3p.au3 is the 'include.au3'

The project folder:

Posted Image

Greetz

Edited by Greenhorn
Link to comment
Share on other sites

Anyway, this is the code that bombs:

If Not FileExists($szDestDir & '\Au3Zipc.dll') Then FileInstall('Au3Zipc.dll', $szDestDir & '\Au3Zipc.dll')
Most likely the part that is failing is the value of $szDestDir.

I took a look to you code in post #7 and in function GetAppDir() you have the following line:

$szDir = DownloadAutoIt3(@ScriptDir & '\' & $szAppFolder, 1)
But you never assign any value to $szAppFolder
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Most likely the part that is failing is the value of $szDestDir.

I took a look to you code in post #7 and in function GetAppDir() you have the following line:

$szDir = DownloadAutoIt3(@ScriptDir & '\' & $szAppFolder, 1)
But you never assign any value to $szAppFolder
It looks like the main script, include file, and installed file are all in the same folder, so your theory looks better than mine right now. But he uses the $szAppFolder variable elsewhere before that call, including displaying it as the title and in the text of a MsgBox(). Seems like it would get noticed if it wasn't set.

:)

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

It looks like the main script, include file, and installed file are all in the same folder, so your theory looks better than mine right now. But he uses the $szAppFolder variable elsewhere before that call, including displaying it as the title and in the text of a MsgBox(). Seems like it would get noticed if it wasn't set.

:)

I'm sure if he is using SciTE it will get noticed if $szAppFolder wasn't set. The question will be what is the value of $szAppFolder? or if $szAppFolder path exists, if not he need to use DirCreate($szAppFolder) and then FileInstall().
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Moin,

Global $szAppFolder     = 'AutoIt3p'

The $szAppFolder is not existing at compiletime !

So, if the folder $szAppFolder is not existing on the drive, the main.au3 calls the function DownloadAutoIt3() in the include.au3.

In the function DownloadAutoIt3() the script shall check if the Au3Zipc.dll already exist in $szDestDir, in case of not the DLL should be extrated.

Greetz

Greenhorn

Edited by Greenhorn
Link to comment
Share on other sites

Moin,

Global $szAppFolder     = 'AutoIt3p'

The $szAppFolder is not existing at compiletime !

So, if the folder $szAppFolder is not existing on the drive, the main.au3 calls the function DownloadAutoIt3() in the include.au3.

In the function DownloadAutoIt3() the script shall check if the Au3Zipc.dll already exist in $szDestDir, in case of not the DLL should be extrated.

Greetz

Greenhorn

Think about compile-time and run-time separately:

That destination folder doesn't have to actually exist at compile time, which is when you were getting the error. At compile time it just needs to find the file that needs to be compressed and added to the script .exe file. This is why variables are not allowed in the FileInstall() source and full paths should be used for the source file location.

If it compiles correctly and then FileInstall() fails at run time, then you might have a problem with your destination path.

:)

Edited by PsaltyDS
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

If I compile the GetAutoIt3p.au3 - means the include.au3 - as a standalone EXE = No error -> no problem.

If I compile the AutoIt3pEx.au3 - means the main.au3 - including the GetAutoIt3p.au3 - means the include.au3 - the error occures like in my first post.

Greetz

p.s. Now my damaged spinal disk needs alittle break, I'll be back in round about 45 minutes, thanks to all of you !!!

Edited by Greenhorn
Link to comment
Share on other sites

If I compile the GetAutoIt3p.au3 - means the include.au3 - as a standalone EXE = No error -> no problem.

If I compile the AutoIt3pEx.au3 - means the main.au3 - including the GetAutoIt3p.au3 - means the include.au3 - the error occures like in my first post.

Greetz

p.s. Now my damaged spinal disk needs alittle break, I'll be back in round about 45 minutes, thanks to all of you !!!

This topic is getting long and confusing. Can you post a SHORT demo that will reproduce your symptoms? Similar to what I posted in post #6, but reproducing your issue. Like a main script in 10 lines or less, and the include file in 5 lines or less, with a simple one-line text file for the include. Then we can just put those three files in one folder and try it.

:)

Edited by PsaltyDS
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

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...