Matrix Elements VB-800 Instrukcja Użytkownika Strona 28

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 172
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 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.
Przeglądanie stron 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 ... 171 172

Komentarze do niniejszej Instrukcji

Brak uwag