Karel - Init Variables

  • Hi,

    I am having some problems on execute a program at the controller start an init the variables only once.


    For example:


    Program main


    VAR

    i : INTERGER


    ROUTINE Init

    BEGIN

    i=0

    END Init



    ROUTINE Program

    BEGIN

    i=i+1

    END_Program


    BEGIN

    Init

    REPEAT

    abort_=FLG[555]

    Program

    DELAY(1000)

    UNTIL abort_

    END main


    I put [Main] in HOT START and COLD START Autoexec program but every cold or hot start i restart to 0 even with the '" return to top of program" = FALSE


    May be there is another way to do what I need?


    Thanks

  • AD
  • Nono,


    Its not clear what you are trying to do.

    However, the UNINIT command may be useful. It will return TRUE if a variable is uninitialized.

    For example, if you only want to set i=0 on the first execution of your main program:


    IF UNINIT(i) THEN

    i=0

    ENDIF

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now