MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuel de service Page 58

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 282
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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
Vue de la page 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 281 282

Commentaires sur ces manuels

Pas de commentaire