Sign in to follow this  
Followers 0
t0ddie

Filereadline

5 posts in this topic

i read the help file already, im a little bit rusty, i havent used autoit in awhile

heres my code, its not working. a little help?

FileReadLine,test1,bots.txt,1

FileReadLine,test2,bots.txt,2

FileReadLine,test3,bots.txt,3

msgbox,0,test,%test1%

theres my code.... i cant get the lines of text from bots.txt (on my desktop) into a variable. the script also runs on my desktop.

thanks in advance for your help


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I swapped to Autohotkey (as it is based on AutoIt 2, its syntax is identical for the FileReadLine command).

lc = 0
Loop
{
    lc ++
    FileReadLine, test, bots.txt, %lc%
    if ErrorLevel <> 0
  break
    MsgBox, 4, , Test #%lc% is "%test%", 3
    }

MsgBox, The end of the file has been reached or there was a problem.

Some code like this should work with A2

lc=0
maxlc=3

Msg:
IfGreater, lc, %maxlc%, Exit
EnvAdd, lc, 1
FileReadLine,test,bots.txt,%lc%
MsgBox,0,test,Test #%lc% is "%test%
Goto, Msg
Edited by Beastmaster

Share this post


Link to post
Share on other sites

i got an error, so i changed this...

lc=0

maxlc=3

to this...

setenv,lc,0

setenv,maxlc,3

(add the rest of your code here)

its doing the same thing it did before,when i first tried the command. its like the command just isnt working.

i get a series of message boxes, going from 1 to 4... saying test#1 is " test#2 is "

etc... etc... but the variable %test% does not show up in the box.

both the script and the file "bots.txt" are on my desktop.

im using the command with the proper syntax,and im not sure why its not working.

maybe i should bang my head on the computer.


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I've to appologize :D. To set variables without a leading SetEnv is an AutoHotkey option (regardless that SetEnv would have worked with AHK as well, cause it's backward compatible to A2).

I havn't expected (and don't have in mind) that it's necessary to set the path if script and input file are at the same dir level, but have a try and change this line (with AHK I use a build in variable "A_ScriptDir" if needed)

.
.
.
FileReadLine,test,%Userprofile%\Desktop\bots.txt,%lc%
.
.
.
Edited by Beastmaster

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i also must apologize. the reason the command did not work, was because the file was named bots.txt.txt

i recently reformatted, and i forgot that the extensions were hidden, so i wrote it in myself. lol

however...

there are 3 names in bots.txt. they are "one" on line 1 "two" for line 2 and "three" for line 3

a non script-ending error still occurs though

in this code....

setenv,lc,0

setenv,maxlc,3

Msg:

IfGreater, lc, %maxlc%, Exit

EnvAdd, lc, 1

FileReadLine,test,bots.txt,%lc%

MsgBox,0,test,Test #%lc% is "%test%

Goto, Msg

this code will make the last variable "three" appear on the third message box, and then a fourth message box comes up with the variable "three" in it again.

why does this fourth message box come up, when there are only three lines?

i havent looked at the script to figure it out for myself too much yet, but i did figure out why the FileReadLine command wasnt working for me.

oh, i just fixed it. i changed this...

setenv,maxlc,3

to this...

setenv,maxlc,2

thanks for the tips.

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0