Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 492
» Latest member: Feederumn
» Forum threads: 2,833
» Forum posts: 26,548

Full Statistics

Latest Threads
Another Dir/File compare ...
Forum: Utilities
Last Post: eoredson
6 hours ago
» Replies: 0
» Views: 28
Problems with QBJS
Forum: Help Me!
Last Post: hsiangch_ong
8 hours ago
» Replies: 3
» Views: 72
another variation of "10 ...
Forum: Programs
Last Post: hsiangch_ong
8 hours ago
» Replies: 2
» Views: 94
sleep command in compiler...
Forum: General Discussion
Last Post: Pete
11 hours ago
» Replies: 1
» Views: 50
Aloha from Maui guys.
Forum: General Discussion
Last Post: madscijr
Yesterday, 04:33 PM
» Replies: 8
» Views: 145
which day of the week
Forum: Programs
Last Post: Pete
Yesterday, 03:32 PM
» Replies: 29
» Views: 639
Playing sound files in QB...
Forum: Programs
Last Post: ahenry3068
Yesterday, 05:37 AM
» Replies: 9
» Views: 1,188
Rock Jockey 2.0 is ready ...
Forum: Games
Last Post: NakedApe
01-09-2025, 09:02 PM
» Replies: 20
» Views: 622
Button rack or hotkey fun...
Forum: Utilities
Last Post: Jack002
01-09-2025, 08:20 PM
» Replies: 6
» Views: 405
ANSIPrint
Forum: a740g
Last Post: bplus
01-09-2025, 05:36 PM
» Replies: 11
» Views: 225

 
  Get Disk Drive Capacity
Posted by: BDS107 - 07-03-2023, 04:30 PM - Forum: Help Me! - Replies (14)

Hi,
Years ago when I wrote assembler in GWBASIC or QuickBASIC there was INT &H21 to see how much free space you have left on the disk.
See also https://ftp.zx.net.nz/pub/archive/ftp.mi...46/980.HTM
Is there such a thing for QB64-PE with modern PC's like Windows 7 and up??

In C something like this? https://learn.microsoft.com/en-us/dotnet...ew=net-7.0

Print this item

  Either QB64pe enhancement or IDGI
Posted by: doppler - 07-03-2023, 02:26 PM - Forum: General Discussion - Replies (7)

After some thought (always bad for me), Either this will become a QB64pe enhancement or I Don't Get It.

I use drop files a lot since implemented a couple releases ago (v1.3).  It's easy to use and setup.  A couple of commands and your program can take a list of files dropped on a window.  I want to take to the next level.

Drop them on the desktop icon link.!  And process them.  This a hidden feature (or not well known) in Microsoft windows.  I read through the program doc's again.  Not clear if it is already implemented.

Let the fun begin....

Print this item

  Circles and Ellipses(Tilt and Fill)
Posted by: SMcNeill - 07-03-2023, 07:30 AM - Forum: SMcNeill - Replies (1)

Code optimized for QB64PE which we came up with several years back as a community.  I thought I'd share it here, in case anyone ever needed it or wanted to make use of it again in the future.

Code: (Select All)

Screen _NewImage(800, 600, 32)

Dim TransRed As _Unsigned Long
Dim TransGreen As _Unsigned Long
Dim TransBlue As _Unsigned Long
TransRed = _RGBA(255, 0, 0, 128)
TransGreen = _RGBA(0, 255, 0, 128)
TransBlue = _RGBA(0, 0, 255, 128)

Call CircleFill(100, 100, 75, TransRed)
Call CircleFill(120, 120, 75, TransBlue)

Call EllipseFill(550, 100, 150, 75, TransBlue)
Call EllipseFill(570, 120, 150, 75, TransGreen)

Call EllipseTilt(200, 400, 150, 75, 0, TransGreen)
Call EllipseTilt(220, 420, 150, 75, 3.14 / 4, TransRed)

Call EllipseTiltFill(0, 550, 400, 150, 75, 3.14 / 6, TransRed)
Call EllipseTiltFill(0, 570, 420, 150, 75, 3.14 / 4, TransGreen)

End

Sub CircleFill (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    ' CX = center x coordinate
    ' CY = center y coordinate
    '  R = radius
    '  C = fill color
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    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

Sub EllipseFill (CX As Integer, CY As Integer, a As Integer, b As Integer, C As _Unsigned Long)
    ' CX = center x coordinate
    ' CY = center y coordinate
    '  a = semimajor axis
    '  b = semiminor axis
    '  C = fill color
    If a = 0 Or b = 0 Then Exit Sub
    Dim h2 As _Integer64
    Dim w2 As _Integer64
    Dim h2w2 As _Integer64
    Dim x As Integer
    Dim y As Integer
    w2 = a * a
    h2 = b * b
    h2w2 = h2 * w2
    Line (CX - a, CY)-(CX + a, CY), C, BF
    Do While y < b
        y = y + 1
        x = Sqr((h2w2 - y * y * w2) \ h2)
        Line (CX - x, CY + y)-(CX + x, CY + y), C, BF
        Line (CX - x, CY - y)-(CX + x, CY - y), C, BF
    Loop
End Sub

Sub EllipseTilt (CX, CY, a, b, ang, C As _Unsigned Long)
    '  CX = center x coordinate
    '  CY = center y coordinate
    '  a = semimajor axis
    '  b = semiminor axis
    ' ang = clockwise orientation of semimajor axis in radians (0 default)
    '  C = fill color
    For k = 0 To 6.283185307179586 + .025 Step .025
        i = a * Cos(k) * Cos(ang) + b * Sin(k) * Sin(ang)
        j = -a * Cos(k) * Sin(ang) + b * Sin(k) * Cos(ang)
        i = i + CX
        j = -j + CY
        If k <> 0 Then
            Line -(i, j), C
        Else
            PSet (i, j), C
        End If
    Next
End Sub

Sub EllipseTiltFill (destHandle&, CX, CY, a, b, ang, C As _Unsigned Long)
    '  destHandle& = destination handle
    '  CX = center x coordinate
    '  CY = center y coordinate
    '  a = semimajor axis
    '  b = semiminor axis
    ' ang = clockwise orientation of semimajor axis in radians (0 default)
    '  C = fill color
    Dim max As Integer, mx2 As Integer, i As Integer, j As Integer
    Dim prc As _Unsigned Long
    Dim D As Integer, S As Integer
    D = _Dest: S = _Source
    prc = _RGB32(255, 255, 255, 255)
    If a > b Then max = a + 1 Else max = b + 1
    mx2 = max + max
    tef& = _NewImage(mx2, mx2)
    _Dest tef&
    _Source tef&
    For k = 0 To 6.283185307179586 + .025 Step .025
        i = max + a * Cos(k) * Cos(ang) + b * Sin(k) * Sin(ang)
        j = max + a * Cos(k) * Sin(ang) - b * Sin(k) * Cos(ang)
        If k <> 0 Then
            Line (lasti, lastj)-(i, j), prc
        Else
            PSet (i, j), prc
        End If
        lasti = i: lastj = j
    Next
    Dim xleft(mx2) As Integer, xright(mx2) As Integer, x As Integer, y As Integer
    For y = 0 To mx2
        x = 0
        While Point(x, y) <> prc And x < mx2
            x = x + 1
        Wend
        xleft(y) = x
        While Point(x, y) = prc And x < mx2
            x = x + 1
        Wend
        While Point(x, y) <> prc And x < mx2
            x = x + 1
        Wend
        If x = mx2 Then xright(y) = xleft(y) Else xright(y) = x
    Next
    _Dest destHandle&
    For y = 0 To mx2
        If xleft(y) <> mx2 Then Line (xleft(y) + CX - max, y + CY - max)-(xright(y) + CX - max, y + CY - max), C, BF
    Next
    _Dest D: _Dest S
    _FreeImage tef&
End Sub

Print this item

  BAM: Keyboard Input Issues Fixed
Posted by: CharlieJV - 07-02-2023, 04:16 PM - Forum: QBJS, BAM, and Other BASICs - No Replies

https://basicanywheremachine-news.blogsp...fixed.html

Print this item

  Problem with creating a Huffman code tree
Posted by: SagaraS - 07-01-2023, 09:48 PM - Forum: Help Me! - Replies (10)

Hello,

I started to write a code to read, count and sort a byte array.

Now I want to take the next step, but I don't know how to start exactly by creating a Huffman code tree with QB64 syntax.

I don't want a C or C++ solution, I want a QB64 solution for it.

Here is my current code:

In the 'test.txt' stand an example like 'aaavvrijgtmmspoe'
The file input can be anything. So all bytes should be considered from 0 to 255.

Code: (Select All)
'Huffman Encoding

TYPE assignment
  CHAR AS _UNSIGNED _BYTE '<-- ASCII Character
  COUNT AS _UNSIGNED LONG '<-- Frequenzy of ASCII Chars (Counter)
END TYPE

DIM File AS STRING

File = "test.txt"

OPEN File FOR BINARY ACCESS READ AS #1
REDIM MEM(LOF(1) - 1) AS _UNSIGNED _BYTE
GET #1, , MEM()
CLOSE #1

' Step 1 - Calc ASCII Char Frequenzy
REDIM Table(0) AS assignment
CALC_Table Table(), MEM()

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

  P1 = LB
  P2 = UB
  REF.CHAR = Array((P1 + P2) \ 2).CHAR
  REF.COUNT = Array((P1 + P2) \ 2).COUNT

  DO

    SELECT CASE Mode
      CASE 0:
        DO WHILE Array(P1).CHAR < REF.CHAR
          P1 = P1 + 1
        LOOP

        DO WHILE Array(P2).CHAR > REF.CHAR
          P2 = P2 - 1
        LOOP
      CASE 1:
        DO WHILE Array(P1).COUNT < REF.COUNT
          P1 = P1 + 1
        LOOP

        DO WHILE Array(P2).COUNT > REF.COUNT
          P2 = P2 - 1
        LOOP
    END SELECT

    IF P1 <= P2 THEN
      temp = Array(P1)
      Array(P1) = Array(P2)
      Array(P2) = temp

      P1 = P1 + 1
      P2 = P2 - 1
    END IF

  LOOP WHILE P1 <= P2

  IF LB < P2 THEN CALL QUICKSORT(Array(), LB, P2, Mode)
  IF P1 < UB THEN CALL QUICKSORT(Array(), P1, UB, Mode)
END SUB

Print this item

  BAM Language Reference
Posted by: CharlieJV - 07-01-2023, 08:07 PM - Forum: QBJS, BAM, and Other BASICs - Replies (6)

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.


Work in progress (test version of documentation)

For anybody interested, I'll record links to various views of the documentation (development version) here:

Print this item

  Drawing an ellipse
Posted by: PhilOfPerth - 07-01-2023, 08:14 AM - Forum: Help Me! - Replies (26)

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?

Print this item

  Side "Fack"
Posted by: bplus - 06-30-2023, 02:45 PM - Forum: Programs - No Replies

A little side track from BSpinoza's great Expresso thread:
https://qb64phoenix.com/forum/showthread...2#pid17352

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 Smile

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!



Attached Files
.zip   tr to f words.zip (Size: 829.54 KB / Downloads: 31)
Print this item

  BAM Support in Raster Master 2.1
Posted by: CharlieJV - 06-30-2023, 02:31 PM - Forum: QBJS, BAM, and Other BASICs - Replies (5)

Pretty cool.  I am tickled silly at the mere mention of my project and/or anybody just giving it a spin.

https://www.reddit.com/r/Basic/comments/...master_21/

Print this item

  Chapter 20 Games Programming Terry's Tutorial
Posted by: bplus - 06-29-2023, 05:07 PM - Forum: General Discussion - Replies (3)

@TerryRitchie

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)?

Print this item