The command 'once' is not doing what is expected

Forums ProRealTime English forum ProBuilder support The command 'once' is not doing what is expected

Viewing 10 posts - 1 through 10 (of 10 total)
  • #71154

    Please try out following lines

    I would expect that M2 is getting the value of M1 but the value stays zero!

    #71158

    It DOES do what it is expected from it!

    That’s because ONCE is executed only ONCE; when you launch that code BARINDEX=0, so will be M1 and, finally… M2, which will NEVER be executed again (while M1 continues growing).

    #71168

    Thanks for your prompt answer. Could you please help me to understand the following:

    It still returns zero!

    #71175

    Not sure why it does not pick up the value but you do not really need the once. This code will fix the value as you want it. The Once is not necessary if you use an =

    p.s. – it is preferred if you use the ‘Insert PRT Code’ button when posting code in the forums. I’ve tidied up your posts for you!

    1 user thanked author for this post.
    #71182

    ONCE is read by the system ONCE at launch time, so your code could be written as

    When BarIndex is ZERO the IF…ENDIF block will be skipped, later, when executed, line 3 will be skipped because of the ONCE keyword.

     

    #71183

    Thanks for your alternative code. You are right there are often many ways around. My sample code had to discover the missfunction of the command ‘once’ just in principle and my hope is to get it working in future. It was thought as a request to the programmer. I obvioused that the missfunction is limited to barindex but it works fine with other values.

    #71185

    ONCE is read by the system ONCE at launch time

    Which so obviously why it does not work at BarIndex 3! I must be tired….

    #71187

    Do I get it right that ONCE is executed just one time in the very first loop of a program? So that it is not useful to use ONCE it in a later loop independent on its position? Thanks for your support to getting a better understanding.

     

    #71188

    ONCE is used to initialize a variable (PRT doeas not tell between variables and constants), as soon as the code is launched, after that it will simply be ignored, no matter where you write it.

     

     

    #71190

    So it is no missfunction it was just my misunderstanding of the comand ONCE.
    Thank so much for your patience!

Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login