Sign in to follow this  
Followers 0
Eviltim

simplify?

4 posts in this topic

I was looking for a way to get a certain part of a line from a text file.

i tried using StringTrimLeft and Right but when the result is put in the message box, it shows nothing at all.

i think it has something to do with certain null charatcers.

i cant just alter the text file becuase it generated from another program.

the outputs of this generated file can be more or less than just the first 7 lines

So i came up with a way to read just the first few letters of the line and not the rest of the characters.

is there any way to simplify all of this?

dim $var, $a, $b, $c, $d, $e, $f, $g

$a = FileReadLine("list.txt", 2)
$b = FileReadLine("list.txt", 3)
$c = FileReadLine("list.txt", 4)
$d = FileReadLine("list.txt", 5)
$e = FileReadLine("list.txt", 6)
$f = FileReadLine("list.txt", 7)
$g = FileReadLine("list.txt", 8)
$a = StringLeft($a, 10)
$b = StringLeft($b, 10)
$c = StringLeft($c, 10)
$d = StringLeft($d, 10)
$e = StringLeft($e, 10)
$f = StringLeft($f, 10)
$g = StringLeft($g, 10)
$a = StringStripWS($a, 8)
$b = StringStripWS($b, 8)
$c = StringStripWS($c, 8)
$d = StringStripWS($d, 8)
$e = StringStripWS($e, 8)
$f = StringStripWS($f, 8)
$g = StringStripWS($g, 8)
MsgBox(64, "The Output:" , $a & $b & $c & $d & $e & $f & $g)

Share this post


Link to post
Share on other sites



local $temp, $i
local $output = ""

for $i = 2 to 8
    $temp = fileReadLine("list.txt", $i)
    $temp = stringLeft($temp, 10)
    $temp = stringStripWS($temp, 8)
    $output = $output & $temp
next

msgBox(0x40, "The output" , $output)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This is the file. Its a .sol file genrated from a flash file.

I had to break it down to 10 characters each just so the info will start on the next line without all of the null characters in front of it.

Posted Image

local $temp, $i
local $output = ""

for $i = 2 to 8
    $temp = fileReadLine("list.txt", $i)
    $temp = stringLeft($temp, 10)
    $temp = stringStripWS($temp, 8)
    $output = $output & $temp
next

msgBox(0x40, "The output" , $output)

<{POST_SNAPBACK}>

I will try this out and see how it goes. Thanks LxP

EDIT: Yep, that will definetly work, thanks again!

Edited by Eviltim

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