Jump to content

Recommended Posts

Posted (edited)

I am tring to get a filereadline into seperate variables for each "section"

Here is my script:

;****************************************

RunWait(@ComSpec & " /c " & "ndir I: /spa > C:\space.txt","C:\",@SW_HIDE)

$file = FileOpen("C:\space.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

$line = FileReadLine(($file),13)

;****************************************

The $line has a value of =

USERS\Rich (there are many spaces here) 467,136 (SPACES here) 466,352 (MORE SPACES) 784,352 (SPACES) 784

I would like to put each section into a variable. Each of these fields can change. What would be the easiest way to get each field into a variable.

The only thing seperating each field is spaces.

Any suggestions? :)

Rich2323

Edited by rich2323
Posted (edited)

I am not quite sure what you mean by "sections", if you mean commas or spaces?! but either way it sounds like you should look at the StringSplit() function.

<{POST_SNAPBACK}>

Yes, I do mean each section seperated by the spaces. When I looked at the StringSplit command, it puts each SPACE in as part of the Array, can I get rid of that? Otherwise these number could change and so could the array they are in. Edited by rich2323
Posted

$rec = "USERS\Rich        467,136    466,352    784,352    784" 
$rec = StringStripWS($rec, 4)
$SEC = StringSplit($rec, " ")

<{POST_SNAPBACK}>

That worked, thank you very much!!!

Rich2323

:)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...