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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 485
» Latest member: zenevan
» Forum threads: 2,804
» Forum posts: 26,384

Full Statistics

Latest Threads
Prime Number Generator
Forum: Programs
Last Post: eoredson
3 hours ago
» Replies: 1
» Views: 19
DeflatePro
Forum: a740g
Last Post: aadityap0901
3 hours ago
» Replies: 6
» Views: 180
"9,999 digits of PHI with...
Forum: Programs
Last Post: ahenry3068
4 hours ago
» Replies: 5
» Views: 55
Ascii Christmas Tree
Forum: Christmas Code
Last Post: Pete
8 hours ago
» Replies: 6
» Views: 218
request for printing patt...
Forum: Learning Resources and Archives
Last Post: Pete
8 hours ago
» Replies: 18
» Views: 479
What do you guys like to ...
Forum: General Discussion
Last Post: TempodiBasic
10 hours ago
» Replies: 24
» Views: 566
QB64PE v4.0 is now live!!
Forum: Announcements
Last Post: bplus
Yesterday, 10:55 PM
» Replies: 41
» Views: 1,696
Masakari - the abandoned ...
Forum: Programs
Last Post: Sanmayce
Yesterday, 06:27 PM
» Replies: 0
» Views: 39
Merry X-Mas 2024!!
Forum: General Discussion
Last Post: NakedApe
Yesterday, 05:18 PM
» Replies: 13
» Views: 262
Smallish Games
Forum: bplus
Last Post: bplus
Yesterday, 11:31 AM
» Replies: 20
» Views: 1,400

 
  Subscript out of range?
Posted by: Cobalt - 12-18-2023, 11:08 PM - Forum: Help Me! - Replies (3)

Ok now that I have some time to code and play around, I'm trying to get back into it.
Thus I find my self in a situation that I'm not sure what is going on. I have an array with 16 elements (0-15) and I have a RND statement that I think is supposed to give me results of 0-15(RND * 16) But every so often I am receiving a Subscript out of range error.
am I just goofing or is something else going on? What am I forgetting here?

Line 41 is listed as the error line, which is the RND * 16 line.
I've attached the needed files to run it , if your curious just what it does.
Steve, I would be interested in your thoughts on how it is setup and what it puts out.

Code: (Select All)
TYPE Player_Stat
Name AS STRING * 16
Title AS STRING * 24
Strength AS _BYTE
Dexterity AS _BYTE
Constitution AS _BYTE
Intelligence AS _BYTE
Wisdom AS _BYTE
Charisma AS _BYTE
HP AS _BYTE
MP AS _BYTE
Max_HP AS _BYTE
Max_MP AS _BYTE
Xp AS LONG
Nxp AS LONG
Level AS _BYTE
Age AS _UNSIGNED _BYTE
Race AS _BYTE
END TYPE

SCREEN _NEWIMAGE(800, 600, 32)
RANDOMIZE TIMER
DIM SHARED Layer(8) AS LONG, Font(4) AS LONG, P AS Player_Stat
DIM SHARED Titles(15) AS STRING, Race(4) AS STRING
DATA "Novice","Aspirant","Battler","Fighter","Adept","Chevalier","Veteran","Warrior","Swordman","Hero","Soldier","Myrmidon","Champion","Superhero","Paladin","Lord"
DATA "Mystery","Human","Zombie","Dwarf","Elves"
FOR i% = 0 TO 15: READ Titles(i%): NEXT
FOR i% = 0 TO 4: READ Race(i%): NEXT
Layer(0) = _DISPLAY
Layer(1) = _COPYIMAGE(Layer(0))
Layer(2) = _LOADIMAGE("8x6CharSheet.bmp", 32)
Layer(3) = _LOADIMAGE("portraits2.jpg", 32)
Font(1) = _LOADFONT("ComicRunes.otf", 40, "monospace")
Font(2) = _LOADFONT("ComicRunes.otf", 24, "monospace")
Font(3) = _LOADFONT("DwarvenStonecraftCyr.otf", 24, "monospace")
_FONT Font(1)
_PRINTMODE _KEEPBACKGROUND
_SCREENMOVE 10, 10
COLOR _RGB32(0)
P.Name = "Ryo Seaba"
P.Title = Titles(RND * 16)
Stat_Maker

x%% = INT(RND * 10)
y%% = INT(RND * 10)
_PUTIMAGE , Layer(2), Layer(0)
_PRINTSTRING (293 - 18 * (LEN(RTRIM$(P.Name)) / 2), 28), P.Name
_PUTIMAGE (590, 80), Layer(3), Layer(0), (160 * x%%, 120 * y%%)-STEP(159, 119)
Fill_Stats

'LINE (319, 20)-STEP(2, 40), _RGB32(255, 0, 0), BF
'LINE (128, 40)-STEP(329, 2), _RGB32(255, 0, 0), BF
'160,120
SUB Stat_Maker
P.Strength = INT(RND * 15) + 1
P.Dexterity = INT(RND * 15) + 1
P.Constitution = INT(RND * 15) + 1
P.Intelligence = INT(RND * 15) + 1
P.Wisdom = INT(RND * 15) + 1
P.Charisma = INT(RND * 15) + 1
P.HP = INT(RND * P.Strength) + INT(RND * P.Constitution) + P.Constitution \ 2
P.MP = INT(RND * P.Intelligence) + INT(RND * P.Wisdom) + P.Wisdom \ 2
P.Max_HP = P.HP
P.Max_MP = P.MP
XpNeed%% = P.Strength + P.Dexterity + P.Constitution + P.Intelligence + P.Wisdom + P.Charisma
' P.Xp = XpNeed%%
P.Nxp = (INT(RND * XpNeed%% * 2) * 2 + 10) * (P.HP / 12) 'int((P.HP + P.MP)/10)*10
P.Level = 0
P.Age = INT(RND * 6) + 16
P.Race = INT(RND * 5)
END SUB

SUB Fill_Stats
_FONT Font(2)
_PRINTSTRING (192, 206), LTRIM$(STR$(P.Strength))
_PRINTSTRING (192, 238), LTRIM$(STR$(P.Dexterity))
_PRINTSTRING (192, 270), LTRIM$(STR$(P.Constitution))
_PRINTSTRING (192, 302), LTRIM$(STR$(P.Intelligence))
_PRINTSTRING (192, 334), LTRIM$(STR$(P.Wisdom))
_PRINTSTRING (192, 366), LTRIM$(STR$(P.Charisma))
_PRINTSTRING (600, 276), LTRIM$(STR$(P.HP))
_PRINTSTRING (600, 302), LTRIM$(STR$(P.MP))
_PRINTSTRING (664, 276), LTRIM$(STR$(P.Max_HP))
_PRINTSTRING (664, 302), LTRIM$(STR$(P.Max_MP))
_PRINTSTRING (600, 330), LTRIM$(STR$(P.Xp))
_PRINTSTRING (600, 356), LTRIM$(STR$(P.Nxp))
_PRINTSTRING (316, 294), "Bare Fists"
_PRINTSTRING (316, 490), "Thin Cloth"
_PRINTSTRING (624, 384), LTRIM$(STR$(P.Level))
_PRINTSTRING (624, 410), RTRIM$(Race(P.Race))
_PRINTSTRING (624, 438), LTRIM$(STR$(P.Age))

_FONT Font(3)
_PRINTSTRING (293 - 19 * (LEN(RTRIM$(P.Title)) / 2), 144), P.Title
END SUB



Attached Files
.rar   StatMaker.rar (Size: 1.08 MB / Downloads: 52)
Print this item

  QB664PE v3.10.0 is now live for X-Mas!!
Posted by: SMcNeill - 12-18-2023, 08:17 PM - Forum: Announcements - Replies (53)

https://github.com/QB64-Phoenix-Edition/QB64pe/releases

Quote:v3.10.0 Latest

Enhancements
#392 - Allow single quoted strings in $VERSIONINFO. - @a740g
#399 - The IDE waits for release of F5 key before running the program to avoid start of multiple copies of the program. - @SteveMcNeill
#401 - Add Support for optional paramter for an image handle to CLS. - @SteveMcNeill
#404 - Increased the maximum number of possible SUBs/FUNCTIONs in a program from 1000 to 25000. - @SteveMcNeill
#414, #415 - Implemented $EMBED metacommand and _EMBEDDED$ function. - @RhoSigma-QB64
Can be used to embed any files (images, sounds, fonts and other assets) into the compiled executable and recall it in the program when needed.
Read the respective Wiki pages: $EMBED and EMBEDDED$
Bug Fixes
#389 - Internal fixes to use correct math functions from std:: namespace. - @a740g
#391 - Fixed no sound issue on maccOS discussed in this forum posts. - @a740g
#397, #398 - Fixed several CONST issues. - @SteveMcNeill
#405 - Fixed checking for invalid domains in _ARCSEC and _ARCCSC as per the forum posts
#407, #410 - Change IDE save method for better speed on big source files. - @SteveMcNeill
#412 - Avoid segfault on bogus SVG data pretending to be valid SVG text. - @a740g
Full Changelog: v3.9.1...v3.10.0

https://github.com/QB64-Phoenix-Edition/QB64pe/releases

Print this item

  _FREEIMAGE Behavior
Posted by: TerryRitchie - 12-17-2023, 08:21 PM - Forum: Help Me! - Replies (7)

I just ran across something that I did not either realize or should not be happening.

When an image is freed using _FREEIMAGE the associated variable is not reset to zero but instead retains the negative value of the image assigned. Is this normal behavior?

Code: (Select All)
image1 = _NEWIMAGE(100, 100, 32)
image2 = _COPYIMAGE(image1)

PRINT image1, image2
_FREEIMAGE image2
PRINT image1, image2
_FREEIMAGE image1
PRINT image1, image2
The code above shows that when images are freed the associated variable retains the image value. I would expect the variable to be reset to zero along with the image being removed from memory.

Is this correct?

Print this item

  SVG drawing example : Polygons!
Posted by: James D Jarvis - 12-16-2023, 02:40 PM - Forum: Learning Resources and Archives - No Replies

Another demo program showing how to draw SVGs and load them via memory buffer to use SVG as an alternative drawing method.
SVG's can draw polygons with a simple path definition that is mostly string of numbers.
this string "<path  stroke ='#FFFFFF' fill='#FF0000'  stroke-width='3' d ='M 200 200 700 200 700 400 200 400 200 200'/>" would draw a red rectangle with a 3 pixel wide white border if embedded in complete SVG string. The polygon is simply defined as a series of points. The only variation in this series of points is the use of M which tells any program drawing the path to move to the following point instead of drawing to the point.

In this example the subroutione svgpoly$  will take a randomly defined polygons and convert them into an SVGpath description held in a string. The path descriptions will be inserted into a complete SVG definition and loaded into a memory buffer and displayed.

Code: (Select All)
'SVG polygon drawing example
'drawing polygons with paths
'a QB64 example by James D. Jarvis
'works with QB64-PE version 3.9.0 and later

'
'this demonstrates how to use subroutines to build a multiple polygon definitions and combine them into a memory buffer that is
'loaded and displayed

Screen _NewImage(800, 500, 32)
Randomize Timer
Dim si As _Unsigned Long 'the SVG image buffer, it's an image handle like any other
Do
    Cls , _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256)) 'clear the screen and fill it with a random color
    ss$ = "" 'the the SVG string
    'build the polygons for the demo
    np = Int(6 + Int(Rnd * 100))
    If Rnd * 100 < 3 Then np = np * 20
    For p = 1 To np
        ss$ = ss$ + svgpoly$(Int(25 + Rnd * (_Width - 50)), Int(25 + Rnd * (_Height - 50)), Int(10 + Rnd * 100), Int(10 + Rnd * 120), (Int(Rnd * 90)), Int(1 + Rnd * 10), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256)), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256)))
    Next p
    'take the polygon defintions and compine them with the rest of the SVG string
    ss$ = "<svg width='" + _Trim$(Str$(_Width)) + "' height='" + _Trim$(Str$(_Height)) + "'>" + ss$ + " </svg>" 'putting all those polygons inside an SVG as large as the window
    si = _LoadImage(ss$, 32, "memory") 'load the svg described in ss$ into memory
    _PutImage (0, 0), si 'put the svg on the screen, using 0,0 because the source SVG is as large as the window
    tt$ = Str$(p) + " polygons": _Title tt$ 'put the polygon count in the window title
    Sleep
    _FreeImage si 'free the image so we can load a new one without wasting memory or if we are exiting the program

Loop Until InKey$ = Chr$(27)
'_CLIPBOARD$ = ss$      'windows users can uncomment the commad on the left to dump the last sbg drawn to their clipboard.

Function svgpoly$ (cx, cy, rr, shapedeg, turn, ww, bklr As _Unsigned Long, fklr As _Unsigned Long)
    'filled rotated polygon returned as a string portion of an svg string buffer
    'cx,cy are center of polygon
    'rr oios radius of polygon
    'shapedeg is the angle forming the basis of the polygon , if it doesn't divide into 360 evenly an irregular polygon will be created
    'turn will be the angle the whole polygon is turned off of 0 degree
    'ww is the width fo the border border stroke of the polygon
    'output returned from theis function will be astring holding an SVG path describing a polygon.
    '
    'define the path that will form the polygon and fill the border and fill colors
    i$ = i$ + "<path  stroke ='" + packcolorN$(bklr) + "' fill='" + packcolorN$(fklr) + "' "
    'add the stroke width
    i$ = i$ + " stroke-width='" + _Trim$(Str$(ww)) + "' "

    'find the 1st point in the polygon
    x = rr * Sin(0.01745329 * turn)
    y = rr * Cos(0.01745329 * turn)
    'tell the svg to draw the path by moving to the first point of the polygon
    i$ = i$ + "d ='M"
    i$ = i$ + Str$(cx + x) + Str$(cy + y) + Str$(cx + x) + Str$(cy + y)
    'find the perimter of the polygon
    For deg = turn To turn + 360 Step shapedeg
        x2 = rr * Sin(0.01745329 * deg)
        y2 = rr * Cos(0.01745329 * deg)
        'record the consecutive points of the polygon  that will be drawn to form the path that defines the polygon perimeter
        i$ = i$ + Str$(cx + x2) + Str$(cy + y2)
    Next
    'close the polyon by drawing to the first point
    i$ = i$ + Str$(cx + x) + Str$(cy + y)
    i$ = i$ + "'/>" 'end the path definition of the polygon
    svgpoly$ = i$ 'return this path holding a polygon definiton to the SVG to be drawn
End Function
Function packcolorN$ (klr As _Unsigned Long)
    'convert an unsigned long color value into a hexidecimal # that will be used in an SVG
    Dim As _Unsigned Long rk, gk, bk
    'get the color channels of the unsinged long color
    rk = _Red32(klr)
    gk = _Green32(klr)
    bk = _Blue32(klr)
    'convert those channel values into hexidecimal
    If rk < 16 Then
        r$ = "0" + Hex$(rk) 'put in a padded hexidcimal value
    Else
        r$ = Hex$(rk) 'put in a 2 digit hexidecimal value
    End If
    If gk < 16 Then
        g$ = "0" + Hex$(gk) 'put in a padded hexidcimal value
    Else
        g$ = Hex$(gk) 'put in a 2 digit hexidecimal value
    End If
    If bk < 16 Then
        b$ = "0" + Hex$(bk) 'put in a padded hexidcimal value
    Else
        b$ = Hex$(bk) 'put in a 2 digit hexidecimal value
    End If
    packcolorN$ = "#" + r$ + g$ + b$
End Function

Print this item

  Merry X-Mas 2023!! Santa Steve Returns With Gifts For All!!
Posted by: SMcNeill - 12-16-2023, 09:19 AM - Forum: Learning Resources and Archives - Replies (6)


.7z   qb64wiki.7z (Size: 1.74 MB / Downloads: 74)

.7z   qb64phoenix.com.7z (Size: 176.65 MB / Downloads: 89)

As usual, it's Christmas time once again, and those of you who have been members of the QB64 community for a while, you know what that means!! It's the time of year when Santa Steve shows up and offers a hard drive full of goodies for one and all!

Now most years, Santa Steve just downloads and archives the QB64 wiki, and makes them available for one and all so they can have full access to the year's newest wiki information -- but this year, Santa Steve has went above and beyond even that!! This year, Santa Steve is hosting and offering the whole QB64-PE FORUMS as well as the QB64-PE WIKI for everyone to enjoy!!

(Note that the small attachment is JUST the Wiki, while the 2nd, larger attachment is both the Wiki and the Forums.)

If you want it, there's no reason why you can't grab a copy of the QB64-PE Archives for 2023! It's free! It's available for one and all!

If you're in a country or area that absolutely can't download the archive (perhaps due to bandwidth issues or some other such thing), then post here! It's Christmas time, for goodness sake! Somebody can burn off a copy of the archive to a DVD and snail mail it to you, if that's absolutely necessary!

QB64-PE Archives 2023 -- for one and for all!!

Enjoy, guys! (And you gals out there too!)

Print this item

  Winter Banner?
Posted by: bplus - 12-16-2023, 01:51 AM - Forum: Site Suggestions - Replies (55)

I've got some extra Winter Banners if anyone is interested.

Print this item

  Disable Print Screen?
Posted by: TerryRitchie - 12-15-2023, 08:01 PM - Forum: General Discussion - Replies (13)

Does anyone have any ideas on how a QB64PE program can disable the print screen function when running?

Ideally I would like to be able to hook the keyboard's PRINT SCREEN key to intercept keypresses while at the same time disabling the operating system from grabbing a screen shot. However, disabling the operating system's ability to perform screen shots while the program is running would be just as useful.

Any thoughts, ideas?

Print this item

  Sorting and Searching:A Cookbook
Posted by: SMcNeill - 12-15-2023, 06:50 PM - Forum: General Discussion - No Replies


.txt   Algorithm_Book.txt (Size: 171.27 KB / Downloads: 80)


Quote: This booklet contains a collection of sorting and searching algorithms.
While many books on data structures describe sorting and searching algorithms,
most assume a background in calculus and probability theory. Although a formal
presentation and proof of asymptotic behavior is important, a more intuitive
explanation is often possible.
The way each algorithm works is described in easy-to-understand terms. It
is assumed that you have the knowledge equivalent to an introductory course in C
or Pascal. In particular, you should be familiar with arrays and have a basic
understanding of pointers. The material is presented in an orderly fashion,
beginning with easy concepts and progressing to more complex ideas. Even though
this collection is intended for beginners, more advanced users may benefit from
some of the insights offered. In particular, the sections on hash tables and skip
lists should prove interesting.


Santa Cruz, California
Thomas Niemann
March, 1995

Print this item

  Select Case error
Posted by: Dimster - 12-14-2023, 04:39 PM - Forum: Help Me! - Replies (9)

[Image: Error-using-Select-Case.png]


I have run into a situation where the IDE is showing an error in my use of a Select Case. I have 4 cases the last one being Case "Extreme". Attached is a clip of the code and warning box. Normally this would mean I have missed an End IF or a Next but at the moment I can't seem to find it.. I'll keep looking but my question here is that mysterious "7" which you see in the warning box which highlights Case "Extreme" , 7 .... there is no 7 on that case line. Any idea what that 7 means and if it may be pointing me to where I need to address the problem?

Print this item

  Is BIMDAS busted?
Posted by: PhilOfPerth - 12-13-2023, 02:11 AM - Forum: Help Me! - Replies (2)

The BIMDAS rules (universal priority rules for math) sets priority for math operations as
Brackets, Indices, Multiplication, Division, Addition, Subtraction.
Within the BIMDAS rules, the expression 5+4*3^2-1/2 becomes (3^2)*4/2+5-1
                                                                                               B   I   M  D   A  S
and the result is 22.

With the re-arrangement, Phoenix returns 22, as expected.
but when entered as 5 + 4 * 3 ^ 2 - 1 / 2, it returns 40.5

Does this mean we must apply the BIMDAS rules manually, or am I missing something?  Huh
Print "Am I missing something here?"

Print this item