MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Instrukcja Obsługi Strona 58

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 282
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 57
2
Working with the Target Language
2-38
Within the scope of a function, variable assignments always create new local
variables unless you use the
:: scope resolution operator. For example, given
a local variable
foo and a global variable foo:
%function
%assign foo = 3
%endfunction
In this example, the assignment always creates a variable foo local to the
function that will disappear when the function exits. Note that
foo is created
even if a global
foo already exists.
In order to create or change values in the global scope, you must use the
::
operator to disambiguate, as in:
%function
%assign foo = 3
%assign ::foo = foo
%endfunction
The :: forces the compiler to assign to the global foo, or to change its existing
value to 3.
Note: It is an error to change a value from the RTW file without qualifying it
with the scope. This example does not generate an error:
%assign CompiledModel.name = "newname" %% No error
This example generates an error:
%with CompiledModel
%assign name = "newname" %% Error
%endwith
Przeglądanie stron 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 281 282

Komentarze do niniejszej Instrukcji

Brak uwag