Intelligent Automation & Macro Software  

Go Back   Automation Anywhere, Inc. Forums > Products Zone > Automation Anywhere
Register FAQ Search Today's Posts Mark Forums Read

Automation Anywhere Post messages and questions related to Automation Software here.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-13-2011, 05:04 AM
desm35 desm35 is offline
Junior Member
 
Join Date: Sep 2011
Posts: 8
Default Multiple IF's with Variable

I'm trying to create a multiple IF statement with a Variable, but can't figure out the correct syntax.

I have a variable that I've called $Random$ that is configured as follows:
Random
Type: List
Option: Values
Values: A;B;C;D

I want the following achieved:
If $Random$
Includes 'A' Then Mouse Click: Position 1
Includes 'B' Then Mouse Click: Position 2
Includes 'C' Then Mouse Click: Position 3
Includes 'D' Then Mouse Click: Position 4

At present I have it setup as follows:

If $Random$ Includes 'A' Then
Mouse Click: Position 1
End If
If $Random$ Includes 'B' Then
Mouse Click: Position 2
End If
If $Random$ Includes 'C' Then
Mouse Click: Position 3
End If
If $Random$ Includes 'D' Then
Mouse Click: Position 4
End If

I assume this is wrong as this will randomly generate A,B,C,D four times, but I can't figure out how to assess multiple IF's against a variable that is generated once. Can anyone help. Thanks.

Dunc
Reply With Quote
  #2 (permalink)  
Old 09-13-2011, 12:12 PM
forumstaff forumstaff is offline
Senior Member
 
Join Date: Oct 2010
Posts: 521
Default

Hello desm35,

We recommend you to replace the operator from "includes" to "equals".

For example:

The following If statement:

If $Random$ Includes 'A' Then
Mouse Click: Position 1
End If
If $Random$ Includes 'B' Then
Mouse Click: Position 2
End If
If $Random$ Includes 'C' Then
Mouse Click: Position 3
End If
If $Random$ Includes 'D' Then
Mouse Click: Position 4
End If

Has to be changed to:

If $Random$ Equals 'A' Then
Mouse Click: Position 1
End If
If $Random$ Equals 'B' Then
Mouse Click: Position 2
End If
If $Random$ Equals 'C' Then
Mouse Click: Position 3
End If
If $Random$ Equals 'D' Then
Mouse Click: Position 4
End If

Please let us know how it goes for you.

Thanks & Regards
Reply With Quote
  #3 (permalink)  
Old 09-13-2011, 04:04 PM
desm35 desm35 is offline
Junior Member
 
Join Date: Sep 2011
Posts: 8
Default

Ok, I've changed 'Includes' to 'Equals' which in my situation does actually do the same thing.

What I am actually after is the correct syntax to randomly generate either A,B,C,D only once. Depending on which letter is generated, the mouse would then click in the spot designated to that letter.

Here's the process:
1) Randomly generate either A,B,C or D.
2a) IF, random generation = 'A', Then Mouse Click in Position 1
2b) IF, random generation = 'B', Then Mouse Click in Position 2
2c) IF, random generation = 'C', Then Mouse Click in Position 3
2d) IF, random generation = 'D', Then Mouse Click in Position 4

A,B,C or D should only be randomly generated once and then the appropriate mouse click made.

At present, I think that my code is randomly generating A,B,C,D four times, which is incorrect. Thanks.

Dunc
Reply With Quote
  #4 (permalink)  
Old 09-14-2011, 03:11 PM
forumstaff forumstaff is offline
Senior Member
 
Join Date: Oct 2010
Posts: 521
Default

Hello desm35,

Instead of creating a new variable, you can make use of "my-list variable" which works similar to the array of values. You can read the values randomly by having the "make random" check box active while editing the "my-list variable" and inserting the list of values you want to use in your task. Then you can make use of the "if-else-is" conditional construct according to your requirement.

Please find a task attached with this post according to your requirement. Instead of the mouse clicks, we have used "message box".

Thanks & Regards
Attached Files
File Type: atmn testrandom.atmn (749 Bytes, 3 views)
Reply With Quote
  #5 (permalink)  
Old 09-14-2011, 05:04 PM
desm35 desm35 is offline
Junior Member
 
Join Date: Sep 2011
Posts: 8
Default

I've attached an updated version of your test. I am still finding that with your latest suggestion, the code creates multiple mouse clicks in one loop of the process.

In one loop of my code it often clicks more than once. For example, in one loop it may click in Position 1 twice and Position 2 once. On another loop it may click in Position 1 once, Position 2 once and Position 3 once.

It is as if the random letter is being generated more than once giving the possibility that, say 'A', 'B' and 'D' for example may be generated and thus mouse clicks would be made in Position 1,2 and 4.

I want only one letter to be generated on the entire loop of the process. On this 1st loop a 'B' may be generated for example and the mouse would click in Position 2. On the 2nd loop (it is set to 10 loops) a 'D' may be generated and thus a mouse would be made in Position 4.

Any ideas.

Dunc
Attached Files
File Type: atmn testrandom_export.atmn (40.4 KB, 1 views)
Reply With Quote
  #6 (permalink)  
Old 09-14-2011, 09:21 PM
philkryder philkryder is online now
Senior Member
 
Join Date: Sep 2007
Posts: 458
Default

keep us posted on how this works for you.

You might consider instead,
using an XCEL spreadsheet with the random function
and
read the mouse positions and click on them.

The IF constructs withing AA are minimal.

Use AA for those things at which it excels.

Use excel calculate the random values.
Use AA to click where you need it.

good luck. Phil
Reply With Quote
  #7 (permalink)  
Old 09-15-2011, 02:43 AM
desm35 desm35 is offline
Junior Member
 
Join Date: Sep 2011
Posts: 8
Default

Are you sure that AA can't do what I am after? It seems like quite a sophisticated program being able to create quite complex variables. You say that the IF constructs are quite minimal, but there are options for IF, IF ELSE and ELSE. Surely this is enough to construct code that:

1) Generates a random letter.
2a) IF the random letter = 'A', then click in Position 1
2b) IF the random letter = 'B', then click in Position 2
2c) IF the random letter = 'C', then click in Position 3
2d) IF the random letter = 'A', then click in Position 4

Surely the code I have attached to this thread just needs tweaking - the syntax is just slightly wrong?

Dunc
Reply With Quote
  #8 (permalink)  
Old 09-15-2011, 07:50 PM
philkryder philkryder is online now
Senior Member
 
Join Date: Sep 2007
Posts: 458
Default

Quote:
Originally Posted by desm35 View Post
Are you sure that AA can't do what I am after? It seems like quite a sophisticated program being able to create quite complex variables. You say that the IF constructs are quite minimal, but there are options for IF, IF ELSE and ELSE. Surely this is enough to construct code that:

1) Generates a random letter.
2a) IF the random letter = 'A', then click in Position 1
2b) IF the random letter = 'B', then click in Position 2
2c) IF the random letter = 'C', then click in Position 3
2d) IF the random letter = 'A', then click in Position 4

Surely the code I have attached to this thread just needs tweaking - the syntax is just slightly wrong?

Dunc
show me how you do
IF A or B?

IF A or B and C?

thats what I mean by minimal.

the problem you have MAY be related to the creation of the $RANDOM$ variable.

I saw you were working with a LIST. ? why ?

If $RANDOM$ < 2 then
variable operation $X$ = 200
variable operation $Y$ = 400
Else if $RANODOM$ < 3 then
variable operation $X$ = 300
variable operation $Y$ = 500

etc...
end if
end if

mouse click $X$ $Y$

Last edited by philkryder; 09-16-2011 at 10:12 AM.
Reply With Quote
  #9 (permalink)  
Old 10-10-2011, 06:09 PM
trentonponder trentonponder is offline
Senior Member
 
Join Date: Jan 2009
Posts: 102
Default

There are many ways to solve this. This is more a question of structuring If statements and loops in programming rather then specific to AA.

1 -
If $Random$ Includes 'A' Then
Mouse Click: Position 1
Else If
If $Random$ Includes 'B' Then
Mouse Click: Position 2
Else If
If $Random$ Includes 'C' Then
Mouse Click: Position 3
Else If
If $Random$ Includes 'D' Then
Mouse Click: Position 4
End If

2 - You can put it in a loop which will exit as soon as the new page loads (assuming that`s what the mouse click is intended to do).
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -7. The time now is 04:03 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 ©2007, Crawlability, Inc.
Copyright © 2003-2011 Automation Anywhere, Inc. All rights reserved