Jump to content
Sign in to follow this  
rich2323

filereadline sections into seperate variables

Recommended Posts

rich2323

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

Share this post


Link to post
Share on other sites
automagician

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.

Share this post


Link to post
Share on other sites
rich2323

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

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
rich2323

$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

:)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.