MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuale di Servizio Pagina 58

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 282
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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
Vedere la pagina 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 281 282

Commenti su questo manuale

Nessun commento