Jump to content

Minor Problem Help Please


Recommended Posts

$file = FileOpen("C:\Users\Brian\Documents\hamster.txt", 4) ;4 is so it reads from directory

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf


While 1
    $chars = FileRead($file, 1)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Char read:", $chars)
    
Wend



FileClose($file)

When it opens my text, it reads each letter as hex. So instead of it displaying "Hamsters are cute" it displays the hex of it. How do I make it read the letters instead. And can I make it so that if I put a autoit code in that text, then it executes that autoit code?

Link to comment
Share on other sites

Why are you using filemode 4 in the FileOpen()? (4 = Read raw mode)

Oh, I tried very hard to avoid using 4 because when I do:

$file = FileOpen("Hamster.txt", 0) 

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf


While 1
    $chars = FileRead($file, 1)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Char read:", $chars)
    
Wend



FileClose($file)

It can't find my file D=. I guess its cause it doesn't know which directory to look for it in idk. Its my first time using fileopen =p

Edited by BlazerV60
Link to comment
Share on other sites

if the path is like it is in your second example, it checks the current directory, then it checks the PATH environment variable

if the path starts with a drive, it is total absolute and looks only there

if the path starts with "/" it is mostly absolute and looks only on the current drive

if the path starts with "./" it is relative and only looks in that directory

if the path starts with "../" it starts in the parent directory

just copy the path from the first example to the second example and it'll work just fine

Link to comment
Share on other sites

if the path is like it is in your second example, it checks the current directory, then it checks the PATH environment variable

if the path starts with a drive, it is total absolute and looks only there

if the path starts with "/" it is mostly absolute and looks only on the current drive

if the path starts with "./" it is relative and only looks in that directory

if the path starts with "../" it starts in the parent directory

just copy the path from the first example to the second example and it'll work just fine

Ohhh it worked, thanks you guys. And it is it possible for me to use fileopen to open a gui made by autoit. Cause when I make it open my gui program, it just shows me a box with the gui code in it instead of the gui itself.

Edited by BlazerV60
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...