Karel Globale Variablen

  • Hallo zusammen,


    ich bin recht neu in der Karel Programmierung und schreibe gerade ein Roboterprogramm in Karel und will mit Globalen Variablen arbeiten, allerdings nicht mit Registern oder Flags.



    Ich habe mehrere Programme wie z.B. Main.kl ; Start.kl ; Error.kl etc…


    Jetzt sollte ich eine Möglichkeit haben wie ich in allen Programmen auf dieselben Variablen zugreifen und diese beschreiben kann,


    so dass ich den geänderten Wert im anderen Programm auch mitbekomme (da Parallelprogramme)…



    Gibt’s da eine Möglichkeit? :/


    Vielen Dank :)

  • ANZEIGE
  • Hallo DaKLAFS,


    schau mal in der Karelreferenz nach "FROM"


    FROM Clause

    Purpose: Indicates a variable or routine that is external to the program, allowing data and/or routines

    to be shared among programs

    Syntax : FROM prog_name

    where:

    prog_name : any KAREL program identifier

    Details:

    • The FROM clause can be part of a type, variable, or routine declaration.

    • The type, variable, or routine belongs to the program specified by prog_name .

    • In a FROM clause, prog_name can be the name of any program, including the program in which

    the type, variable, or routine is declared.

    • If the FROM clause is used in a routine declaration and is called during program execution, the

    body of the declaration must appear in the specified program and that program must be loaded.

    • The FROM clause cannot be used when declaring variables in the declaration section of a routine.

Erstelle ein Benutzerkonto oder melde dich an um zu kommentieren

Du musst ein Benutzerkonto haben um einen Kommentar hinterlassen zu können

Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Geht einfach!
Neues Benutzerkonto erstellen
Anmelden
Du hast bereits ein Benutzerkonto? Melde dich hier an.
Jetzt anmelden