Sign in to follow this  
Followers 0
Mayo

Help with Edit Box II

3 posts in this topic

Okay, well I got this script which loads the text from whatever file the user opens into a edit box. The problem is, once the user opens another file, it just loads the text from that file over the previous text. I'm trying to make it to where when he opens another file, it completely clears all the text that is in the edit box and then loads the text from the file.

$file = FileOpenDialog( "Select a script to load.", @ScriptDir & "\scripts", "Bot Scripts (*.bot)", 1)
$file = StringReplace($file, "|", @CRLF)
$file = FileOpen($file, 0)
If $file = -1 Then
ElseIf $file = 1 Then
While 1
    $chars = FileRead($file, 1)
    If @error = -1 Then ExitLoop
GuiCtrlSetData($edit1, $chars, -1)
Wend

FileClose($file)
EndIf

I've been reading the help file for a long time, I've tried

GuiCtrlSetData($edit1, $chars)[code=auto:0] without the "-1" and all it does it put a "[]" type of symbol into the box...

Thanks.

Share this post


Link to post
Share on other sites



Lol, 30 seconds after I posted this I figured it out... If anyone else has trouble with this ever, heres the solution:

Func ScriptOpener1()
$file = FileOpenDialog( "Select a script to load.", @ScriptDir & "\scripts", "Bot Scripts (*.bot)", 1)
$file = StringReplace($file, "|", @CRLF)
$file = FileOpen($file, 0)
If $file = -1 Then
ElseIf $file = 1 Then
While 1
    $chars = FileRead($file)
    If @error = -1 Then ExitLoop
GuiCtrlSetData($edit1, $chars)
Wend

FileClose($file)
EndIf
EndFunc

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Okay, well I got this script which loads the text from whatever file the user opens into a edit box. The problem is, once the user opens another file, it just loads the text from that file over the previous text. I'm trying to make it to where when he opens another file, it completely clears all the text that is in the edit box and then loads the text from the file.

$file = FileOpenDialog( "Select a script to load.", @ScriptDir & "\scripts", "Bot Scripts (*.bot)", 1)
$file = StringReplace($file, "|", @CRLF)
$file = FileOpen($file, 0)
If $file = -1 Then
ElseIf $file = 1 Then
While 1
    $chars = FileRead($file, 1)
    If @error = -1 Then ExitLoop
GuiCtrlSetData($edit1, $chars, -1)
Wend

FileClose($file)
EndIf

I've been reading the help file for a long time, I've tried

GuiCtrlSetData($edit1, $chars)
without the "-1" and all it does it put a "[]" type of symbol into the box...

Thanks.

Why do you have that While loop in there?

Also I wouldn't worry about using the FileOpen with a FileRead() unless it's a large file

$file = FileOpenDialog( "Select a script to load.", @ScriptDir & "\scripts", "Bot Scripts (*.bot)", 1)
$Chars = StringReplace(FileRead($File), '|', @CRLF)
GuiCtrlSetData($edit1, $chars)
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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