Posts: 495
Threads: 41
Joined: Apr 2022
Reputation:
40
03-07-2026, 04:23 PM
(This post was last modified: 03-07-2026, 04:27 PM by Jack.)
I adapted GROK's suggestion https://grok.com/share/c2hhcmQtMg_564536...04ca64c554
Code: (Select All)
Type MyType
s As String * 80
End Type
Dim MyVar As MyType
Dim mBlock As _MEM: mBlock = _Mem(MyVar)
Dim As Long i
For i = 0 To 9
PutDouble mBlock, i, Sqr(i + 1)
Next
For i = 0 To 9
Print GetDouble#(mBlock, i)
Next
_MemFree mBlock
' Helper to make syntax nicer
Sub PutDouble (mem As _MEM, index As Long, value As Double)
_MemPut mem, mem.OFFSET + index * 8, value
End Sub
Function GetDouble#(mem As _MEM, index As Long)
Dim v As Double
_MemGet mem, mem.OFFSET + index * 8, v
GetDouble# = v
End Function
still way too messy
Posts: 4,703
Threads: 222
Joined: Apr 2022
Reputation:
322
03-08-2026, 07:20 PM
(This post was last modified: 03-08-2026, 07:21 PM by bplus.)
Example of using a UDT to hold a string of Str$(numbers), actaully x,y locations stored in sequence of x y x y x y...
Code: (Select All) Type Mask
xys As String
End Type
Screen _NewImage(1024, 200, 32): _ScreenMove 100, 60
Cls , &HFF000000
Print "Hello World!"
Dim hello As Mask
nolight~& = Point(0, 15)
For y = 0 To 20
For x = 0 To 12 * 8
If Point(x, y) <> nolight~& Then hello.xys = hello.xys + Str$(x) + Str$(y)
Next
Next
Print "Press any to continue... zzz"
Sleep
ReDim msk(0) As String
Split hello.xys, " ", msk()
Cls
i = 0
While i < UBound(msk) - 2
For r = 0 To 10
Line (10 * Val(msk(i + 1)) + 40, 10 * Val(msk(i + 2)) + 10)-Step(r + 3.5, r + 3.5), _RGB32(255 - r ^ .8 * 25), B
Next
i = i + 2
Wend
Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
dpos = InStr(curpos, SplitMeString, delim)
Do Until dpos = 0
loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
arrpos = arrpos + 1
If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
curpos = dpos + LD
dpos = InStr(curpos, SplitMeString, delim)
Loop
loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
End Sub
Pretty cool print job too!
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 957
Threads: 52
Joined: May 2022
Reputation:
38
Yesterday, 06:01 PM
(This post was last modified: Yesterday, 06:08 PM by Kernelpanic.)
This thread seems to me have gone off the rails. The original question was whether arrays are possible within records. They aren't! But maybe there's a way to circumvent this limitation by "simulating" it.
I tried this, and it should come pretty close to arrays within records for certain programming tasks. I couldn't think of a better example.
Some data is requested, and then the answer is displayed, along with an image. Nice!
Code: (Select All)
'Verschachtelte Recordarrays - 7./10. Maerz 2026
Screen _NewImage(550, 390, 32)
$Color:32
Option _Explicit
Type Automodelle
Modell As String
Hubraum As String
Leistung As String
End Type
Type Datenblatt
Modelldaten As Automodelle
Farbe As String
FarbeBrilliant As String
Verbrauch As String
Tankgroesse As String
Preis As String
End Type
Type Spezielles
Extra As Datenblatt
Sonderausstattung As String
End Type
Dim Modell(5) As Datenblatt
Dim Special(2) As Spezielles
Dim As String ps
Dim As Long Bild
Locate 2, 3
Input "Modell : ", Modell(1).Modelldaten.Modell
Locate 3, 3
Input "Hubraum in ccm : ", Modell(1).Modelldaten.Hubraum
Locate 4, 3
Input "Motorleistung Kw : ", Modell(1).Modelldaten.Leistung
Locate 5, 3
Input "Farbauswahl : ", Modell(1).Farbe
Locate 6, 3
Input "Farbe brilliant Ja/Nein: ", Special(1).Extra.FarbeBrilliant
Sleep 2
Cls
Locate 2, 3
Print "Ihre Auswahl war:"
Locate 4, 3
Print "Modell : "; Modell(1).Modelldaten.Modell
Locate 5, 3
Print "Hubraum : "; Modell(1).Modelldaten.Hubraum; " ccm"
Locate 6, 3
'KW auch als PS ausgeben
ps = Str$(Val(Modell(1).Modelldaten.Leistung) * 1.36)
Print "Motorleistung: "; Modell(1).Modelldaten.Leistung; " Kw"; " ("; ps; " PS )"
Locate 7, 3
Print "Farbauswahl : "; Modell(1).Farbe
Locate 9, 3
If Special(1).Extra.FarbeBrilliant = "Ja" Then
Modell(1).Preis = "52.899.00"
Print "Preis Ihrer Modellauswahl: "; Modell(1).Preis
Else
Modell(1).Preis = "49.500.00"
Print "Preis Ihrer Modellauswahl: "; Modell(1).Preis
End If
Bild = _LoadImage("..\..\..\Bilder\AudiS3-Kl.jpg") 'Siehe Hinweis unten um das Bild zu erhalten
_PutImage (20, 185), Bild 'Platzierung des Bildes. Haengt von der Fenstergroesse ab
End
Image of the answer: "No" was entered.
Posts: 515
Threads: 65
Joined: May 2022
Reputation:
84
Yesterday, 08:02 PM
(This post was last modified: Yesterday, 08:03 PM by Petr.)
Would a functional 1D array within an array be enough to start with? It seems to work properly. I haven't tried higher versions yet. I'm just using all the available options. That's all. But this needs to be tested deeply, use would be at your own risk, it's not an official development branch, it's a modified version of 4.4.0 x86 and the tests were only done on Windows. Of course, I put this together with AI.
patched version: https://drive.google.com/file/d/1ueTungC...drive_link
was changed: https://drive.google.com/file/d/1YWAhFdz...drive_link
Posts: 495
Threads: 41
Joined: Apr 2022
Reputation:
40
@Petr
access denied on first link
Posts: 515
Threads: 65
Joined: May 2022
Reputation:
84
@Jack access repaired, try again
Posts: 495
Threads: 41
Joined: Apr 2022
Reputation:
40
thank you Petr 
off to testing
Posts: 495
Threads: 41
Joined: Apr 2022
Reputation:
40
Petr
this simple test run OK
Code: (Select All)
_Title "simple_test"
$Console:Only
_Dest _Console
Option _Explicit
Type mytype
m( 10) As Long
End Type
Dim x As mytype
Dim As Long i
For i = 0 To 10
x.m(i) = i
Next
For i = 0 To 10
Print x.m(i)
Next
I am going to modify my decfloat stuff which uses arrays in udts a lot, so I can determine the performance and stability of your QB64, the modifications will take quite a bit of time but as soon as it's done and run some tests I will post the results here
Posts: 515
Threads: 65
Joined: May 2022
Reputation:
84
OK, I'll be glad. Now I'm already trying to extend to multi-element arrays in an array.
I also tried _Preserve operations (increase or decrease), GET, PUT, Erase, Redim. Everything behaved correctly.
Posts: 165
Threads: 20
Joined: Apr 2022
Reputation:
20
Can it do something like :
Code: (Select All)
_Title "simple_test"
$Console:Only
_Dest _Console
Option _Explicit
Type mytype
m( 10) As Long
End Type
Dim x(10) As mytype
Dim As Long i,j
For j = 0 To 10
For i = 0 To 10
x(j).m(i) = i
Next
Next
For j = 0 To 10
For i = 0 To 10
Print x(j).m(i)
Next
Next
If so, that would be great. I've been hoping for that for years.
|