Page 1 of 1

Case Structure? and other newbie questions

Posted: 20 Jan 2016 22:04
by StillLearning
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

Re: Case Structure? and other newbie questions

Posted: 21 Jan 2016 21:16
by Martin
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

Re: Case Structure? and other newbie questions

Posted: 10 Feb 2017 21:57
by nbi
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:

Re: Case Structure? and other newbie questions

Posted: 10 Feb 2017 22:08
by Martin
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