Jump to content

Need help with arrays and loops


Recommended Posts

Hey all,

I'm trying to call each variable from an array individually to use in a loop, then perform some actions, and when the loop is complete call the next variable.

For example,

$Hello[0] = Apple
$Hello[1] = Banana
$Hello[2] = Pineapple
$Hello[3] = Pear
$Hello[4] = Mango
$Hello[5] = Orange

I now want to call on the array to do some functions which I assume I would you a For...To...Next statement, however, I'm not sure how to properly do it.

What I want to happen is for example to open notepad, Paste "Apple", then exit Notepad, Click on a button on a different application, then do the same loop for "Banana", then "Pineapple" and so on.

If anyone could help me with this I'd greatly appreciate it, I'm not sure what this function would be called so I couldn't find it anywhere else in the help section.

Link to comment
Share on other sites

iNadez-,

A simple example...

local $hello[6]

$Hello[0] = 'Apple'
$Hello[1] = 'Banana'
$Hello[2] = 'Pineapple'
$Hello[3] = 'Pear'
$Hello[4] = 'Mango'
$Hello[5] = 'Orange'

for $i = 0 to ubound($Hello) - 1
    ;
    ; do something
    ;
    ConsoleWrite($Hello[$i] & @CRLF)
next

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

46 minutes ago, kylomas said:

iNadez-,

A simple example...

local $hello[6]

$Hello[0] = 'Apple'
$Hello[1] = 'Banana'
$Hello[2] = 'Pineapple'
$Hello[3] = 'Pear'
$Hello[4] = 'Mango'
$Hello[5] = 'Orange'

for $i = 0 to ubound($Hello) - 1
    ;
    ; do something
    ;
    ConsoleWrite($Hello[$i] & @CRLF)
next

kylomas

How do i send the 'Apple' value? when i use the consoleWrite command it just sends "$Hello[$i]" to the console until the end of the array number

Link to comment
Share on other sites

In the for loop, each "round" $i increments.  So, on the first round $i = 0 and thus $Hello[0] = "Apple".

Make sure $Hello[0] (or $Hello[$i]) is not wrapped in quotes.

Edited by spudw2k
Link to comment
Share on other sites

Global $InstaFamous[15];
   $InstaFamous[0] = "https://www.instagram.com/christianguzmanfitness/?hl=en"
   $InstaFamous[1] = "https://www.instagram.com/stevecook/?hl=en"
   $InstaFamous[2] = "https://www.instagram.com/bradleymartyn/?hl=en"
   $InstaFamous[3] = "https://www.instagram.com/calumvonmoger/?hl=en"
   $InstaFamous[4] = "https://www.instagram.com/therock/?hl=en"
   $InstaFamous[5] = "https://www.instagram.com/loganpaul/?hl=en"
   $InstaFamous[6] = "https://www.instagram.com/buffbunny/?hl=en"
   $InstaFamous[7] = "https://www.instagram.com/jakepaul/?hl=en"
   $InstaFamous[8] = "https://www.instagram.com/nikkiblackketter/?hl=en"
   $InstaFamous[9] = "https://www.instagram.com/jenselter/?hl=en"
   $InstaFamous[10] = "https://www.instagram.com/1dayumay/?hl=en"
   $InstaFamous[11]= "https://www.instagram.com/whitneyysimmons/?hl=en"
   $InstaFamous[12] = "https://www.instagram.com/maxxchewning/?hl=en"
   $InstaFamous[13] = "https://www.instagram.com/omarisuf/?hl=en"
   $InstaFamous[14] = "https://www.instagram.com/silentmikke/?hl=en"

Okay so this is my code, I now want to take these values and input them into the google search bar. This is what I have:

Func Famous()
         for $i = 0 to ubound($InstaFamous) - 1
            MouseClick("left",1133, 63,1,500)
            Send("$InstaFamous[$i]"
            Send("{ENTER}")
         Next
      EndFunc

I'm just not sure how to paste that information I have called from the array into the google bar (PS: The mouseclick is the google URL bar

Link to comment
Share on other sites

Are you using IE?

There are _IE functions that will reliably set a dom object with a specific value...send is very unreliable

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...