Sign in to follow this  
Followers 0
Overlord

increase array number

16 posts in this topic

Hi, I want to know if it's possible to increase a arra by number manually?

I looked through the helpfile and although _ArrayAdd comes close it's not really what I need...

#include <IE.au3>
#include <Array.au3>
Global $sURL1 = "http://apps.facebook.com/inthemafia/remote/html_server.php?xw_controller=recruit&xw_action=view"
$oIE = _IECreate($sURL1); opens the MY mafia page
$sHTML = _IEBodyReadHTML($oIE);  reads all the text on MY MAFIA
$output = StringSplit($sHTML, 'fb_protected="true"', 1); split after 
;ConsoleWrite($output[2] & @LF)
$output2 = StringTrimLeft($output[2], 7)
;ConsoleWrite($output2 & @LF)
$uninvited = StringLeft($output2, StringInStr($output2, "</SPAN></LABEL><LABEL class") - 1); split before 
ConsoleWrite($uninvited & @LF); write output to console. this should be only the names

I know that output[2] gives me the first name but how can I increase that number so I can read $output[3]?

how can I make a loop for this?

Share this post


Link to post
Share on other sites



not sure what your asking:

Do you mean to redifine the array to add to the dimension?

That would be Redim

or do you mean to loop through what is already in the array?

ie:

For $i = 0 to ubound($array)-1

msgbox(0,'',$array[$i])

next

Share this post


Link to post
Share on other sites

and I'm absolutely not understandign the helpfile for that ;-(

Share this post


Link to post
Share on other sites

and I'm absolutely not understandign the helpfile for that ;-(

Maybe take a bit more time and try something for a change before trowing the towel?

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

Share this post


Link to post
Share on other sites

Maybe take a bit more time and try something for a change before trowing the towel?

sorry Jos but I'm already trying 2 days constantly...I've read the helpfile for every thing I needed, even for stringsplit.

But atm, I'm getting a bit down for not finding my solution and keep bumping into a wall here...

if you look at my other post you will see that I tried it in several ways.

http://www.autoitscript.com/forum/index.php?showtopic=91783

and none work like it should. All the rest from my script works. I just need this part updated

Share this post


Link to post
Share on other sites

sorry Jos but I'm already trying 2 days constantly...I've read the helpfile for every thing I needed, even for stringsplit.

But atm, I'm getting a bit down for not finding my solution and keep bumping into a wall here...

if you look at my other post you will see that I tried it in several ways.

http://www.autoitscript.com/forum/index.php?showtopic=91783

and none work like it should. All the rest from my script works. I just need this part updated

Not sure I understand now. Your simple question in this thread was: "How to increase the Array size"

Answer is : Use Redim.

So what is your problem using redim?


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

Share this post


Link to post
Share on other sites

I don't understand the helpfile for ReDim...

I don't know how to implement it into my script....

Share this post


Link to post
Share on other sites

I don't understand the helpfile for ReDim...

I don't know how to implement it into my script....

Then start with taking the time to understand the helpfile examples because when you don't understand that, there is no way you can start applying it to your own scripts.

Open the example, run it and try understanding it.

Then come back with questions about what you don't understand.

Jos


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

Share this post


Link to post
Share on other sites

With ReDim you can resize the array without losing the data inside.

For example, this is my initial array:

Dim $array[3]

[0] Hal

[1] Eric

[2] Guy

When I Redim it, all initial values will remain intact, but I can add new ones later if I want now:

ReDim $array[5]

[0] Hal

[1] Eric

[2] Guy

[3] -EMPTY-

[4] -EMPTY-

Do you understand now?

Share this post


Link to post
Share on other sites

This is the statement that confuses me:

I know that output[2] gives me the first name but how can I increase that number so I can read $output[3]?

That sounds like simply needing to use a for loop to step through rather that redefine.

Can you clarify?

Share this post


Link to post
Share on other sites

With ReDim you can resize the array without losing the data inside.

For example, this is my initial array:

Dim $array[3]

[0] Hal

[1] Eric

[2] Guy

When I Redim it, all initial values will remain intact, but I can add new ones later if I want now:

ReDim $array[5]

[0] Hal

[1] Eric

[2] Guy

[3] -EMPTY-

[4] -EMPTY-

Do you understand now?

THANK you for a much easier example then the one from the helpfile. Now I understand it. :-)

Share this post


Link to post
Share on other sites

This is the statement that confuses me:

That sounds like simply needing to use a for loop to step through rather that redefine.

Can you clarify?

$output = StringSplit($sHTML, 'fb_protected="true"', 1); split after 
;ConsoleWrite($output[2] & @LF)
$output2 = StringTrimLeft($output[2], 7)
;ConsoleWrite($output2 & @LF)
$uninvited = StringLeft($output2, StringInStr($output2, "</SPAN></LABEL><LABEL class") - 1); split before 
ConsoleWrite($uninvited & @LF); write output to console. this should be only the names

$output = StringSplit($sHTML, 'fb_protected="true"', 1); split after 
;ConsoleWrite($output[2] & @LF)
$output2 = StringTrimLeft($output[3], 7)
;ConsoleWrite($output2 & @LF)
$uninvited = StringLeft($output2, StringInStr($output2, "</SPAN></LABEL><LABEL class") - 1); split before 
ConsoleWrite($uninvited & @LF); write output to console. this should be only the names

$output = StringSplit($sHTML, 'fb_protected="true"', 1); split after 
;ConsoleWrite($output[2] & @LF)
$output2 = StringTrimLeft($output[4], 7)
;ConsoleWrite($output2 & @LF)
$uninvited = StringLeft($output2, StringInStr($output2, "</SPAN></LABEL><LABEL class") - 1); split before 
ConsoleWrite($uninvited & @LF); write output to console. this should be only the names

$output = StringSplit($sHTML, 'fb_protected="true"', 1); split after 
;ConsoleWrite($output[2] & @LF)
$output2 = StringTrimLeft($output[5], 7)
;ConsoleWrite($output2 & @LF)
$uninvited = StringLeft($output2, StringInStr($output2, "</SPAN></LABEL><LABEL class") - 1); split before 
ConsoleWrite($uninvited & @LF); write output to console. this should be only the names

I want to know how I can loop this so I don't have to write the whole code again for each output.

2nd problem here...how will I know when I reach the end cause today there are 15 words on the list, tomorrow 25, the day after only 3?

that is what I wanted to achieve.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

ok, I think I figured it out...

#include <IE.au3>
#include <Array.au3>
Global $sURL1 = "http://apps.facebook.com/inthemafia/remote/html_server.php?xw_controller=recruit&xw_action=view"
Dim $output
$oIE = _IECreate($sURL1); opens the MY mafia page
$sHTML = _IEBodyReadHTML($oIE);  reads all the text on MY MAFIA

$output = StringSplit($sHTML, 'fb_protected="true"', 1); split after
For $uninvited in $output
$uninvited = StringLeft($output[2], StringInStr($output[2], "</SPAN></LABEL><LABEL class") - 1); split before 
$name = StringTrimLeft($uninvited,7)
ConsoleWrite($name & @LF); write output to console. this should be only the names
Next

the only problem I'm having now is that I get the same name 35 times instead of different names...

what is wrong here?

Edited by Overlord

Share this post


Link to post
Share on other sites

The said to Redim the loop, just lookup the Redim in the help file. I would however create a array based off of how many are on the list seperate from the list, then you can _ArrayConcatenate with your true list, it works ALOT faster then Rediming up to 10 to 25 times especially if you start out with a list that is over 100


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites

You are incorrectly labeling it by using the output[2] meaning your going through the same thing over 35 times. Can you look at the "For In Next" in the help files because you cannot use the expression and variable together while inside the loop. Suppose to use the variable that you declared off the expression.


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

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