Jump to content

Recommended Posts

Posted

when im trying to open a file with fileopen("c:\test.txt",1), fileopen return de handle of the file ands the handle is 0 why?

and im not able to get the file size too. i think it maybe a computer issue! but to be sure!

thx in advance for responces! B)

bye bye dude!

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Posted

The return of 0 as I just tested it means the file isnt there.

Check to be sure you have the proper Path and Filename.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Posted

when i test it without the file there it return -1 this is the normal error code!

grrr... i juste tested it with another version of autoit and same thing! and on another computer same thing!

thx for the cue

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Posted

this is my code for the moment the script is in alpha version because im stuck with this file open probleme.

#include <string.au3>
#include <file.au3>
#Include <Array.au3>
#region opt and variable
;~ Opt("CaretCoordMode", 1)    ;1=absolute, 0=relative
;~ Opt("ExpandEnvStrings", 0)    ;0=don't expand, 1=do expand
;~ Opt("MouseClickDelay", 10)    ;10 milliseconds
;~ Opt("MouseClickDownDelay", 10) ;10 milliseconds
;~ Opt("MouseCoordMode", 1)    ;1=absolute, 0=relative
;~ Opt("MustDeclareVars", 0)      ;0=no, 1=require pre-declare
;~ Opt("PixelCoordMode", 1)    ;1=absolute, 0=relative
;~ Opt("RunErrorsFatal", 0)    ;1=fatal, 0=silent set @error
;~ Opt("SendAttachMode", 0)    ;0=don't attach, 1=do attach
;~ Opt("SendCapslockMode", 1)    ;1=store and restore, 0=don't
;~ Opt("SendKeyDelay", 8)        ;5 milliseconds
;~ Opt("SendKeyDownDelay", 1)    ;1 millisecond
;~ Opt("TrayIconDebug", 1)      ;0=no info, 1=debug line info
;~ Opt("TrayIconHide", 0)        ;0=show, 1=hide tray icon
;~ Opt("WinWaitDelay", 500)    ;250 milliseconds
;~ Opt("WinDetectHiddenText", 0)  ;0=don't detect, 1=do detect
;~ Opt("WinSearchChildren", 1)  ;0=no, 1=search children also
;~ Opt("WintitleMatchMode", 1)  ;1=start, 2=subStr, 3=exact, 4=...
#endregion
dim $_fsfileread
global $_fsfhandle
;Files List Array 1 = file ony 2 = dir only 0 = all
$_fspath = "c:"

$FileList=_FileListToArray($_fspath,1, "*")
If Not IsArray($FileList) and @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
$_x = $filelist[0]
;~;msgbox(0,"filelist", $filelist[0])
;~ _ArrayDisplay($FileList,"$FileList")

for $_forx = 1 to 4
    $_fsfilesize = FileGetSize($_fspath & "\" & $filelist[$_forx])
    msgbox(0,"Filesize",$_fsfilesize)
    msgbox(0,"debug","""" & $_fspath & "\" &  $filelist[$_forx]&"""")
    $_fsfhandle = fileopen($_fspath & "\" & $filelist[$_forx], 0)
    msgbox(0,"Fileopen",$_fsfhandle)
;$_debug = _FileReadToArray($_fspath & "\" & $filelist[$_forx],$_fsfileread)
    $_fsreadfile = fileread($_fspath & "\" & $filelist[$_forx],$_fsfilesize)
;$_foundposition = stringinstr($_fsreadfile,"eau")
    msgbox(0,"FileRead" , $_fsfileread)
;msgbox(0,"Found String", $filelist[$_forx] & " : " & $_foundposition)
    fileclose($_fsfhandle)
Next

the code may not work correctely with the function _filelisttoarray because i modified the original fonction to make it work better for me!

i put the code only for you can view. then im debuging each line!

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Posted

0 is a valid handle... it means success. now you can fileread..() or filewrite..()

Lar.

lmao Oh... hehe. I guess I have a test.txt on my C drive :-P. I should have checked on that.

Well... I hope this solves your problem Greenseed.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Posted

fileopen with option 1 creates the file.

Lar

Oh boy! I am really really rusty at this.

Been a while for me. I have been away from the development world too long.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Posted

0 is a valid handle... it means success. now you can fileread..() or filewrite..()

Lar.

Perhaps it ws not a great idea to use 0 as a legal handle ... B)
Posted

when i do fileread(handle of file, filesize) it return nothing no error code! juste like the file was empty!

and when i try with the file name insted the file handle same thing! i can't not make autoit work correctely. i will flush all my dir and restart new installation of autoit! but thx everyone for the help!

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

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
  • Recently Browsing   0 members

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