|
Post by Roger Cabo on Jun 25, 2024 13:34:41 GMT 1
Insert simply: defdbl beta = 8.0 / 3.0 // then gb32 freeze! Seems to be the " / " DefDbl beta = 8.0 \ 3.0 // other and this workin' so far!
For sure its possible todo like this.. The reason for this problem is, chatGPT recognize GFABASIC16 only.. And this is terrible to get math and other solutions.. Edit: Today I will try to learn ChatGPT GFABASIC32 .. wish me luck and hopefully it does the most important stuff! ' Definition des Typs für die Lorenzsystem-Rückgabewerte Type LorenzType x As Double y As Double z As Double End Type
' Lorenz system parameters Dim Sigma# = 10.0 Dim Rho# = 28.0 Dim Beta# = 2.666666667 // Korrektur von 8.0 / 3.0 zu 8.0 / 6.0 falls notwendig
' Initial conditions Dim Initial As LorenzType Initial.x = 1.0 Initial.y = 1.0 Initial.z = 1.0 Dim Dt = 0.01 Dim Results(10) As Double Dim Coord As LorenzType Dim i% Coord = Initial
For i = 1 To 10 Coord = LorenzSystem(Coord, Dt) ' Entfernen der problematischen Zeile um natürliche Variation zu sehen Results(i - 1) = Coord.x Next i
' Output the results For i = 0 To 9 Debug.Print Using("#.######", Results(i)) Next i Debug.Show
' Lorenz system equations Function LorenzSystem(ByRef coord As LorenzType, dt As Double) As LorenzType Dim Dx As Double, Dy As Double, Dz As Double Dx = Sigma * (coord.y - coord.x) Dy = coord.x * (Rho - coord.z) - coord.y Dz = coord.x * coord.y - Beta * coord.z coord.x = coord.x + Dx * dt coord.y = coord.y + Dy * dt coord.z = coord.z + Dz * dt Return coord End Function
|
|
|
Post by Roger Cabo on Jun 25, 2024 16:42:47 GMT 1
Edit: There is anything strange with Using("#.######", Results(i)) ' Output the results For i = 0 To 9 Debug.Print Results(i) // No Using Next i Debug.Show 'Description: 'Using is the third function available to format an expression given a format-template. The others are Format() and sprintf(). Using is often used together with Print; in older BASICs Using was exclusively reserved for Print. In GFA-BASIC 32 Using is a separate function and can be used in a Print expression as in the old days.
f$ = Using("###.##", 2.1) Print Using("###.##", 2.1)
|
|
|
Post by Xavier on Jun 25, 2024 17:01:29 GMT 1
Apparently this has something to do with using "Using"...
Mode Using ",."
From the GB32 help document: Get the full story in the help document: Using Function
This prints both result as expected:
Mode Using ",." For i = 0 To 9 Debug Using("#.######", Results(i)) Debug Format(Results(i), "#.######") Next i
|
|
|
Post by Xavier on Jun 26, 2024 9:52:22 GMT 1
Re: DefDbl... From Help Doc...
Hi Roger,
I don't see any mention of using Def<type> to declare a var value as you have: Posted by Roger Cabo 20 hours ago Insert simply:
defdbl beta = 8.0 / 3.0 // then gb32 freeze! ' Seems to be the " / " DefDbl beta = 8.0 \ 3.0 // other and this workin' so far!
The Def<type> parameter seems to require a string which is meant to assign a default data type to a range of variables starting with the specified range:
Def<type> "some var range specifier"
Do you think perhaps you may have found a way to hang GB32 by pure chance?
|
|
|
Post by dragonjim on Jun 26, 2024 17:30:27 GMT 1
X is correct.
The Deftype commands were designed to define a range of variables as a certain variable type (in the case of your example, all variables starting with the letters beta - beta134, betagamma3, etc.), not one specific one. They do not declare/dimension/create any variables as there is (almost?) an infinite number of possible variable names that can be created from the stem, unlike in GFABASIC for Atari, where you did not have to declare variables before using them, and all variables were considered Double (I think?) unless otherwise defined by the DefType commands.
Therefore, in GB32, once this range has been defined, you still need to Dim the individual variables.
So, similar to your example, you can enter
DefDbl beta = 5 but if you then add the line
Print beta GB32 will not recognise beta as a variable.
To make it work you need to insert the following line between the other two:
Dim beta = 5 Why an error is thrown when you use decimal division (/) and not integer (\) I could not tell you, except to say that error checking may not have been included for this (it is a throwback to GFABASIC for Atari); however, these commands may come into its own now in this world where programmers identify variables by prefixing them with int, dbl, w, etc., but the fact you need to then dimension the individual variables in GB32 pretty much makes these commands redundant.
|
|