Posts: 3,978
Threads: 177
Joined: Apr 2022
Reputation:
220
BTW no word from our guy "l" but MS Outlook has seen fit to reclassify my Bank Statement as junk mail. Sure, to them it probably is.
b = b + ...
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
Well now that Mark's established it's his fault for this turning into a political thing, let's continue...
https://qb64phoenix.com/forum/showthread...5#pid29905
Posts: 3,978
Threads: 177
Joined: Apr 2022
Reputation:
220
Mr l has replied and is rewriting code comments into English from Spanish and sending later.
b = b + ...
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
11-16-2024, 08:33 PM
(This post was last modified: 11-16-2024, 08:37 PM by Pete.)
Good, because we're not going to see Pete's Handy Dandy Spanish REM to English REM utility anytime pronto.
+1 for successful phishing expedition. You are now tied with Steve, amazing.
Pete
Posts: 3,978
Threads: 177
Joined: Apr 2022
Reputation:
220
Wow thanks Pete, well he's still first in my book.
I sent a sample RA setup using UDT's here it is for you guys to follow along. It was likely posted here before:
Code: (Select All) _Title "UDT to Random Access File Test" ' b+ 2021-12-24
Type Image
As String * 255 Text, FileName
As Long SzX, SzY, PosX, PosY
End Type
Const SW = 1000, SH = 700
ReDim As Image TheItem(1 To 100), TheRecord
TheItem(1).Text = FakeText$(255)
TheItem(1).FileName = FakeText$(255)
Print TheItem(1).Text
Print Len(TheItem(1).Text)
Print TheItem(1).FileName
Print Len(TheItem(1).FileName)
Print "zzz"
Sleep
'make fake data to file
For i = 1 To 100
TheItem(i).Text = FakeText$(255)
TheItem(i).SzX = 100 + Rnd * 20
TheItem(i).SzY = 70 + Rnd * 14
TheItem(i).PosX = Rnd * (SW - TheItem(i).SzX)
TheItem(i).PosY = Rnd * (SH - TheItem(i).SzY)
TheItem(i).FileName = FakeText$(255)
Next
Open "Data Dump.RA" For Random As #1 Len = Len(TheRecord)
For i = 1 To 100
'odious and tedious is this
TheRecord.Text = TheItem(i).Text
TheRecord.SzX = TheItem(i).SzX
TheRecord.SzY = TheItem(i).SzY
TheRecord.PosX = TheItem(i).PosX
TheRecord.PosY = TheItem(i).PosY
TheRecord.FileName = TheItem(i).FileName
Put #1, , TheRecord
Next
Close #1
Print "Data File Ready"
' OK we got data filed! Now can we get it back
Open "Data Dump.RA" For Random As #1 Len = Len(TheRecord)
For i = 1 To 100
Cls
Get #1, i, TheRecord
Print "Record Number:"; i
Print "Text: "; TheRecord.Text
Print "SzX:"; TheRecord.SzX
Print "SzY:"; TheRecord.SzY
Print "PosX:"; TheRecord.PosX
Print "PosY:"; TheRecord.PosY
Print "FileName:"; TheRecord.FileName
Print " zzz..."
Sleep
Next
Close #1
Function FakeText$ (lengthh)
BlankString$ = Space$(lengthh)
fini = Int(Rnd * 255) + 1
For i = 1 To fini
Mid$(BlankString$, i, 1) = Chr$(Rnd * (96 - 32) + 32)
Next
FakeText$ = BlankString$
End Function
I was thinking, hoping, we go through some theory and practice and he could work out the details in applying to his particular code but there is sure to be an unrelated detail to snag the transition.
b = b + ...
Posts: 346
Threads: 24
Joined: Jul 2022
Reputation:
20
Hi
I liked to post a my 2cent demo on UDT and Random File for database...
Code: (Select All)
Rem demo of UDT database
Rem #defining UDT, #array of UDT, #creating reading overwriting RANDOM file
Rem #reading array in one shot, #managing file, #handle runtime error
Rem #using Global subroutines, #console mode output, #formatting output text
Type MyRecord
i As Integer
s As Single
sS As String * 10
leng As Long
End Type
Dim MioRecord(1 To 9) As MyRecord
Cls , 1
GoSub MakeDataFile
Cls , 2
GoSub ReadDataFile
Cls , 3
GoSub ShowDataOnRequest
Cls , 1
Print " Quitting"
End
PrintDataOnScreen:
Cls , 4
Print " Record number " + ss$
Print
Print "Miorecord.i = "; MioRecord(Val(ss$)).i
Print "Miorecord.s = "; MioRecord(Val(ss$)).s
Print "Miorecord.sS = "; MioRecord(Val(ss$)).sS
Print "Miorecord.leng = "; MioRecord(Val(ss$)).leng
Print
GoSub WaitAKeyPressed
Return
ShowDataOnRequest:
ss$ = ""
While ss$ <> "Q"
Locate 1, 1
Print "Press 1 to 9 for see data in choosen record"
ss$ = UCase$(InKey$)
If InStr("123456789", ss$) > 0 And ss$ <> "" Then GoSub PrintDataOnScreen
' remember to avoid to search a null string using INSTR otherwise you'll get a logical bug
Wend
Return
ReadDataFile:
If _FileExists(NomeFile$) Then Print "File already on disc, we read it!" Else Print "File not found, operation failed!"
On Error GoTo Failure
numfile = FreeFile
Open NomeFile$ For Random As #numfile Len = Len(MioRecord())
Get #numfile, , MioRecord() ' <-- one step to get data of an array!The old way need a FOR or WHILE NOT EOF() loop
Close #numfile
Print "Read data from random file"
GoSub WaitAKeyPressed
Return
MakeDataFile:
NomeFile$ = "DummyDat.dat"
If _FileExists(NomeFile$) Then Print "File already on disc, we overwrite it!" Else Print "File not found, we create it!"
numfile = FreeFile
Open NomeFile$ For Random As #numfile Len = Len(MioRecord())
For a% = 1 To 9 Step 1
MioRecord(a%).i = a%
MioRecord(a%).s = a% / 10
MioRecord(a%).sS = Str$(a%)
MioRecord(a%).leng = Len(MioRecord(a%).sS)
Rem Put #numfile, , MioRecord(a%) <-- this is the old way to store data each record a time
Next a%
Put #numfile, , MioRecord()
Close #numfile
Print "Data file made"
GoSub WaitAKeyPressed
Return
WaitAKeyPressed:
Print "waiting a keypressed"
Do: s$ = InKey$: Loop Until s$ <> ""
Return
Failure:
Cls , 5
Color 30, 2
Print " System Failure! Data file not found!" + Chr$(13) + "Now Quitting"
End
Return
it follows the old fashion of GOSUB and GOTO but each GOSUB / RETURN can be switched into a SUB/END SUB with the right parameters.
While ON ERROR GOTO cannot be converted into modern Subroutine.
It shows the difference between Qbasic/QB45 and QB64pe: the news is that you can save and read a whole array to/from file in QB64pe.
Posts: 3,978
Threads: 177
Joined: Apr 2022
Reputation:
220
Back in the day, Random access, RA, files took place of need to create an array for the file.
The file acted as the array you could read/write to, so changes were made directly without UDT array which we didn't have then anyway, though we had "fields".
I am starting to wonder if RA is best way to go these days. The longer you have the file open while processing, the more likely an error to occur eg a crash causing data corruption.
Now that we do have UDT arrays, just load the file data into it and process from that then when done rewrite the data file.
RA's are also nice if data file is HUGE! too big for UDT array?
b = b + ...
Posts: 1,002
Threads: 50
Joined: May 2022
Reputation:
27
Is the person in need of help still busy translating? It must be a tremendous text!
Posts: 346
Threads: 24
Joined: Jul 2022
Reputation:
20
What can produce Chatgpt for this task?
It would be interesting... but I have no registration to use Chatgpt, I'll do the next time.
PS: the person in need is always here hanging around or he has gone away?
Posts: 3,978
Threads: 177
Joined: Apr 2022
Reputation:
220
No word yet from Mr "l", maybe with review of code for translation and my demo of setting up reading writing to RA was all the help he needed? Hmm... how often does that happen? I won't say never but rare...
b = b + ...
|