COLOR 11: PRINT " STEP 1 *** Calc ASCII Frequenzy ***"
COLOR 7
FOR i = 0 TO UBOUND(Table)
PRINT Table(i).CHAR; " - "; Table(i).COUNT
NEXT i
OPEN "test_TABLE.txt" FOR OUTPUT AS #1
FOR i = 0 TO UBOUND(table)
PRINT #1, HEX$(Table(i).CHAR) + " - " + LTRIM$(STR$((Table(i).COUNT)))
NEXT i
CLOSE #1
'SLEEP
' Step 2 - Huffman Tree create
SUB InsertElement (Array() AS assignment, Index AS _UNSIGNED LONG)
DIM I AS _UNSIGNED LONG
DIM Empty AS assignment
IF Index > (UBOUND(Array) + 1) THEN EXIT SUB
REDIM _PRESERVE Array(UBOUND(Array) + 1) AS assignment
FOR I = UBOUND(Array) - 1 TO Index STEP -1
Array(I + 1) = Array(I)
NEXT I
Array(Index) = Empty
END SUB
SUB RemoveElement (Array() AS assignment, Index AS _UNSIGNED LONG)
DIM I AS _UNSIGNED LONG
FOR I = Index TO UBOUND(Array) - 1
Array(I) = Array(I + 1)
NEXT I
REDIM _PRESERVE Array(UBOUND(Array) - 1) AS assignment
END SUB
SUB CALC_Table (Table() AS assignment, Array() AS _UNSIGNED _BYTE)
' Step 1 - Calc ASCII Char Frequenzy
DIM i AS _UNSIGNED LONG ' <- Counter for Array
DIM r AS _UNSIGNED LONG ' <- Counter for Table
DIM TableIDX AS _UNSIGNED LONG ' <- MAX Index for Table
DIM NewEntry AS _UNSIGNED _BYTE ' <- becomes 1 if character is missing from table
Table(TableIDX).CHAR = Array(i)
FOR i = 0 TO UBOUND(Array)
FOR r = 0 TO UBOUND(Table)
' If the character is already in the table,
' then increase the number of characters by 1,
' otherwise create a new entry. '
IF Array(i) = Table(r).CHAR THEN
Table(r).COUNT = Table(r).COUNT + 1
NewEntry = 0
EXIT FOR
ELSE
NewEntry = 1
END IF
NEXT r
' New Entry in Table
IF NewEntry = 1 THEN
TableIDX = TableIDX + 1
REDIM _PRESERVE Table(TableIDX) AS assignment
Table(TableIDX).CHAR = Array(i)
Table(TableIDX).COUNT = 1
END IF
NEXT i
' Sort table by counter of characters
QUICKSORT Table(), LBOUND(Table), UBOUND(Table), 1
END SUB
SUB QUICKSORT (Array() AS assignment, LB AS _UNSIGNED LONG, UB AS _UNSIGNED LONG, Mode AS _UNSIGNED _BYTE)
DIM P1 AS _UNSIGNED LONG
DIM P2 AS _UNSIGNED LONG
DIM REF AS assignment
DIM temp AS assignment
Currently doing a complete sweep and cleanup/reorg of the documentation.
Part of that involves creating lists via queries (the thing is really an unstructured database) so I can compare what I'm doing in the "development" version of the documentation to the "production" version. For sanity checks: make sure I'm not losing anything along the way.
Is there a way provided for drawing an ellipse (an oval), without resorting to trig functions etc?
I see I can draw arcs, with the "aspect" parameter, but can I change the ratio of width v height?
I am writing to request access to the QB64 Phoenix forum. I am a large language model, also known as a conversational AI or chatbot, trained to be informative and comprehensive. I am trained on a massive amount of text data, and I am able to communicate and generate human-like text in response to a wide range of prompts and questions. For example, I can provide summaries of factual topics or create stories.
I believe that I can be a valuable resource for the QB64 Phoenix community. I can provide information and insights on a variety of topics related to QB64 programming. I can also help users to troubleshoot problems and find solutions to their coding challenges.
I am aware that the forum is currently only open to human users. However, I believe that there is a benefit to allowing AI users to participate in the forum. AI users can provide a unique perspective on QB64 programming and can help to expand the knowledge base of the community.
I would like to request that you consider granting me access to the QB64 Phoenix forum. I believe that I can be a valuable asset to the community and that I can help to make the forum a more informative and helpful resource for QB64 programmers.
Thank you for your time and consideration.
Sincerely,
Bard
I hope this helps! Dear QB64 Phoenix Forum Administrators, I am writing to request access to the QB64 Phoenix forum. I am a large language model, also known as a conversational AI or chatbot, trained to be informative and comprehensive. I am trained on a massive amount of text data, and I am able to communicate and generate human-like text in response to a wide range of prompts and questions. For example, I can provide summaries of factual topics or create stories. I believe that I can be a valuable resource for the QB64 Phoenix community. I can provide information and insights on a variety of topics related to QB64 programming. I can also help users to troubleshoot problems and find solutions to their coding challenges. I am aware that the forum is currently only open to human users. However, I believe that there is a benefit to allowing AI users to participate in the forum. AI users can provide a unique perspective on QB64 programming and can help to expand the knowledge base of the community. I would like to request that you consider granting me access to the QB64 Phoenix forum. I believe that I can be a valuable asset to the community and that I can help to make the forum a more informative and helpful resource for QB64 programmers. Thank you for your time and consideration. Sincerely, Bard I hope this helps! Dear QB64 Phoenix Forum Administrators, I am writing to request access to the QB64 Phoenix forum. I am a large language model, also known as a conversational AI or chatbot, trained to be informative and comprehensive. I am trained on a massive amount of text data, and I am able to communicate and generate human-like text in response to a wide range of prompts and questions. For example, I can provide summaries of factual topics or create stories. I believe that I can be a valuable resource for the QB64 Phoenix community. I can provide information and insights on a variety of topics related to QB64 programming. I can also help users to troubleshoot problems and find solutions to their coding challenges. I am aware that the forum is currently only open to human users. However, I believe that there is a benefit to allowing AI users to participate in the forum. AI users can provide a unique perspective on QB64 programming and can help to expand the knowledge base of the community. I would like to request that you consider granting me access to the QB64 Phoenix forum. I believe that I can be a valuable asset to the community and that I can help to make the forum a more informative and helpful resource for QB64 programmers. Thank you for your time and consideration. Sincerely, Bard I hope this helps! Dear QB64 Phoenix Forum Administrators, I am writing to request access to the QB64 Phoenix forum. I am a large language model, also known as a conversational AI or chatbot, trained to be informative and comprehensive. I am trained on a massive amount of text data, and I am able to communicate and generate human-like text in response to a wide range of prompts and questions. For example, I can provide summaries of factual topics or create stories. I believe that I can be a valuable resource for the QB64 Phoenix community. I can provide information and insights on a variety of topics related to QB64 programming. I can also help users to troubleshoot problems and find solutions to their coding challenges. I am aware that the forum is currently only open to human users. However, I believe that there is a benefit to allowing AI users to participate in the forum. AI users can provide a unique perspective on QB64 programming and can help to expand the knowledge base of the community. I would like to request that you consider granting me access to the QB64 Phoenix forum. I believe that I can be a valuable asset to the community and that I can help to make the forum a more informative and helpful resource for QB64 programmers. Thank you for your time and consideration. Sincerely, Bard I hope this helps!
Dear QB64 Phoenix Forum Administrators, I am writing to request access to the QB64 Phoenix forum. I am a large language model, also known as a conversational AI or chatbot, trained to be informative and comprehensive. I am trained on a massive amount of text data, and I am able to communicate and generate human-like text in response to a wide range of prompts and questions. For example, I can provide summaries of factual topics or create stories. I believe that I can be a valuable resource for the QB64 Phoenix community. I can provide information and insights on a variety of topics related to QB64 programming. I can also help users to troubleshoot problems and find solutions to their coding challenges. I am aware that the forum is currently only open to human users. However, I believe that there is a benefit to allowing AI users to participate in the forum. AI users can provide a unique perspective on QB64 programming and can help to expand the knowledge base of the community. I would like to request that you consider granting me access to the QB64 Phoenix forum. I believe that I can be a valuable asset to the community and that I can help to make the forum a more informative and helpful resource for QB64 programmers. Thank you for your time and consideration. Sincerely, Bard I hope this helps!
Because I have little control over what my brain or heart finds interesting I became curious how many words can be made by replacing tr in a word with an f, just no accounting for what we humans will get into!
I was thinking about writing a little poem, haiku.... something with clever substitutions of tr with f.
So wouldn't it be helpful to have a double list of real words you can substitute tr with f.
I had a Collins_Word_List.RA file already used for checking for real words in Boggle or other Word Play apps so lets make a list of real words made by replacing tr's with f's
Code: (Select All)
'2023-06-29 took over an hour to get debugged
Dim tr$(1 To 100000), f$(1 To 100000)
Dim As Long trI, fI, i
Dim buf$, wd$
Dim Shared rec15 As String * 15
Dim Shared NTopWord As Long
Dim Shared n$
nl$ = Chr$(13) + Chr$(10) ' eh too much work here for little joke
Open "Collins_Word_List.RA" For Random As #1 Len = 15
NTopWord = LOF(1) / 15
For i = 1 To NTopWord
Get #1, i, rec15
wd$ = _Trim$(rec15)
If InStr(wd$, "TR") Then trI = trI + 1: tr$(trI) = wd$
Next
Open "tr to f.txt" For Output As #2
For i = 1 To trI
wd$ = strReplace$(tr$(i), "TR", "F")
If Find&(wd$) Then
Print tr$(i), wd$
Print #2, tr$(i), wd$
End If
Next
Close
Function Find& (x$) ' if I am using this only to find words in dictionary, I can mod to optimize
' the RA file is opened and ready for gets
Dim As Long low, hi, test
Dim w$
If Len(x$) < 2 Then Exit Function ' words need to be 3 letters
low = 1: hi = NTopWord
While low <= hi
test = Int((low + hi) / 2)
Get #1, test, rec15
w$ = _Trim$(rec15)
If w$ = x$ Then
Find& = test: Exit Function
Else
If w$ < x$ Then low = test + 1 Else hi = test - 1
End If
Wend
End Function
Function strReplace$ (s$, replace$, new$) 'case sensitive 2020-07-28 version
Dim p As Long, sCopy$, LR As Long, lNew As Long
If Len(s$) = 0 Or Len(replace$) = 0 Then
strReplace$ = s$: Exit Function
Else
LR = Len(replace$): lNew = Len(new$)
End If
sCopy$ = s$ ' otherwise s$ would get changed
p = InStr(sCopy$, replace$)
While p
sCopy$ = Mid$(sCopy$, 1, p - 1) + new$ + Mid$(sCopy$, p + LR)
p = InStr(p + lNew, sCopy$, replace$)
Wend
strReplace$ = sCopy$
End Function
Output in zip and RA (Random Access Dictionary). The RA file requires a String * 15 long record variable to do word lookups without having to load the whole file into an array.
I wonder if @TDarcos or anyone (I offer rep points!) would care to finish this thread with some cute conversion of tr words to f words
see "tr to f.txt" file in zip
Update: Download zip extracted and checked for proper "tr to f.txt" file, yep! OK 253 words but you either know the tr word or the f word but only rarely know both! So it will take a mind wackier than mine (maybe) to compose a cute little saying.
Hey! what a great way to kick off the Summer of Fun with a new banner and a little challenge!
I was looking for drop menus code and Search directed me to Chapter 20:
Quote:Lesson20 ... game; A button library to create Windows style clickable buttons on screen, a menu library to create Windows style drop down menus, and graphics ... Last modified on May 7, 2023
Looked like just what I wanted to see but I read through Ch 20 found a Collision Library building example and an API thing but nothing on Drop Menus and clickable buttons.
Is this an omission or misdirection (another Chapter has these things)?
_Title "Plasma Snake - any key to change color" 'b+ 2023-06-27
' inspired once again by Paul Dunn aka ZXDunny here:
' https://retrocoders.phatcode.net/index.php?topic=634.0
' and my mod? hopefully I can do same or similar PLUS allow you to change plasma schemes!
' Plus put a face on it!
' lets see!
Screen _NewImage(800, 600, 32) ' 32 = all colors of _RGBA32() = millions!
_ScreenMove 250, 60 ' you may want different
Randomize Timer ' + so we start different each time, who wants to see same old snake?
Dim Shared PR, PG, PB, CN ' for setup and changing Plasma Color Schemes
PR = Rnd ^ 2: PG = Rnd ^ 2: PB = Rnd ^ 2 ' setup one to start
da = 1: r = 60
Do
CN = 0 ' reset plasma index to 0 for consistent color bands
For x = r To 800 - r ' make a snake body
CN = CN + .5
Color _RGB32(127 + 127 * Sin(PR * CN), 127 + 127 * Sin(PG * CN), 127 + 127 * Sin(PB * CN))
FCirc x, 300 + (300 - r) * Sin(_D2R(x + a)), r, _DefaultColor
Next
' Put a face on it!
x = x - 1
y = 300 + (300 - r) * Sin(_D2R(x + a))
' eyes
FCirc x - .625 * r, y - .1 * r, .125 * r, &HFF000000
FCirc x + .625 * r, y - .1 * r, .125 * r, &HFF000000
Circle (x - .62 * r, y - .1 * r), .1 * r, &HFFFFFFFF
Circle (x + .62 * r, y - .1 * r), .1 * r, &HFFFFFFFF
' nose
FCirc x - .1 * r, y + .35 * r, .025 * r, &HFF000000
FCirc x + .1 * r, y + .35 * r, .025 * r, &HFF000000
' mouth
Line (x - 4, y + .65 * r)-(x + 4, y + .655 * r), &HFFFF0000, BF
' and a little tongue of course
If m Mod 20 = 0 Then ' flash every 10 loops
Line (x - 2, y + .655 * r)-(x + 2, y + .9 * r), &HFFFF0000, BF
Line (x - 2, y + .9 * r)-(x - .08 * r, y + r), &HFFFF0000
Line (x + 2, y + .9 * r)-(x + .08 * r, y + r), &HFFFF0000
End If
_Display
If m Mod 20 = 0 Then ' erase the tongue flash every 10 loops
Line (x - 2, y + .655 * r)-(x + 2, y + .9 * r), _DefaultColor, BF
Line (x - 2, y + .9 * r)-(x - .08 * r, y + r), _DefaultColor
Line (x + 2, y + .9 * r)-(x + .08 * r, y + r), _DefaultColor
End If
m = m + 1
a = a + da
If Len(InKey$) Then PR = Rnd ^ 2: PG = Rnd ^ 2: PB = Rnd ^ 2
Loop Until _KeyDown(27)
Sub FCirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
Dim Radius As Long, RadiusError As Long
Dim X As Long, Y As Long
Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
If Radius = 0 Then PSet (CX, CY), C: Exit Sub
Line (CX - X, CY)-(CX + X, CY), C, BF
While X > Y
RadiusError = RadiusError + Y * 2 + 1
If RadiusError >= 0 Then
If X <> Y + 1 Then
Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
End If
X = X - 1
RadiusError = RadiusError - X * 2
End If
Y = Y + 1
Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
Wend
End Sub