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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 484
» Latest member: BigDog
» Forum threads: 2,799
» Forum posts: 26,418

Full Statistics

Latest Threads
What do you guys like to ...
Forum: General Discussion
Last Post: bplus
6 minutes ago
» Replies: 14
» Views: 206
Raspberry OS
Forum: Help Me!
Last Post: Jack
2 hours ago
» Replies: 10
» Views: 196
GNU C++ Compiler error
Forum: Help Me!
Last Post: eoredson
2 hours ago
» Replies: 48
» Views: 757
Mean user base makes Stev...
Forum: General Discussion
Last Post: Pete
4 hours ago
» Replies: 25
» Views: 399
A question on using Infor...
Forum: Help Me!
Last Post: justsomeguy
5 hours ago
» Replies: 7
» Views: 118
New Message Box Library U...
Forum: Works in Progress
Last Post: Pete
5 hours ago
» Replies: 1
» Views: 30
SaucerZap
Forum: QBJS, BAM, and Other BASICs
Last Post: Pete
5 hours ago
» Replies: 6
» Views: 49
Let's Make a Wheel!
Forum: Help Me!
Last Post: Pete
5 hours ago
» Replies: 2
» Views: 27
_IIF limits two question...
Forum: General Discussion
Last Post: madscijr
Yesterday, 03:53 AM
» Replies: 9
» Views: 174
Fast QB64 base64 encoder ...
Forum: a740g
Last Post: a740g
12-21-2024, 04:43 AM
» Replies: 3
» Views: 473

 
  Stack size limit for If/Then statements?
Posted by: JamesAlexander - 01-28-2024, 10:59 PM - Forum: General Discussion - Replies (20)

Hi All,

I'm developing a program where I am implementing a lot of if/then statements to do logic, but the way it is designed, I will have to use a lot of straight logical statements. I have tried using this through DATA statements and arrays, dimension the arrays as $'DYNAMIC, etc...so I am just going the straightforward route.

A sample line for an IF / THEN statement is just this:

IF Lookahead$ = CHR$ (0) THEN G$="XXXXXXX": PUT #2 , ,G$ : G$=""

where the line has about 3 or less multi-statements, and only if they are true. Is is simple, but there are many of them. I am already using a logic tool to automate the process, that is why I cannot do it another way. The automation is simple and straightforward, at the expense of stack space because each of the statements are automatically generated and then can be used in QB64 code.
 
The kicker is, I have about 9,786 lines that I can use successfully - anything more, I will get a C++ error.

I think it has to do with the Main() sub being limited to approximately 10,000 lines or less (9,786 exactly), but am not entirely sure.

How can I increase the number of logic statements and conditionals that are outside of arrays? Is it just the stack space, or will I have to do it another way?

What are my options with this? I have tried using CLEAR, and that won't do either. Is it possible to somehow allocate a tremendous amount of stack size at the risk of very minimal variables? Or perhaps edit and recompile a modified version of Qb64Pe source code that will work for this increasing the line numbers and limits?

Thanks,
James

Print this item

  Color Extraction Developer Insights
Posted by: TerryRitchie - 01-28-2024, 06:28 AM - Forum: Help Me! - Replies (11)

I'm writing a few image manipulation routines and need them to be as fast as possible. I'm using bit manipulation to extract pixel color information like so:

(all of the variables have been declared properly beforehand)

_MEMGET m, o, p '            get pixel at offset within image memory block
a = 4278190080 AND p '  extract alpha
r = 16711680 AND p '      extract red
g = 65280 AND p '           extract green
b = 255 AND p '               get blue level (0 to 255)
a = _SHR(a, 24) '              get alpha level (0 to 255) (divide by 16777215)
r = _SHR(r, 16) '               get red level (0 to 255) (divide by 65536)
g = _SHR(g, 8) '               get green level (0 to 255) (divide by 256)

I need some insight from the developers regarding _ALPHA32(), _RED32(), _GREEN32(), and _BLUE32(). Is my bit manipulation faster than using these statements or are they handled internally using the same method (or an even faster method I'm unaware of)?

Loving the memory manipulation statements by the way. Man, have I been missing out by not using them regularly.

Print this item

  Clicker template game
Posted by: Ra7eN - 01-27-2024, 03:39 PM - Forum: Works in Progress - No Replies

I still am stuck on idle, incremental and clicker games and was curious it I could pull it off in qb64. I can!!
however got bored. Here is some starter code for someone that wants to play with it. currently it works, little buggy on display.  but hey, have fun!!

note: I use the "ADVENTURE CAPITALIST" CLICKER game for inspiration. long ways off but this is the core.

It is all thanks to this hidden gem routine:

Code: (Select All)
' Set up the timer event for game upkeep
UpdateTimer = _FREETIMER
ON TIMER(UpdateTimer, 0.5) GameUpkeep
TIMER(UpdateTimer) ON

Full Code (WIP)

Code: (Select All)
screen 12

CONST TRUE = 1
CONST FALSE = 0



TYPE PurchasableItem
    Name AS STRING
    Count AS INTEGER
    Cost AS DOUBLE
    ProductionRate AS DOUBLE
END TYPE

TYPE Operator
    Name AS STRING
    Cost AS DOUBLE
    ManagedItemIndex AS INTEGER
    Owned AS INTEGER
END TYPE




' Define the data for each item
DATA "Nebula Collector",50,0.5
DATA "Space Rover",500,2
DATA "Asteroid Miner",2500,10
DATA "Cosmic Observatory",12000,40
DATA "Interstellar Probe",60000,100
DATA "Wormhole Excavator",300000,500
DATA "Quantum Research Lab",1500000,2000
DATA "Galactic Trading Post",7500000,8000
DATA "Alien Artifact Hunter",37500000,40000
DATA "Dimensional Gateway",187500000,100000

DIM SHARED Stardust AS DOUBLE
DIM SHARED UpdateTimer AS INTEGER
DIM SHARED Items(10) AS PurchasableItem
DIM SHARED Operators(1 TO 10) AS Operator




' Read the data and initialize each item
FOR I = 1 TO 10
    READ Items(I).Name, Items(I).Cost, Items(I).ProductionRate
    Items(I).Count = 0
NEXT I

' Initialize Operators
DATA "Basic Drone",10000,1
DATA "Advanced Drone",50000,2
DATA "Mining Robot",250000,3
DATA "Observatory AI",1250000,4
DATA "Probe Navigator",6250000,5
DATA "Wormhole Technician",31250000,6
DATA "Quantum Scientist",156250000,7
DATA "Galactic Trader",781250000,8
DATA "Artifact Analyst",3906250000,9
DATA "Dimensional Engineer",19531250000,10

FOR I = 1 TO 10
    READ Operators(I).Name, Operators(I).Cost, Operators(I).ManagedItemIndex
    Operators(I).Owned = FALSE
NEXT I



' Set up the timer event for game upkeep
UpdateTimer = _FREETIMER
ON TIMER(UpdateTimer, 0.5) GameUpkeep
TIMER(UpdateTimer) ON

DO
    CLS
    PRINT "Stardust: "; Stardust
    PRINT "============================================"
    PRINT

    PRINT "Press 'C' to collect Stardust."
    PRINT "Press 'Q' to quit the game."
    PRINT

    PRINT "Upgrades:"

    ' Display all upgrades with their stats
    FOR I = 1 TO 10
        IF Items(I).Cost <= Stardust THEN
            COLOR 10 ' Set text color to lime (color code 10)
            IF I < 10 THEN
                PRINT "Press "; STR$(I); " to buy "; Items(I).Name; ": "; Items(I).Count; " | Cost: "; Items(I).Cost
            ELSE
                PRINT "Press 0 to buy "; Items(I).Name; ": "; Items(I).Count; " | Cost: "; Items(I).Cost
            END IF
        ELSE
            COLOR 15 ' Set text color to white (default color code)
            PRINT Items(I).Name; ": "; Items(I).Count; " | Cost: "; Items(I).Cost
        END IF
    NEXT I
    COLOR 15 ' Reset text color to white for the rest of the text


    PRINT "Operators:"
    ' Display all operators with their stats
    ' Change color to lime if the player can afford the operator and it's not already owned
    FOR I = 1 TO 10
        IF Operators(I).Cost <= Stardust AND Operators(I).Owned = FALSE THEN
            COLOR 10 ' Set text color to lime (color code 10)
        ELSE
            COLOR 15 ' Set text color to white (default color code)
        END IF
        PRINT Operators(I).Name; ": Cost "; Operators(I).Cost; ", Managed Upgrade: "; Items(Operators(I).ManagedItemIndex).Name
    NEXT I
    COLOR 15 ' Reset text color to white for the rest of the text



    DIM userInput AS STRING
    userInput = INKEY$
    SELECT CASE LCASE$(userInput)
        CASE "c"
            Stardust = Stardust + 1
        CASE "1", "2", "3", "4", "5", "6", "7", "8", "9"
            IF Stardust >= Items(VAL(userInput)).Cost THEN
                PurchaseItem VAL(userInput)
            END IF
        CASE "0"
            IF Stardust >= Items(10).Cost THEN
                PurchaseItem 10
            END IF
        CASE "q"
            END ' Quit the game
    END SELECT
    _LIMIT 30
LOOP


'$include: 'utils_2023.bi'


SUB GameUpkeep
    FOR i = 1 TO 10
        IF Operators(i).Owned THEN
            Stardust = Stardust + (Items(Operators(i).ManagedItemIndex).Count * Items(Operators(i).ManagedItemIndex).ProductionRate)
        END IF
    NEXT i
END SUB

SUB PurchaseItem (ItemIndex AS INTEGER)
    IF Stardust >= Items(ItemIndex).Cost THEN
        Stardust = Stardust - Items(ItemIndex).Cost
        Items(ItemIndex).Count = Items(ItemIndex).Count + 1
        Items(ItemIndex).Cost = Items(ItemIndex).Cost * 1.15
    END IF
    ' Increase the ProductionRate per click instead of auto-generating Stardust
    Items(ItemIndex).ProductionRate = Items(ItemIndex).ProductionRate + SOME_INCREMENT_VALUE
END SUB

Print this item

Heart Julia
Posted by: Kernelpanic - 01-26-2024, 11:15 PM - Forum: General Discussion - No Replies

There was once a thread about Julia here . . .  Heart  I met Julia again today while I was experimenting, and I noticed this problem with the one hundred decimal places again. . . I now have the solution to set this up if anyone is interested. See the screenshot.

[Image: Julia-Nachkommastellen-mit-Standard-2024-01-26.jpg]

Print this item

  Search possibly bringing up wrong result
Posted by: TerryRitchie - 01-26-2024, 07:09 PM - Forum: Wiki Discussion - Replies (5)

When I search the wiki for variable types this page comes up:

https://qb64phoenix.com/qb64wiki/index.p...able_Types

which is correct.

When I search the wiki for type this page comes up:

https://qb64phoenix.com/qb64wiki/index.php/Type

I would have expected the page for the TYPE statement to come up instead.

When I search the wiki for end type this page appears:

https://qb64phoenix.com/qb64wiki/index.php/TYPE

which is the page for the TYPE statement.

The only way to get the TYPE statement page to appear using search is to enter TYPE in capital letters. I see the two previous pages I listed above end in Type and TYPE. In my opinion I believe it would be better to have a search for type (regardless of case) point to the TYPE statement's page. Just seems it may be a bit confusing for budding QB64PE programmers.

Print this item

  FUNCTION Event(x AS DOUBLE) AS DOUBLE
Posted by: Dimster - 01-26-2024, 04:17 PM - Forum: Help Me! - Replies (4)

Before creating a function I normally would Dimension x as Double BEFORE I actually call the function. For example

Dim x as Double
...code..
...code..

x = Event
...
Function Event(x)
...code...
End Function

But, dimensioning on an "as needed basis" or "on the run" what is the correct syntax

Function Event (x as Double) as Double or Function Event(x) as Double or Function Event (x as Double)??

It's hard to give up on the old ways, if they worked, to learn a new more efficient way. (by efficient I mean to reduce all those Dim Shared variables I have at the beginning of my code to only creating them when they are actually called for service.

Print this item

  extra icon in taskbar running QB64PE in Windows 11
Posted by: madscijr - 01-26-2024, 01:44 PM - Forum: General Discussion - Replies (4)

I recently got a new computer which came with Windows 11, and running QB64PE 3.10.0 on it, I can't help but notice an extra command prompt icon shows up in the taskbar (see screenshot). The prompt is mostly blank with "QB64PE.exe" in it. Is this normal? If I right-click on it in the taskbar and select Close Window, the QB64PE IDE closes as well, so I guess it's needed. Is there any configuration I can do to hide it or make it go away? Any info appreciated!

PS Here is my system info, if it helps: 

Code: (Select All)
Processor    Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz   2.30 GHz
Installed RAM    32.0 GB (31.8 GB usable)
System type    64-bit operating system, x64-based processor
Pen and touch    Touch support with 10 touch points

Edition    Windows 11 Pro
Version    22H2
Installed on 12/30/2023
OS build    22621.3007
Experience    Windows Feature Experience Pack 1000.22681.1000.0

[Image: qb64pe-extra-icon-on-taskbar-2.png]

Print this item

  How can I create a search file for text?
Posted by: PhilOfPerth - 01-25-2024, 10:27 PM - Forum: Help Me! - Replies (5)

How can I create a quick search (e.g. binary search) of a text file using QBPE? My file is several thousand (sorted) items of very varied length. 
Just an algorithm will do, I'm happy to try to  code the function myself (although I may need a few prompts along the way). Big Grin

Print this item

  _ERRORLINE abilities
Posted by: MichelleL - 01-24-2024, 11:55 PM - Forum: Help Me! - Replies (7)

I'm kind of not even sure how to phrase this question. _ERRORLINE will display the line where and error is found. But say I wanted to use the command to display something different depending on where the error is found. As in bounding the error to within a section of code, as in:

If _ErrorLine > 100and _ErrorLine < 150 Print "This section of code"
If _ErrorLine > 200and _ErrorLine < 250 Print "This other section of code"

Well, that is good, so long as I don't add more code prior to these two lines, in which case I have to keep tabs on those lines and change them each time I add or subtract prior code. Is there an ability to 'tag' something to use in place of the values? Or, maybe a different command.....

Print this item

  QBJS - Videos
Posted by: dbox - 01-24-2024, 07:06 PM - Forum: QBJS, BAM, and Other BASICs - Replies (1)

Thought I would create a new thread as a place to collect QBJS videos as they are available.  I'm not a youtuber myself, but there are others out there creating some great content.


It's More Fun to Compute #4 - QBJS Profile in VSCode
@grymmjack covers a lot of ground with this one.  In addition to the in-depth walkthrough of how to create a QBJS profile in VSCode, the first several minutes of the video contain a great general overview of the QBJS IDE and project.



QBJS Is a QBasic Like Interpreter For the Web

This is a great little intro to QBJS by RetroNick.  There's even a shoutout to BAM in this one.  RetroNick also has a number of QB64 videos on his channel.

Print this item