Studio error or wrong code

https://youtu.be/A6LPeWhtTjI
What you see in the back is a keyboard input test window
And I’m debugging the elevator
If you press the button on the building, the studio will move at will
I pressed the button, but I wonder why it’s going offline
Am I doing this because I wrote the wrong code?
Previously, however, the behavior was different when debugging and monitoring
I couldn’t film it, but if I were to tell you the situation
When you turn on the monitor, press the building up-down button to go up to the second floor, and when debugging, it goes up to the desired floor
Do you have any idea what kind of error it is…

Hi @limhyeonsoo, I watched your video and I’m not sure how others see that. But I have no idea what is your problem. Can you maybe describe it a little bit better?

1 Like

I’m also not entirely sure what you’re asking. However I do know that Monitor Mode can sometimes have weird behavior. If you’re concerned about your Watch window not updating properly, try this:

  1. Disable Monitor Mode using the magnifying glass in the toolbar
  2. Close all Automation Studio tabs (Window → Close All)
    2a. Don’t save any of the Watch window configurations
  3. Go to Project → Clean Configuration
    3a. Check all 4 boxes in the popup that appears
    3b. This will delete all of your saved Watch + Trace window settings, as well as delete all project binaries
  4. Perform a Rebuild and transfer your project to ARSim

If the problem persists, then it’s related to your code and something is resetting the values you’re entering. Otherwise, it may have been some sort of glitch with the Watch window. If that ever happens, you can usually fix it by closing and re-opening your Watch window (and exiting Monitor Mode) but a rebuild will ensure that everything is cleaned out fully.

2 Likes

It’s been resolved because someone I know helped
Thank you for your answer

It’s been resolved because someone I know helped
Thank you for your reply

Ok can you share with is what was the solution? if it was problem with AS Watch or something similar, then it would be worth it for others. Please mark it as a solution. :slight_smile:

1 Like

I set ‘i’ as a global variable and made the operation of pressing the number of floors into a for loop. But it’s a loop where you mark 1 to 6 and add 1 to see if there are pressed buttons on each floor
However, the for loop was set incorrectly here
If you write it like a picture and the for loop ends, 7 is derived, and 7 is an error that occurred because I did not recognize it in the code I wrote
KakaoTalk_20240226_141950891

  1. When setting a variable such as i, designate it as a local variable
  2. When using the array function, it would be better to force the range of values using the for loop to limit the range of i
2 Likes

I’m glad you figured it out! In case anyone else stumbles upon this thread, I wanted to give one more piece of advice to add onto your notes.

You can define the size of an array using a constant variable like so:

This allows you to use the same constant in your code to limit the range of any FOR loops:
image

Then, if you ever need to change the size of your array, all you have to change is the value of this constant. The array declaration and your code will automatically adapt.

14 Likes

Thx for your tip ^^ :smile:

Hi all,

great, that you found a solution! :clap:

Another tip to loop safely through arrays is calculating the array size in the code, for example if you can’t use a constant (for whatever reason).

You can do this calculation by determine the size of the whole array, and divide it by the size of one array element → the result is the number of array elements.

// If you're starting at array index 0, don't forget to subtract 1 at the loop end index after the calculation of the number of array elements
for i := 0 TO SIZEOF(MyArray)/SIZEOF(MyArray[0]) -1 DO
   MyArray[i] := i + 1;
END_FOR

9 Likes