Case Structure? and other newbie questions

Post your questions and help other users.

Moderator: Martin

Post Reply
StillLearning
Posts: 7
Joined: 11 Jan 2016 04:13

Case Structure? and other newbie questions

Post by StillLearning » 20 Jan 2016 22:04

Does AutoMagic have a case structure?

Select ??
Case
Case
Case
End Select

If not ...

What is the work around sequence?

******
Can the if statement do:

If ...

Else if


Else if


Else if

Edit: I have tried this and did does seem to work. Still I seek the case statement for simpler coding.

****

How do I execute a flow from within the an if statement?

****

In the FOR statement:

for (i in list)

What is the index variable and how do I reference it?

"i" seems to be content from the list.

I need to know the index/count

***

How do I detect a random PopUp window within the running app that I have a flow executing on?

This app will NOT give me any Query information, so no ID nor title is available.

Needless to say when this happens ( the PopUp ) it messes the run flow up.

Are these PopUp windows detectable?

**********

How do I get current focus?

**********

How do I get the parm count (number of entries) in a list and/or map?

**********

How do I get the Init Variable Text File to read the text as it is formated in the file and not as one large bite?

Line1
Line2
Line3
Line4

It reads it as [[line1,line2,line3,line4]]

******
When is an APP considered "running"?

I use launch app and the flow continues to the next step. I have a few apps that sometimes take a long time to be
fully functional. This load time is random. Sleeping a huge time stops an input when the load time is short.

How do I detect a completely loaded/active app?

*************

I know a lot of questions, probably will be more, hope I can get working answers.

Thank You

StillLearning

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Case Structure? and other newbie questions

Post by Martin » 21 Jan 2016 21:16

Hi,

I'll try to answer... :)
Feel free to ask again if I miss some questions:

There's not switch/case-syntax, using else if might be the way to go in a script.

You can not execute a flow from within a script action directly (respectively it's not meant to be done). You can use action Execute Flows to execute other flows.

A for-loop does not provide an index variable by its own. Use a loop over an index to have this:
int n = length(list) - 1;
for (i in [0 to n]) {...}

Popup-Windows might be detectable with trigger UI Event event type Window opened. Check the provided variables with an action Notification On Screen to check if there's anything useful to identify the popup window.

Currently there's no function to get the focused component. How would you like to use the current focus?

Entries in a list/map: n = length(list); respectively: n = length(map);
also check out the documentation of action Script

Action Init Variable Text File should read the text as is, no additional characters etc. You can use function split to split it into lines. Check out the examples page: Script examples: Create a list of lines from a multiline text

It's difficult to detect when an app is "running" properly. An app could show a progress dialog and display the real content five minutes later after a long network operation completes. "Running" usually means when the app is in the foreground so will be true as soon as the app is displayed. You could use action Control UI with action getText to see if an expected button or text field is displayed at a given location.

Regards,
Martin

nbi
Posts: 25
Joined: 30 Apr 2016 21:49

Re: Case Structure? and other newbie questions

Post by nbi » 10 Feb 2017 21:57

Are multiple loop control variables legal? For example:

jlst=newList(3, 0, 1, 2);
for (i in [0 to 3],j in jlst)
{
......
}

Yes, jlst has a strange sequence - don't ask. :shock:

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Case Structure? and other newbie questions

Post by Martin » 10 Feb 2017 22:08

Automagic does not provide multiple loop control variables. When I understand your example, you could do it like this:

Code: Select all

jlst=newList(3, 0, 1, 2);
n = length(jlst) - 1;
for (index in [0 to n])
{
  // index will contain 0, 1, 2, 3
  // value will contain 3, 0, 1, 2
  value = jlst[index];
  log(index + " --> " + value);
}
Regards,
Martin

Post Reply