Jump to content
Sign in to follow this  
willwatters

Reading from file and storing as a variable

Recommended Posts

What is the code please to be able to read data from a file (in the format: name, password per line) and storing the name and password as two separate variables?

I'm planning on doing a loop to read the records (name and password) but how can i count the number of records so I can store it as a variable for the loop?

Thanks

Share this post


Link to post
Share on other sites

RTFM

In particular, check:

FileReadLine()

StringSplit()

StringStripWS()

A little example script:

$filename = ''

$h = FileOpen($Filename,0)
If $h <> -1 Then
   While 1
      $line = StringStripWS(FileReadLine($h),7)
      If @error Then
         FileClose($h)
         ExitLoop
      EndIf
      
      $line = StringSplit($line,',')
      
      If $line[0] >= 2 Then
         MsgBox(0,'','Name ' & $line[1] & @lf & 'Pass ' & $line[2])
      EndIf
      
   WEnd
EndIf
Edited by ezzetabi

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...