Sign in to follow this  
Followers 0
andygo

Fileinstall don't work

15 posts in this topic

hello,

this is part of a script:

_inst("a2.jpg", @TempDir & "\")

Func _inst($checkfile, $checkdir)
    FileInstall("dummy", $checkdir & $checkfile, 1)
    ;MsgBox(64,"info", $checkdir & $checkfile & @CRLF & FileReadLine ( $checkdir & $checkfile, 1))
    if FileReadLine ( $checkdir & $checkfile, 1) = "dummy" then
        FileInstall($checkfile, $checkdir & $checkfile, 1)
    else
        MsgBox(16,"Fehler", $checkdir & $checkfile & @CRLF & "konnte nicht erstellt werden!")
    endif
Endfunc

in SciTE Editor, the Syntax-Check says everything is ok, and i can run the script from there,

all is fine, function works. but when i try to compile, the aut-2-exe says:

Posted Image

what is wrong, why cant compile?

Share this post


Link to post
Share on other sites



Using FileInstall means on compile time a file must be included in the script executable. You are trying to include file "dummy", which apparently does not exist.

You probably meant to type something like:

FileInstall($checkfile, $checkdir & $checkfile, 1)

Share this post


Link to post
Share on other sites

all the files i compile with the script exists. if i install them this way:

FileInstall("a2.jpg", @TempDir & "\a2.jpg", 1)
FileInstall("a2.jpg", @TempDir & "\a2.jpg", 1)
FileInstall("av.jpg", @TempDir & "\av.jpg", 1)
FileInstall("s07.jpg", @TempDir & "\s07.jpg", 1)
FileInstall("i82.jpg", @TempDir & "\i82.jpg", 1)
FileInstall("i_view32.exe", @TempDir & "\" & $precfg0 & "\" & $precfg0 & "i_view32.exe", 1)
FileInstall("i_view32.ini", @TempDir & "\" & $precfg0 & "\i_view32.ini", 1)
FileInstall("dummy", @TempDir & "\" & $precfg0 & "\_curlrc", 1);
FileInstall("curl.exe", @TempDir & "\" & $precfg0 & "\" & $precfg0 & "curl.exe", 1);
FileInstall("libeay32.dll", @TempDir & "\" & $precfg0 & "\libeay32.dll", 1);
FileInstall("libssl32.dll", @TempDir & "\" & $precfg0 & "\libssl32.dll", 1);
FileInstall("list.w", @TempDir & "\" & $precfg0 & "\list.w", 1)
FileInstall("date.w", @TempDir & "\" & $precfg0 & "\date.w", 1)
FileInstall("both.w", @TempDir & "\" & $precfg0 & "\both.w", 1)
;FileInstall("list-s.w", @TempDir & "\" & $precfg0 & "\list-s.w", 1)
;FileInstall("date-s.w", @TempDir & "\" & $precfg0 & "\date-s.w", 1)
;FileInstall("both-s.w", @TempDir & "\" & $precfg0 & "\both-s.w", 1)
FileInstall("watermark.license", @TempDir & "\" & $precfg0 & "\watermark.license", 1)
FileInstall("watermark.exe", @TempDir & "\" & $precfg0 & "\" & $precfg0 & "watermark.exe", 1)
FileInstall("watermark.ini", @TempDir & "\" & $precfg0 & "\watermark.ini", 1)
FileInstall("auto.htm", @TempDir & "\" & $precfg0 & "\auto.htm", 1);
FileInstall("streamlite.htm", @TempDir & "\streamlite.htm", 1)
DirCreate(@TempDir & "\" & $precfg0 & "\fgo");
;FileInstall("dummy", @TempDir & "\" & $precfg0 & "\fgo\_curlrc", 1);
FileInstall("curl.exe", @TempDir & "\" & $precfg0 & "\fgo\" & $precfg0 & "1curl.exe", 1);
FileInstall("libeay32.dll", @TempDir & "\" & $precfg0 & "\fgo\libeay32.dll", 1);
FileInstall("libssl32.dll", @TempDir & "\" & $precfg0 & "\fgo\libssl32.dll", 1) ;

compiling works. i just get the error if i try to compile like my first post here

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

THIS LINE IS WRONG. YOU ARE TRYING TO INCLUDE A FILE THAT DOES NOT EXIST. THE FILE IS NAMED DUMMY:
FileInstall("dummy", $checkdir & $checkfile, 1)
Edited by Manadar

Share this post


Link to post
Share on other sites

THIS LINE IS WRONG. YOU ARE TRYING TO INCLUDE A FILE THAT DOES NOT EXIST. THE FILE IS NAMED DUMMY:

FileInstall("dummy", $checkdir & $checkfile, 1)

sorry manadar, but you are wrong.

if i point to a non-existing file, then this error is shown:

Func _inst($checkfile, $checkdir)
    FileInstall("i-am-not-here.txt", $checkdir & $checkfile, 1)
    ;MsgBox(64,"info", $checkdir & $checkfile & @CRLF & FileReadLine ( $checkdir & $checkfile, 1))
    if FileReadLine ( $checkdir & $checkfile, 1) = "dummy" then
        FileInstall($checkfile, $checkdir & $checkfile, 1)
    else
        MsgBox(16,"Fehler", $checkdir & $checkfile & @CRLF & "konnte nicht erstellt werden!")
    endif
Endfunc

Posted Image

Share this post


Link to post
Share on other sites

andygo,

As Manadar has, understandably, decided to leave this topic, let us see if a different voice can get through.

Manadar has already told you that you are getting the error because you are trying to FileInstall a non-existent file. In the snippet you included in your first post this file was called "dummy".

You are getting the error when you compile, and not when you run from SciTE, because of the different way FileInstall is handled in these 2 cases. From the Help file for FileInstall:

When this function is used from a non-compiled script, a copy operation is performed instead (to allow for easy testing pre-compilation)

Trying to copy a non-existent file does not worry Autoit - it just carries on. But trying to include a non-existent file in a compiled .exe obviously causes an error.

Two options:

1. Check if the file exists BEFORE using FileInstall (use FileExists) and do not try to include it if it is not there.

2. Adjust your code so that it does not try to include non-existent files. :)

I hope that this alternative explanation helps.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@melba & @manadar:

i understand you both. please try this mini-script yourself,

then you will see the error.

just create an empty file "test1.txt" and another file "dummy.txt" with

the word "dummy" as its first line.

_inst("test1.txt", @TempDir & "\")
Func _inst($checkfile, $checkdir)
    FileInstall("dummy.txt", $checkdir & $checkfile, 1)
    ;MsgBox(64,"info", $checkdir & $checkfile & @CRLF & FileReadLine ( $checkdir & $checkfile, 1))
    if FileReadLine ( $checkdir & $checkfile, 1) = "dummy" then
        FileInstall($checkfile, $checkdir & $checkfile, 1)
        MsgBox(64,"Info", $checkdir & $checkfile & @CRLF & "is ok.")
    else
        MsgBox(16,"error", $checkdir & $checkfile & @CRLF & "failed!")
    endif
Endfunc

Share this post


Link to post
Share on other sites

Yep, you're brilliant and we're all wrong. I think I'll be out now.

Oh, also:

FileInstall parameter 1 description: The source path of the file to compile. This must be a literal string; it cannot be a variable. It can be a relative path (using .\ or ..\ in the path).

So this is wrong too:

FileInstall($checkfile, $checkdir & $checkfile, 1)

Share this post


Link to post
Share on other sites

FileInstall($checkfile, $checkdir & $checkfile, 1)

From the Help file on FileInstall

Remarks

The FileInstall function is designed to include files into a compiled AutoIt script. These included files can then be "extracted" during execution of the compiled script if the statement is executed. Keep in mind that files such as images can greatly increase the size of a compiled script.

The source file must be a string and not a variable so that the compiler can extract the filename to include. The source cannot contain wildcards.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

hello again,

i think i found a way to check, accessing, reading out an existing file:

if _predel(@TempDir & "\a.jpg") = 1 then FileInstall("a.jpg", @TempDir & "\a.jpg", 1)

func _predel($predel)
    FileInstall("dummy.txt", $predel, 1)
    if FileReadLine ( $predel, 1) = "dummy" then
        FileSetAttrib($predel, "-R", 1)
        FileDelete ( $predel )
        Return 1
    Else
        MsgBox(16, "Fehler", "Zugriffsfehler! Bitte manuell löschen:" & @CRLF & @CRLF & $predel & @CRLF & @CRLF & "Tool anschliessend neu starten.")
        exit
    endif
EndFunc

thank you for the time :)

Edited by andygo

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

The first parameter of FileInstall is NOT EVALUATED on compile time. In fact, nothing is evaluated on compile time.

If False Then
   FileInstall("dummy.txt", "dummy.txt", 1)\
EndIf

On compile time it WILL include dummy.txt

Edited by Manadar

Share this post


Link to post
Share on other sites

The first parameter of FileInstall is NOT EVALUATED on compile time.

If False Then
   FileInstall("dummy.txt", "dummy.txt", 1)\
EndIf

On compile time it WILL include dummy.txt

yes, in this case i want to include the dummy.txt.

reason: it contains only one line with the word "dummy"

and if the fileread also contains "dummy" i know that accessing works.

Share this post


Link to post
Share on other sites

Ok, whatever, I just wondered why you were bumping your own topic after your question had been answered.

that wasnt my intention, sry. you can change topic title to "Solved" and close it.

p.s. xcuse my poor english, i'm livin in germany

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