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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 494
» Latest member: johtopoz3021
» Forum threads: 2,846
» Forum posts: 26,656

Full Statistics

Latest Threads
Big problem for me.
Forum: General Discussion
Last Post: SMcNeill
29 minutes ago
» Replies: 4
» Views: 13
discover graphics with xa...
Forum: Programs
Last Post: hsiangch_ong
1 hour ago
» Replies: 0
» Views: 6
QBJS v0.9.0 - Release
Forum: QBJS, BAM, and Other BASICs
Last Post: hsiangch_ong
1 hour ago
» Replies: 10
» Views: 119
another variation of "10 ...
Forum: Programs
Last Post: Jack002
1 hour ago
» Replies: 37
» Views: 529
Aloha from Maui guys.
Forum: General Discussion
Last Post: doppler
8 hours ago
» Replies: 14
» Views: 324
Cautionary tale of open, ...
Forum: General Discussion
Last Post: doppler
8 hours ago
» Replies: 0
» Views: 16
Extended KotD #22: _MOUSE...
Forum: Keyword of the Day!
Last Post: SMcNeill
Today, 12:29 AM
» Replies: 0
» Views: 47
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: aurel
Yesterday, 09:10 PM
» Replies: 111
» Views: 5,578
QB64PE v4.0 is now live!!
Forum: Announcements
Last Post: Kernelpanic
Yesterday, 04:08 PM
» Replies: 44
» Views: 2,245
Next small EQ step - EQ D...
Forum: Petr
Last Post: Petr
Yesterday, 02:52 PM
» Replies: 11
» Views: 601

 
  Three-dimensional array
Posted by: Kernelpanic - 01-03-2023, 06:39 PM - Forum: Programs - Replies (20)

Structure and representation of a three-dimensional array. What could one do with it? For example: day, month, total sales . . . Nice!  Tongue
Oh yes, wrong inputs are not caught yet.

Ebene = level,  Zeile = row,  Spalte = column

Code: (Select All)
'Dreidimensionales Feld mit graphischer Darstellung - 3. Jan. 2023

$Console:Only
Option _Explicit

Option Base 1
Dim As Integer dreiDimFeld(3, 4, 4)

'"dm" legt die Dimension(Ebenen) fest. Hier dreimal Bloecke a 16
'dz ist Anzahl Zeilen, ds ist Anzahl Spalten
Dim As Integer dm, dz, ds, dFeld
Dim As Integer ebene, zeile, spalte

Locate 2, 2

'Der Ablauf ist: 1te Ebene -> Durchlauf Zeile * Spalte
'dann folgt die naechste Ebene usw. so viele Ebenen
'wie vorhanden sind
dFeld = 1
For dm = 1 To 3
  For dz = 1 To 4
    'Nach jedem sechszehner Block Absatz
    'fuer naechsten Block. Csrlin+1 statt 2 -> schraege Anzeige
    Locate CsrLin + 1, CsrLin + 1
    For ds = 1 To 4
      dreiDimFeld(dm, dz, ds) = dFeld
      Print Using "## "; dreiDimFeld(dm, dz, ds),
      dFeld = dFeld + 1
    Next
  Next
  Print: Locate , 2
Next

Locate CsrLin + 2, 2

Input "Zeige Wert in Ebene : ", ebene
Locate CsrLin + 0, 2
Input "Zeige Wert in Zeile : ", zeile
Locate CsrLin + 0, 2
Input "Und in Spalte       : ", spalte

Locate CsrLin + 1, 2
Print Using "Wert in Ebene: # Zeile: # Spalte: # ist: ##"; ebene, zeile, spalte, dreiDimFeld(ebene, zeile, spalte)

End

Straight and oblique version.
[Image: Dreidimensionales-Feld2023.jpg]

Print this item

  Keyword of the Day 45: _PIXELSIZE
Posted by: SMcNeill - 01-03-2023, 01:37 PM - Forum: Keyword of the Day! - Replies (1)

_PIXELSIZE...  A truly useful word for the people who might want to make various library routines, but not so much so, for everyone else.

What is it?: _Pixelsize is a simple little function which tells us how many bytes a pixel takes up in memory.

How do we use it?: We simply just call it like any other function.  Something as simple as PS = _PixelSize will work just fine.

An example for people:


Code: (Select All)
Screen 0
Print _PixelSize 'should print 0
Sleep

Screen 12
Print _PixelSize 'should print 1
Sleep

Screen _NewImage(640, 480, 32)
Print _PixelSize 'should print 4
Sleep
System


Run the code above and give it a try.  You'll see that we start out in a text only screen, so _PixelSize reports 0 back to us -- there's no pixels in a text only screen!  There's only columns and rows!

Hit any key and then we swap over to a SCREEN 12 screen.  At this point, _PixelSize will report a value of 1 back to us.  Each pixel on the screen takes up one byte of memory.

Hit another key and we swap over to a 32-bit screen.  Now _PixelSize reports a value of 4 back to us.  This is what everyone should expect as 32-bit screens are, by definition, 32-bits -- or 4-bytes -- in size.  Each pixel has a single byte dedicated for Alpha, Red, Green, Blue color values, in a 32-bit screen.

... Which is all well and good, but not really all that useful in a single program.  If you create your screens, you'll probably know what they are to begin with, and there's no need to use _PixelSize to get that value for you...

... Which is why I mentioned this is a gem of a command for anyone who works on making library style code.  You never know when, who, or where your library routine might end up being called, and as such, you'll want to write it to work across various screen modes.  (Or to at least trouble shoot and error check against certain screen modes.)

For example, let's say I write a PerfectBox routine which draws a lovely graphical box, puts a texture on the background for it, and a label, and it interacts with the mouse, and plays music when it's on the screen and highlighted, and does your taxes for you, and convinces your significant other to look the other way while you make out with the sexy neighbor down the hall or across the road...

If I wrote such an amazing piece of code, I'd probably want to write it up as a library function and save it for use in all my programs.  Right?  Heck, I'd probably even want to share it with all you guys so I could brag to the world (well, the world of QB64PE anyway) about what I'd accomplished, and let all of you bask in its glory as well!

And then old @Pete comes along and starts griping... "None of my programs work now, thanks to your stupid PerfectLibrary button!!"

So how do I fix that??

Code: (Select All)
Sub PerfectButton (Parameters As HiddenByTrademark)
  If _PixelSize = 0 Then
     Print "Pete, this doesn't work in Screen 0!  It's a graphical button!"
     DeletePetesHardDrive
     LaughAtPete
     System
   End If
.... 
    'Rest of my PerfectButton Sub goes below here.
End Sub

Now, as you can see, we've error trapped for anyone using Screen 0 with our perfect button.  Pete can now insert our PerfectButton routine into all his code, and not get generic error messages about invalid syntax and such when he attempts to run his code...

... Let's just hope nobody except Pete happens to try and use our PerfectButton routine on a text Screen...  Our error handler may be a little more intense than most people approve of, in the example above...

Print this item

  while: wend
Posted by: fistfullofnails - 01-03-2023, 06:09 AM - Forum: General Discussion - Replies (24)

On Terry Ritchie's function/subroutine part of the QB64 tutorial, line 15 of subs.base,  we have:

Code: (Select All)
WHILE _MOUSEINPUT: WEND

The only way I've seen "WHILE" and "WEND" used is at the start and end of a loop, with some instructions  in between, which then ends with 'WEND".
I'm confused on what is exactly going on here.  Can anyone explain like I'm a five year old?

Code: (Select All)
DO
    _LIMIT 60
    WHILE _MOUSEINPUT: WEND
    IF _MOUSEBUTTON(1) THEN DrawStar _MOUSEX, _MOUSEY
    IF _MOUSEBUTTON(2) THEN Directions
    _DISPLAY
LOOP UNTIL _KEYDOWN(27)

Print this item

  Bilateral Kaleidoscope
Posted by: bplus - 01-02-2023, 07:08 PM - Forum: Programs - Replies (4)

Looking at this: https://qb64phoenix.com/forum/showthread.php?tid=1306

I came up with this:

Code: (Select All)
_Title "Bilateral Kaleidoscope" ' 2023-01-02 NOT like May 2022 version by b+
Const sh = 600, sw = 800
Screen _NewImage(sw, sh, 32)
'_ScreenMove 200, 100
_FullScreen
Randomize Timer
Do
    If lc = 0 Then
        dx1 = 0: dx2 = 0: dy1 = 0: dy2 = 0: dr = 0: dg = 0: db = 0
        x1 = sw * Rnd: y1 = sh * Rnd: x2 = sw * Rnd: y2 = sh * Rnd: r = Rnd * 255: g = Rnd * 255: b = Rnd * 255
        While dx1 = 0: dx1 = Rnd * 6 - 3: Wend
        While dx2 = 0: dx2 = Rnd * 6 - 3: Wend
        While dy1 = 0: dy1 = Rnd * 6 - 3: Wend
        While dy2 = 0: dy2 = Rnd * 6 - 3: Wend
        While dr = 0: dr = Rnd * 4 - 2: Wend
        While dg = 0: dg = Rnd * 4 - 2: Wend
        While db = 0: db = Rnd * 4 - 2: Wend
    End If
    Line (x1, y1)-(x2, y2), _RGB32(r, g, b, 100)
    Line (sw - x1, y1)-(sw - x2, y2), _RGB32(r, g, b, 100)
    Line (x1, sh - y1)-(x2, sh - y2), _RGB32(r, g, b, 100)
    Line (sw - x1, sh - y1)-(sw - x2, sh - y2), _RGB32(r, g, b, 100)
    x1 = Remainder(x1 + dx1, sw)
    x2 = Remainder(x2 + dx2, sw)
    y1 = Remainder(y1 + dy1, sh)
    y2 = Remainder(y2 + dy2, sh)
    r = Remainder(r + dr, 255)
    g = Remainder(g + dr, 255)
    b = Remainder(b + db, 255)
    lc = lc + 1
    If ((Rnd > .999) And (lc > 300)) Or (lc > 4000) Then Sleep 1: Cls: lc = 0
    _Limit 60
Loop Until _KeyDown(27)

Function Remainder (n, d)
    If d = 0 Then Exit Function
    Remainder = n - (d) * Int(n / (d))
End Function

Print this item

  Like gliding over a sparkling ocean
Posted by: CharlieJV - 01-02-2023, 06:44 PM - Forum: QBJS, BAM, and Other BASICs - Replies (3)

https://basicanywheremachine.neocities.o...ling_ocean

Print this item

  DAY 044: RESET
Posted by: SMcNeill - 01-02-2023, 03:21 PM - Forum: Keyword of the Day! - Replies (3)

How many of you guys know this word even exists in our language?  The command is RESET, but how many remember exactly WHAT it resets?  Or what it's for?

This is one of those very important old keywords, that has basically became lost to time.

Keyword: RESET

Wiki page: https://qb64phoenix.com/qb64wiki/index.php/RESET

What's this do:  It basically works as a superpowered CLOSE statement.  Back in the day, when folks used floppy disks and such, it was necessary to use RESET to write your current directory info to the drive track.  Before you ever exited a program, and pulled your floppy out of the drive, you'd issue a RESET command to close all files and update all drive information to the floppy.

Nowadays?  Who owns a floppy drive?  Would a modern OS even require this type of command to update that information, IF you happened to have a floppy drive connected??  I dunno!!

All this command does for us now, is basically just work as a CLOSE statement to close all files.  It's unused.  Obsoleted.  Forgotten...

...Maybe I should've saved this keyword for Memorial Day.   

RIP poor RESET.

Print this item

  File Menu Feature
Posted by: eoredson - 01-02-2023, 05:02 AM - Forum: Help Me! - Replies (4)

I was thinking (again)..

In the Alt-F recent files list could someone add <delete> key to remove a file from the list without deleting the actual .bas program??

That way I don't have to check for broken links..

Erik.

Print this item

Wink Happy new year.
Posted by: Fifi - 01-02-2023, 03:45 AM - Forum: General Discussion - Replies (3)

Yep, it's a very nice banner.
So, happy new 2023 year to all the QB64 Phoenix Edition members.
And my best wishes to the developers.
Cheers.
Fifi

Print this item

  DAY 043: _SHHH
Posted by: SMcNeill - 01-01-2023, 07:00 PM - Forum: Keyword of the Day! - Replies (2)

_SHHH -- the keyword one uses the most on New Years Day.  Usually is a result of too much celebrating on New Years Eve, which causes even the click click click of the mechanical keyboard you love so much, to sound as if the devil is tap dancing inside your brain.  

Code: (Select All)
_SHHH


[Image: image.png]

Usage usually results in an error while causes the programmer to just silently lay his head upon the keyboard for a while, until the world stops spinning and he doesn't feel quite so nauseous.  May sometimes be used in conjecture with the keyword _Hangover for extreme results.  Be cautious in this use so that _BLARF does not occur from within the aftermath of whatever was left from last night's stomach.



Now that the holidays are behind us, we'll focus on starting the KOTD back up once again seriously, come tomorrow when the _SHHH isn't so prominent.  

HAPPY NEW YEAR, ONE AND ALL!!

Print this item

Thumbs Up Nice Banner!
Posted by: bplus - 01-01-2023, 03:38 PM - Forum: General Discussion - Replies (13)

Looks great! @SMcNeill I assume ;-))

Print this item