Sign in to follow this  
Followers 0
xonepc

Help. read the text file and search word.

7 posts in this topic

hi.

Ready to record.txt file

record.txt

----------

no1 -> Unique value

aaaa -> Unique value

no2

bsha

no3

rthf

no4

fh5f

no5

vfgt

no6

bted

no7

fdfg

no8

4dsf

no9

4gd3

.....

--------

$code_no = InputBox("Search for code_no","Enter Code",""," M","150","150","-1","-1")

Question?

return code_no

Share this post


Link to post
Share on other sites



You would use

$Read = FileRead("record.txt")
If StringInStr($Read, "Search String") Then
MsgBox(0, "Results", "The string is in the file.")
Else
MsgBox(0, "Results", "The string isn't in the file.")
EndIf

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

example)

want a input code : aaaa

-> return code_no : no1

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What you can do is use FileReadLine and store your data pair into a couple variables. When the second value is the same string as the input, you return the first value.

But if you're not using a whole lot of data pairs, you're better off just using an .ini file for this. Use any section name you want, then use the input code as your key and the return code as your key value.

Edited by omikron48

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

oh.. i see..

change record.txt

record.txt

code_no=code_value

---------------

no1=aaaa

no2=fw4t

no3=445f

no4=5g46

.............

input code_value -> get code_no

i want a code_no..

ps) data sizes are small..

Edited by xonepc

Share this post


Link to post
Share on other sites

It's:

record.txt

-----

[section name]

aaaa=no1

fw4t=no2

445f=no3

5g46=no4

You use: IniRead("record.txt", "section name", $key, "default") ;"default" is value returned when key isn't found.

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