Elements in a loop - Forum

Forum Navigation
You need to log in to create posts and topics.

Elements in a loop

Please tell me:
There are 50 text output elements (Inscription/Text) on the page.
Each element has its own name, for example Text600.
All subsequent Text601, Text602, Text603 and so on up to Text649.
How can I change the name of the element in order to loop through all the elements.
For example, to update their content?

Подскажите пожалуйста:
На странице находятся 50 элементов для вывода текста (Надпись/Текст).
Каждый элемент имеет своё имя, например Text600.
У всех последующих Text601, Text602, Text603 и так до Text649.
Как можно изменять имя элемента чтобы в цикле перебрать все элементы.
Например чтобы обновить их содержание?

Hi @Igor-13

Try this:

Loop "600" "649" "[pos]"
SetObjectCaption "Text[pos]" "caption text [pos]"
EndLoop

 

luishp, Vadim and Igor-13 have reacted to this post.
luishpVadimIgor-13

Thank you very much, I will try :)

Hi @emmanuel-fernandez,

Since I came here to ask questions about loops, perhaps you won't mind my hijacking this thread ;-)

I have a loop that runs very large lists.  I would like to be able to create both, a pause button and an abort (stop) button.   The trouble is that the mouse and keyboard are more or less frozen during a looping process, so I'm a bit unclear on how I can operate both a pause and a stop (abort) from buttons.

This next question isn't about loops exactly but is IN my loop.   I wish to trap file access errors and so I have unchecked "show errors" in the pub setup and I'm working with [LastError].  Since this variable is in a loop, I do not know if I need to manually set the variable to null via setvar, OR if this value automagically clears itself after the next operation?

 

Thanks guys

 

@rcohen

Hi Robert!

a) Instead of Loop you can use While and in its condition check the value of variable (play \ stop). The value of the variable can be changed in the subroutine (including hotkeys). Although inside Loop you can also check the value of the desired variable and in case of a stop do ExitLoop.

b) Yes, as far as I know the [LastError] variable is cleared after the next successfully executed command. You can check this on a test project by hiding the error between other lines of code.

 

rcohen and emo have reacted to this post.
rcohenemo

Thanks @vadim.

It was the DoWhile that I was struggling to recall....   thanks for kicking the memory bank ;-)

I would like to have tested it but I can't force an error in this case ;-0    I think it resets too but wasn't sure.

Thanks again

 

 

Hi Robert,

consider putting a delay "10" inside the while, to "distract" the control of the process and that it can be more "controllable", pausing or ending the loop

my 0.01

rcohen has reacted to this post.
rcohen

@rcohen

Before one can propose a solution, there need to be some questions answered first ...

1) can you put a number to 'very large lists' ?

2) can you post an example of the commands to be serviced per iteration of the loop ?

3) how many seconds/minutes does it take to go through the whole list ?

4) What is the purpose of the Pause and Abort Buttons ? ... are they related to any errors (i.e. [LastError]) reported by the pub or just because the user is impatient ?

5) Does the Pause process require another button to Resume the loop ?

I would like to have tested it but I can't force an error in this case ;-0 I think it resets too but wasn't sure.

Inside your loop, add these commands temporarily ...

If "[LoopCounter]" "=" "20"
   ... force an error
   Math "[aaa]/0" "0" "[bbb]
EndIf

SetVar "[errorResult]" "[LastError]"

 

... and have a TextBox with its content set to [errorResult]

If the TextBox only flashes the error temporarily, then you can assume that [LastError] is being reset.

CN_Iceman and rcohen have reacted to this post.
CN_Icemanrcohen

Hi @gaev

For now I have the issue solved.  When I enter a long loop, my mouse generally spins up a "busy pointer".   But it never occurred to me that I could just position and click as once you move the mouse the busy pointer vanishes...   Imagine my surprise LOL ;-)
Thanks all who offered solutions.