Matrix Elements VB-800 Manuel d'utilisateur Page 28

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 172
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 27
20 Appendix A1 Extending Ox
cT = dlg.mcT
cN = dlg.mcN
cLag = dlg.mcLag
Call OxValSetInt(OxValGetArrayVal( _
OxValGetVal(pv, 0), 0), cT)
Call OxValSetInt(OxValGetArrayVal( _
OxValGetVal(pv, 1), 0), cN)
Call OxValSetInt(OxValGetArrayVal( _
OxValGetVal(pv, 2), 0), cLag)
Call OxValSetInt(rtn, 1)
End If
End Sub
.......................................................................................
This time we cannot use macros to access the contents of the arguments. We
know that pv will consist of three OxVALUEs. OxValGetVal(pv, 0) accesses the first,
OxValGetVal(pv, 1) the second, etc. We also know that each of these is a refer-
ence, which is passed as an array. OxValGetArrayVal accesses the reference. Finally,
OxValGetInt is used to get the value as an integer, and OxValSetInt tosetittoan
integer.
A1.7 Linking Fortran code
Linking Fortran code to Ox does not pose any new problems, apart from needing to
know how function calls work in Fortran. The simplest solution is to write C wrappers
around the Fortran code, and use a Fortran and C compiler from the same vendor.
Arguments in Fortran functions are always by reference: change an argument in
a function, and it will be changed outside the function. For this reason, well-written
Fortran code copies arguments to local variables when the change need not be global.
Two examples are provided. The directory ox/samples/fortran contains a sim-
ple test function in Fortran, and a C wrapper which also provides a function which is
called from Fortran. These examples use Watcom Fortran, but other compilers will also
be feasible.
Vue de la page 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 ... 171 172

Commentaires sur ces manuels

Pas de commentaire