Matrix Elements VB-800 Instrukcja Użytkownika Strona 26

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 172
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 25
18 Appendix A1 Extending Ox
The first command changes the random number generator,which requires passing
a string, and gets a random number.
The second passes the text of the first edit field (the random number) to
DLogGamma (the argument is automatically passed as a double here), and puts
the result in the second edit field.
Button three is more complex. It creates a Basic array of doubles. Then allocates
an Ox MATRIX of which the address is stored in pmat. The Basic array is copied
to the 2 × 2 Ox matrix by row. This is inverted using the Ox function IInvert,
and the outcome put back into the Basic array. The Ox matrix is freed to prevent
a memory leak. In this way all Ox matrix functions can be used, but:
Care is required when using pointers. A mistake will not only crash
your program, but take VB down as well. So save your work before
testing your code.
The last command shows that VB arrays of doubles are compatible with Ox
VECTORs. The array is passed by specifying the first element Vec(0),which
actually will pass a pointer to the array.
A1.6.2 The RanApp example in Visual Basic
The structure of the VB program is very similar to that in §A1.5:
.........................................ox/dev/windows/vb/RanApp.frm (part of)
Private Sub Form_Initialize()
Dim Res As Integer
Res = FOxGiveWinStart("RanApp", "RanApp", False)
Res = FOxLibAddFunction("ccc$GetRanAppSettings", _
AddressOf FnGetRanAppSettings, 0)
may need to set explicit path to ranapp.ox
giMainIP = OxMainCmd("-r- ranapp.ox")
Draw.Enabled = False
Variance.Enabled = False
If (Res = 0 Or giMainIP <= 0) Then
Generate.Enabled = False
Dimension.Enabled = False
End If
End Sub
Private Sub Form_Terminate()
Call OxGiveWinFinish(True)
End Sub
Private Sub Draw_Click()
Dim Res As Integer
Res = FOxRun(giMainIP, "OnDraw")
End Sub
Przeglądanie stron 25
1 2 ... 21 22 23 24 25 26 27 28 29 30 31 ... 171 172

Komentarze do niniejszej Instrukcji

Brak uwag