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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 483
» Latest member: aplus
» Forum threads: 2,795
» Forum posts: 26,349

Full Statistics

Latest Threads
_IIF limits two question...
Forum: General Discussion
Last Post: madscijr
2 hours ago
» Replies: 7
» Views: 130
GNU C++ Compiler error
Forum: Help Me!
Last Post: Cobalt
3 hours ago
» Replies: 23
» Views: 311
Mean user base makes Stev...
Forum: General Discussion
Last Post: Kernelpanic
4 hours ago
» Replies: 9
» Views: 240
What do you guys like to ...
Forum: General Discussion
Last Post: Pete
5 hours ago
» Replies: 11
» Views: 165
Fast QB64 base64 encoder ...
Forum: a740g
Last Post: a740g
Yesterday, 04:43 AM
» Replies: 3
» Views: 461
DeflatePro
Forum: a740g
Last Post: a740g
Yesterday, 02:11 AM
» Replies: 2
» Views: 74
New QBJS Samples Site
Forum: QBJS, BAM, and Other BASICs
Last Post: dbox
12-20-2024, 06:16 PM
» Replies: 25
» Views: 903
Raspberry OS
Forum: Help Me!
Last Post: Jack
12-20-2024, 05:42 PM
» Replies: 7
» Views: 165
InForm-PE
Forum: a740g
Last Post: Kernelpanic
12-20-2024, 05:22 PM
» Replies: 80
» Views: 6,198
Merry Christmas Globes!
Forum: Programs
Last Post: SierraKen
12-20-2024, 03:46 AM
» Replies: 10
» Views: 161

 
  Apple etc. compatibility
Posted by: PhilOfPerth - 03-29-2024, 11:02 PM - Forum: Help Me! - Replies (7)

This  is a pretty wide-ranging question, and I guess not many will be interested in answering it. But here goes…
My computer uses Windows 10. I’m only familiar with Windows, and have no access to other systems for testing.
I use a fairly small subset of PE for coding (no DMAs, Peeks or Pokes etc.)
I have a couple of friends with Apple systems and I’d like to share some of my progs with them, but I’m loth
to just hand them a copy and say “try this”, in case it interferes with their settings, or worse.
Are they safe to run on other systems, and will they run similarly to how they run on mine?
And if so, are there sections of PE that still should be avoided for compatibility?  (the .exe files, I mean) Undecided
 

Print this item

  Server Costs Paid for 2024/2025
Posted by: SMcNeill - 03-29-2024, 12:46 AM - Forum: Announcements - Replies (3)

Just thought I'd let all you guys know that our server costs have now been paid up thanks to the generous donations of all our wonderful users. 

   

And for those who might be curious, here's our usage details so you can see how much room for growing we have, before we have to worry about upgradding to a different plan:

   


As you can see from the above, our server is paid up for two years and the domain name and privacy junk is paid up for one year.   Next year, we'll have about a $40.00 bill to pay for the domain and privacy, as there's no discount for paying for them in advance.

Otherwise, except for that minor amount of expense, we're all paid up from now until 2026!

Print this item

  Is this STRING bug? - Not. My fail!
Posted by: Petr - 03-28-2024, 07:21 PM - Forum: Help Me! - Replies (3)

Code: (Select All)

$NoPrefix

ReDim Shared Room(1000, 1000) As Integer
Dim Shared ProjectName As String * 12 'try AS STRING * 5 ----> Out of memory bug occur here
ProjectName$ = "Test"
Type Room1D
    As Integer Sx, Ex, Sy, Ey, Typ, Draw, C, Width, Depth
    As String * 10 Name
End Type
ReDim Shared Room1(0) As Room1D

Room1(0).Sx = 20
Room1(0).Ex = 100
Room1(0).Sy = 20
Room1(0).Ey = 1000
Room1(0).Typ = 0
Room1(0).Draw = -1
Room1(0).C = 1
Room1(0).Width = 20
Room1(0).Depth = 20

ReDim _Preserve Room1(1) As Room1D

Print "Saving:"
Dim As Integer LB1, LB2, UB1, UB2
LB1 = LBound(Room, 1)
LB2 = LBound(Room, 2)
UB1 = UBound(Room, 1)
UB2 = UBound(Room, 2)
Print "Lbound nr 1 - Room :", LB1
Print "Lbound nr 2 - Room: ", LB2
Print "Ubound nr 1 - Room:", UB1
Print "Ubound nr 2 - Room:", UB2
Print "Project name string: ", ProjectName$ 'shared string variable
LB1 = LBound(Room1)
UB1 = UBound(Room1)
Print "Lbound - Room1:", LB1
Print "Ubound - Room1", UB1

If FileExists("test") Then Kill "test"

SaveRoom "test"

LoadRoom "test"
Print "---------------------------"
Print "Loaded is:"
LB1 = LBound(Room, 1)
LB2 = LBound(Room, 2)
UB1 = UBound(Room, 1)
UB2 = UBound(Room, 2)
Print "Lbound nr 1 - Room :", LB1
Print "Lbound nr 2 - Room: ", LB2
Print "Ubound nr 1 - Room:", UB1
Print "Ubound nr 2 - Room:", UB2
Print "Project name string: ", ProjectName$
LB1 = LBound(Room1)
UB1 = UBound(Room1)
Print "Lbound - Room1:", LB1
Print "Ubound - Room1", UB1




Sub LoadRoom (Project$)
    ff = FreeFile
    If _FileExists(Project$) Then
        Open Project$ For Binary As #ff
        Dim As Integer LB1, LB2, UB1, UB2
        ReDim ProjectName As String * 16
        Get #ff, , LB1
        Get #ff, , LB2
        Get #ff, , UB1
        Get #ff, , UB2
        ReDim Room(LB1 To UB1, LB2 To UB2) As Integer
        Get #ff, , Room()
        Get #ff, , ProjectName$ 'try comment this in both (loadroom and saveroom) and try again
        Get #ff, , LB1
        Get #ff, , UB1
        ReDim Room1(LB1 To UB1) As Room1D
        Get #ff, , Room1()
    Else
        errStat = _MessageBox("Error!", "File " + Project$ + " not exists.", "ok", "error", 1&)
    End If
End Sub


Sub SaveRoom (Project$)
    ff = FreeFile
    If _FileExists(Project$) Then
        errStat = _MessageBox("Error!", "File " + Project$ + " already exists. Overwrite?", "yesnocancel", "error", 2&)
        If errStat = 1 Then GoTo OverWrite
    Else
        OverWrite:
        ff = FreeFile
        Open Project$ For Binary As #ff
        Dim As Integer LB1, LB2, UB1, UB2
        LB1 = LBound(Room, 1)
        LB2 = LBound(Room, 2)
        UB1 = UBound(Room, 1)
        UB2 = UBound(Room, 2)
        Put #ff, , LB1
        Put #ff, , LB2
        Put #ff, , UB1
        Put #ff, , UB2
        Put #ff, , Room()
        Put #ff, , ProjectName$ 'try comment this in both (loadroom and saveroom) and try again
        LB1 = LBound(Room1)
        UB1 = UBound(Room1)
        Put #ff, , LB1
        Put #ff, , UB1
        Put #ff, , Room1()
    End If
End Sub


I discovered unexpected behavior in the source code provided. I save the contents of the fields with information about the size of the fields to a file and then read that information. Focus on the Room1 array size read (the last two entries). Then try changing above in the declaration DIM SHARED ProjectName AS STRING *12 to a different size *. When I entered *5, an error occurred - out of memory. When I changed it differently, the output of the read values LBOUND and UBOUND, which are written after this string in the test file, also changed.

If I disable writing and then reading ProjectName$ variable in LoadRoom and SaveRoom and then load,  everything works fine. 

Tested in QB64Pe x32 v3.12

Print this item

  Courage, Luck, or Strategy
Posted by: SMcNeill - 03-28-2024, 05:46 AM - Forum: SMcNeill - No Replies

How much money can you win??

Code: (Select All)
_Title "Courage, Luck, or Strategy?"
Screen _NewImage(1280, 720, 32)
$Color:32
Randomize Timer

Dim Shared As Long font(12 To 64), LockLevel, Chances, Betlevel
Dim Shared cash(11) As String
cash(0) = "$0": cash(1) = "$1,000": cash(2) = "$2,000"
cash(3) = "$4,000": cash(4) = "$8,000": cash(5) = "$16K"
cash(6) = "$32K": cash(7) = "$64K": cash(8) = "$128K"
cash(9) = "$256K": cash(10) = "$512K": cash(11) = "$1000000"



For i = 12 To 64
    font(i) = _LoadFont("courbd.ttf", i, "monospace")
Next

LockLevel = 0 'but you could lose it all!  Arrrghh!
Chances = 3 'but you have 3 chances to turn your fate around!
Betlevel = 1 'and you haven't made any bets with your winnings so far!

Do
    Cls , 0
    DrawProgress
    ProcessInput
    If Chances < 0 Then Quit
    _Display
    _Limit 30
Loop

Sub Quit
    Cls
    Color White, 0
    Print "You have won:"; cash(Betlevel)
End Sub

Sub ProcessInput
    Static OldMB
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY
    mb = _MouseButton(1)
    If mb And Not OldMB Then
        If my >= 500 And my <= 600 Then 'down in the control column
            Select Case mx
                Case 150 To 350 'bet
                    r = Int(Rnd * 100) + 1
                    If r < 50 Then
                        Betlevel = Betlevel + 1
                    Else
                        Betlevel = LockLevel
                        LockLevel = 0
                        Chances = Chances - 1
                    End If
                Case 400 To 600 'lock
                    If Chances > 0 And Betlevel <> LockLevel Then
                        LockLevel = Betlevel
                        Chances = Chances - 1
                    End If
                Case 650 To 850 'quit
                    Chances = -1
            End Select
        End If
    End If
    OldMB = mb
End Sub





Sub DrawProgress
    _Font font(32)
    Color Black, 0
    For y = 0 To 1
        For i = 0 To 5
            xc = i * 200 + 100: yc = 120 + 240 * y
            If y * 6 + i <= LockLevel Then
                CircleFill xc, yc, 90, Gold
            ElseIf y * 6 + i <= Betlevel Then
                CircleFill xc, yc, 90, Green
            Else
                CircleFill xc, yc, 90, Red

            End If
            _UPrintString (xc - _UPrintWidth(cash(y * 6 + i)) / 2, yc - _UFontHeight / 2), cash(y * 6 + i)
        Next
    Next
    Line (150, 500)-Step(200, 100), Red, BF
    _UPrintString (220, 534), "Bet"
    Line (400, 500)-Step(200, 100), Gold, BF
    _PrintString (420, 534), "Lock:" + Str$(Chances)
    Line (650, 500)-Step(200, 100), Green, BF
    _PrintString (710, 534), "Quit"
End Sub

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 Pause (time As _Float, exclude_code As Long)
    'exclude_code is the binary value of things we don't want to allow to break Pause
    '1 = Window lost focus
    '2= No Mouse breaking pause
    '4 - No Keyboard breaking pause
    '8 - No Keyup events break pause
    '16 - No modifier keys breaking pause (Shift/Ctrl/Alt)
    t# = Timer + time
    Do
        If time <> 0 And Timer > t# Then Exit Do
        If k <> 0 Then Exit Do
        _Limit 10 'we're a pause. We don't need to do a bunch of crap per second.
        If (exclude_code And 1) Then 'don't unpause until window has focus or time has ran out
            If _WindowHasFocus = 0 Then _Continue
        End If
        If (exclude_code And 2) = 0 Then 'mouse clicks break pause
            While _MouseInput: Wend
            If _MouseButton(1) Or _MouseButton(2) Then Exit Do
        End If
        If (exclude_code And 4) = 0 Then 'we allow keyboard input (of some sort) to break pause
            k = _KeyHit
            If (exclude_code And 8) Then If k < 0 Then k = 0 'but we don't allow keyup events to do it
            If (exclude_code And 16) Then 'here we don't allow modifier keys to do it
                Select Case k
                    Case 100304, 100303, -100304, -100303 'shift up/down
                        k = 0
                    Case 100306, 100305, -100306, -100305 'ctrl up/down
                        k = 0
                    Case 100308, 100307, -100308, -100307 'alt up/down
                        k = 0
                End Select
            End If
        End If
    Loop
End Sub

A little gambling game here, where you have a few basic options to try and sort out how to get the most reward out of your luck.

For starters, you start with $1000, which is yours to keep -- if you walk away right at this moment!

OR....

You can gamble on it, with 50/50 odds on whether you increase your pot, or not -- up to a maximum of $100000!

To add a strategy element to this little game, you can LOCK in your winnings, up to 3 times!   But the problem here is that once you bet and lose, that lock disappears, meaning you'll have to use another lock again if you want to keep your winnings safe -- and you only have a total of 3 locks in the game.

You can play as long as you have locks left, and money to bet.  Each time you bet and lose, you lose one of your locks, so you're only allowed a few failures in each game!

Now the question is:  How much money can you win?  How good is your luck, courage, and strategy??

(For the record, I suck at this type thing.  My highest winning so far has been $16,000 -- I can't even get down to the second line with my luck!  And most times, I end up winning $0.)  Big Grin

Print this item

  Smart Pause
Posted by: SMcNeill - 03-28-2024, 02:45 AM - Forum: SMcNeill - Replies (1)

Code: (Select All)
Print "A 10 second pause, with no break method"
Pause 10, -1 'this has to run for 10 seconds, and no input/process from the user will change that

Print "A 10 second pause, with ONLY mouse break early"
Pause 10, 1 + 4

Print "A pause, with no time limit, and ONLY mouse break"
Pause 0, 1 + 4

Print "A pause, no time limit, with only active window keyboard input break"
Pause 0, 1 + 2

Print "A 10 second pause, which any keypress or mouse click can break"
Pause 10, 0

Sub Pause (time As _Float, exclude_code As Long)
'exclude_code is the binary value of things we don't want to allow to break Pause
'1 = Window lost focus
'2= No Mouse breaking pause
'4 - No Keyboard breaking pause
'8 - No Keyup events break pause
'16 - No modifier keys breaking pause (Shift/Ctrl/Alt)
t# = Timer + time
Do
_Limit 10 'we're a pause. We don't need to do a bunch of crap per second.
If (exclude_code And 1) Then 'don't unpause until window has focus or time has ran out
If _WindowHasFocus = 0 Then _Continue
End If
If (exclude_code And 2) = 0 Then 'mouse clicks break pause
While _MouseInput: Wend
If _MouseButton(1) Or _MouseButton(2) Then Exit Do
End If
If (exclude_code And 4) = 0 Then 'we allow keyboard input (of some sort) to break pause
k = _KeyHit
If (exclude_code And 8) Then If k < 0 Then k = 0 'but we don't allow keyup events to do it
If (exclude_code And 16) Then 'here we don't allow modifier keys to do it
Select Case k
Case 100304, 100303, -100304, -100303 'shift up/down
_Continue
Case 100306, 100305, -100306, -100305 'ctrl up/down
_Continue
Case 100308, 100307, -100308, -100307 'alt up/down
_Continue
End Select
End If
End If
If time <> 0 And Timer > t# Then Exit Do
If k <> 0 Then Exit Do
Loop
End Sub

And here we have a customizable "Pause" routine, which allows for a few things which SLEEP doesn't.

Set it to allow mouse clicks to break pause.
Set it to allow pause to only break when the window has focus.
Remove modifier keys from the list of acceptable keys to break pause (no shift/ctrl/alt breaking pause).
Set it so that only keydown events break pause and not keyup events.
Timed events, or events without no time limit.


One thing of note: This also allows you to create your very own endless loop! Set it with no time limit for a pause, with no input allowed to break the pause, and you have permanently paused your program until you click the red "X" in the top right corner and closed it.

I really wouldn't recommend doing that, but hey, if that's your thing....

Print this item

  Linux HTTP WEB Server Issues - Large Files Fail
Posted by: old_coder - 03-27-2024, 08:33 PM - Forum: Help Me! - No Replies

New to this portal, but been coding for a while.
Tried to search for assistance but found nothing directly related to my issues - may not be asking the correct questions.
Looking for any available assistance with web services in Linux.
Created a WEB based music JukeBox (plan to release code when it is de-kluged) on my Windows machines. Works great on XP & Windows 10.
System is designed so the music playing appliance is a web server, and users can search / add to que / add to playlists via a WEB interface.
Core HTTP handling code was based on luke's simple HTTP server - nicely written and easy to expand from,
Recently added options to play music locally (download & play in the WEB browser). Works great on Windows based server, but messes up badly on Linux Based server - downloads never complete or data gets jumbled.
All WEB pages are HTML coded in text strings, assembled into packets that are downloaded to the client. I thought this works great on Linux, but testing confirmed large file HTML downloads have the same issue
Windows box is a clunker XP Pro machine (64 bit) with 2 GB ram.
Linux box is a Raspberry Pi4 with 4 GB ram.
Pi4 responds to searches 3 - 4 times faster - excellent portable JukeBox!
Every other coded function / WEB function works correct, including HTML page downloads etc AS LONG AS THE DOWNLOAD IS SMALL.
Trying to confirm if this is an error I can work around, a legitimate bug, or something I am missing
Any comments on Linux side WEB server issues will be appreciated.

Print this item

  Can this be done?
Posted by: TerryRitchie - 03-27-2024, 07:00 PM - Forum: General Discussion - Replies (6)

I recently saw a YouTube video where the presenter was using Linux to navigate around his drive. Pretty simple except something caught my eye. The Linux File Manager (Windows Explorer) had a terminal window permanently attached to the bottom of it. This allowed him to issue command prompt commands at will no matter where he is located in the file system. Genius. I've attached a quick Windows mock-up below to show what I mean.

Does anyone know if a 3rd party add-on is available for Windows that gives this functionality? I'm constantly at the command prompt. I added a Windows power tool years ago that allows me to hold down the SHIFT key and then right click on a folder. Within the list of options will be "Open command prompt here". This is handy but I would much prefer to have a persistent command window like I saw in that video.



Attached Files Thumbnail(s)
   
Print this item

Photo Phoenix illustration
Posted by: chikega - 03-27-2024, 03:26 PM - Forum: General Discussion - Replies (1)

Having fun with Dall-e  Big Grin

[Image: Phoenix-QB64.png] 
[Image: Clean-Shot-2024-03-27-at-11-25-58-2x.png]


Cheers, 
Gary

Print this item

  Happy Birthday RhoSigma!
Posted by: TerryRitchie - 03-27-2024, 04:14 AM - Forum: General Discussion - Replies (12)

Happy birthday @RhoSigma !!

Update: Oh I just noticed @Fifi too!

Happy Birthday Fifi !!

Print this item

  Made my first AI project today.
Posted by: Pete - 03-26-2024, 08:41 PM - Forum: General Discussion - Replies (3)

It's a robot golfer. So far, all I can get it to learn is to pound its club repeatedly on the ground, but that's got 90% of the people at my country club completely fooled into thinking it's a real golfer. Now if I can just get it to pee standing up. Hopefully soon. The price of oil isn't getting any cheaper.

Pete

Print this item