Jump to content

Simple way to add remaining file to a variable.


Recommended Posts

Can someone help me with this code, I have assigned the first 8 line items to variables and the remaining lines 9 thru 40 are one block of code to be handled as one variable...

It does not work as is. index 0 is showing 40, so I assume I can use 9 to 40 in a loop to put them all into the variable main... but its not working.. I also tried 9 to 39 just in case its -1 for the total but that did not work either.

The array has a total of 40 line items.

Dim $x
_FileReadToArray("urls\1039498.htm", $x)
$id    = $x[1] ; 1110200.htm
$stre  = $x[2] ; 1134 Ransom Road
$addr  = $x[3] ; Norfolk, Va 23518
$price = $x[4] ; 349000
$beds  = $x[5] ; 5
$desc  = $x[6] ; Lovely 2 Br Home
$city  = $x[7] ; Norfolk
$state = $x[8] ; VA

for $i = 9 to 39
    $main = $main & $x[$i]
Next

msgbox(0,"",$main)
Link to comment
Share on other sites

but its not working

And what is the error?. Because below code is working for me:

#include <file.au3>
Global $main,$x
_FileReadToArray("urls\1039498.htm", $x)
If Not IsArray($x) Then
    MsgBox(0,"","Ops, $x is not an array")
    Exit
EndIf
$id    = $x[1] ; 1110200.htm
$stre  = $x[2] ; 1134 Ransom Road
$addr  = $x[3] ; Norfolk, Va 23518
$price = $x[4] ; 349000
$beds  = $x[5] ; 5
$desc  = $x[6] ; Lovely 2 Br Home
$city  = $x[7] ; Norfolk
$state = $x[8] ; VA

for $i = 9 to $x[0]
    $main &= $x[$i]
Next

msgbox(0,"",$main)
Link to comment
Share on other sites

Thanks.. works well for me now also..

Can't figure out what I may have been doing wrong.. but all is well now..

The top variable were fine, but the looping variables did not show up in the Msgbox at the end.

Fine now... thanks again..

Link to comment
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
 Share

  • Recently Browsing   0 members

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