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,801
» Forum posts: 26,410

Full Statistics

Latest Threads
GNU C++ Compiler error
Forum: Help Me!
Last Post: eoredson
2 hours ago
» Replies: 0
» Views: 11
Merry Christmas Globes!
Forum: Programs
Last Post: SierraKen
7 hours ago
» Replies: 10
» Views: 106
Text-centring subs
Forum: Utilities
Last Post: Pete
8 hours ago
» Replies: 3
» Views: 67
Screw Text Centering. How...
Forum: Utilities
Last Post: Pete
9 hours ago
» Replies: 0
» Views: 20
List of file sound extens...
Forum: Help Me!
Last Post: aplus
11 hours ago
» Replies: 16
» Views: 272
Merry Christmas Globes!
Forum: Christmas Code
Last Post: SierraKen
Yesterday, 09:58 PM
» Replies: 7
» Views: 72
Tenary operator in QB64 w...
Forum: Utilities
Last Post: Kernelpanic
Yesterday, 06:58 PM
» Replies: 7
» Views: 114
New QBJS Samples Site
Forum: QBJS, BAM, and Other BASICs
Last Post: DANILIN
Yesterday, 04:29 PM
» Replies: 24
» Views: 850
School themes from USSR a...
Forum: Programs
Last Post: DANILIN
Yesterday, 04:19 PM
» Replies: 24
» Views: 1,950
fast file find with wildc...
Forum: Help Me!
Last Post: SpriggsySpriggs
Yesterday, 03:55 PM
» Replies: 8
» Views: 111

 
  About "conditionals"
Posted by: CharlieJV - 07-14-2024, 02:32 PM - Forum: QBJS, BAM, and Other BASICs - No Replies

Although this is about conditionals in BAM, the info might be useful to you for thinking about conditionals in general.

https://basicanywheremachine-news.blogsp...n-bam.html

Print this item

  Centroid Question
Posted by: TerryRitchie - 07-13-2024, 06:00 PM - Forum: Help Me! - Replies (17)

Ok you math wizards, I need your input/advice. I've been reading up on centroids and barycenters because I want to find the center point of a given set of x,y points. The suggested math for this as found on the Internet is truly impressive (i.e. wow).

However, why couldn't you just use the center point of the min/max x,y point seen in the set? The code illustrates what I have in mind. Any thoughts on this approach? Good, bad? If bad, why? Thanks for taking the time to read this.

Code: (Select All)
CONST RED~& = _RGB32(255, 0, 0)
CONST GREEN~& = _RGB32(0, 255, 0)
CONST GRAY~& = _RGB32(64, 64, 64)

TYPE iPoint '          x,y point construct
    x AS INTEGER
    y AS INTEGER
END TYPE

DIM rp(19) AS iPoint ' random point
DIM Min AS iPoint '    min x,y seen
DIM Max AS iPoint '    max x,y seen
DIM Center AS iPoint ' center point of random points
DIM p AS INTEGER '     counter

RANDOMIZE TIMER
Min.x = 319 '          start min/max at center of screen
Min.y = 239
Max = Min

SCREEN _NEWIMAGE(640, 480, 32)

p = 0
DO '                                                                                       create random points
    rp(p).x = RND * 640
    rp(p).y = RND * 480
    IF rp(p).x > Max.x THEN Max.x = rp(p).x ELSE IF rp(p).x < Min.x THEN Min.x = rp(p).x ' get max/min x
    IF rp(p).y > Max.y THEN Max.y = rp(p).y ELSE IF rp(p).y < Min.y THEN Min.y = rp(p).y ' get max/min y
    p = p + 1
LOOP UNTIL p > UBOUND(rp)

Center.x = Min.x + ((Max.x - Min.x) / 2) ' get center x
Center.y = Min.y + ((Max.y - Min.y) / 2) ' get center y

p = 0
DO '                                                    draw points in red, lines to center in gray
    LINE (rp(p).x, rp(p).y)-(Center.x, Center.y), GRAY
    CIRCLE (rp(p).x, rp(p).y), 2, RED
    PAINT (rp(p).x, rp(p).y), RED, RED
    p = p + 1
LOOP UNTIL p > UBOUND(rp)


CIRCLE (Center.x, Center.y), 2, GREEN '                 draw green center point
PAINT (Center.x, Center.y), GREEN, GREEN

PRINT Min.x; Min.y, Max.x; Max.y, Center.x; Center.y '  display values

Print this item

  Question about "Sub memcpy ..."
Posted by: Kernelpanic - 07-12-2024, 05:26 PM - Forum: Help Me! - Replies (5)

While reading the wiki I came across Offset(function): https://qb64phoenix.com/qb64wiki/index.p...(function)

The sub "memcpy" is apparently a fixed procedure, because when I changed the name there was an error during compilation.
What is this "memcpy"? Hard-wired?  I couldn't find anything about it in the wiki.

Code: (Select All)

Option _Explicit

Declare CustomType Library
  Sub zeichenKopieren (ByVal Ziel As _Offset, Byval Quelle As _Offset, Byval Bytes As Long)
End Declare

Dim As String zahlen, buchstaben

zahlen = "1234567890"
buchstaben = "ABCDEFGHIJ"

zeichenKopieren _Offset(zahlen) + 5, _Offset(buchstaben) + 5, 5
Print zahlen

End

Quote:internal\c\c_compiler\bin\c++.exe -Wl,--stack,26777216 -std=gnu++17 -fno-strict-aliasing -Wno-conversion-null -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/include -Iinternal\c/parts/core/freeglut/include -Iinternal\c/parts/core/glew/include -DDEPENDENCY_NO_SOCKETS -DDEPENDENCY_NO_PRINTER -DDEPENDENCY_NO_ICON -DDEPENDENCY_NO_SCREENIMAGE internal\c/qbx.cpp -c -o internal\c/qbx.o
In file included from internal\c/qbx.cpp:1894:
internal\c/../temp/maindata.txt: In function 'void QBMAIN(void*)':
internal\c/../temp/maindata.txt:1:55: error: 'zeichenKopieren' was not declared in this scope
    1 | SUB_ZEICHENKOPIEREN=(CUSTOMCALL_SUB_ZEICHENKOPIEREN*)&zeichenKopieren;
      |                                                      ^~~~~~~~~~~~~~~
mingw32-make: *** [Makefile:402: internal\c/qbx.o] Error 1
That is OK.
Code: (Select All)

'12. Juli 2024

Option _Explicit

Declare CustomType Library
  Sub memcpy (ByVal Ziel As _Offset, Byval Quelle As _Offset, Byval Bytes As Long)
End Declare

Dim As String zahlen, buchstaben

zahlen = "1234567890"
buchstaben = "ABCDEFGHIJ"

memcpy _Offset(zahlen) + 5, _Offset(buchstaben) + 5, 5
Print zahlen

End

Print this item

  Finally some good Windows 10 news to share.
Posted by: Pete - 07-11-2024, 11:00 PM - Forum: General Discussion - Replies (22)

   

Well hot diggity dog **** doo! 

After next year, no more annoying Windows f'updates!!!

Pete Smile

Print this item

  Multiscreen program
Posted by: SMcNeill - 07-11-2024, 05:55 PM - Forum: SMcNeill - Replies (5)

Code: (Select All)
DIM SHARED AS LONG x, y, client
SCREEN _NEWIMAGE(640, 480, 32)
host = _OPENHOST("TCP/IP:7319") ' no host found, so begin new host
IF host THEN
_SCREENMOVE 0, 0
DO
IF client = 0 THEN client = _OPENCONNECTION(host) ' receive any new connection
IF client THEN SendXY
x = x + 1: IF x > 1280 THEN x = 0
CLS
_PRINTSTRING (x, y), "Steve is Amazing"
IF x > 1280 - _PRINTWIDTH("Steve is Amazing") THEN _PRINTSTRING (x - 1280, y), "Steve is Amazing"
_DISPLAY
_LIMIT 30
LOOP
ELSE
_SCREENMOVE 640, 0
client = _OPENCLIENT("TCP/IP:7319:localhost") ' Attempt to connect to local host as a client
DO
GetXY
CLS
_PRINTSTRING (x - 640, y), "Steve is Amazing"
_DISPLAY
_LIMIT 30
LOOP
END IF


SUB SendXY
PUT #client, , x
PUT #client, , y
END SUB

SUB GetXY
GET #client, , x
GET #client, , y
END SUB

Inspired by Tempodi's topic: https://qb64phoenix.com/forum/showthread.php?tid=2855

Here, I wanted to create a true multi-screen program. Nothing fancy, but something nice and simple to showcase how easy it is to actually do something like this.

Try run this:

1) Run this.
2) Run a second version of this at the same time while the first version is running.

Then let both versions run for a complete cycle or two, to see the simple effect.

Note: You may need to jump through whatever bells and whistles your OS requires for network/TCP-IP communications and such with your FireWall and Security.

Print this item

  History of the question mark
Posted by: Dimster - 07-11-2024, 01:54 PM - Forum: General Discussion - Replies (8)

Does anyone know the history of how it came to be that "?" became a short form for "PRINT". Has it always been built into the bones of QBasic. Could have been ported over from some other language. Just curious.

Print this item

  Change file data
Posted by: krovit - 07-08-2024, 01:52 PM - Forum: Help Me! - Replies (5)

Hello everyone,
Can someone suggest the code to change the creation date, last access date, and modification date of a file?
I believe it requires calls to KERNEL32 but I'm not sure how to do it.

Thank you!

Print this item

  Multiscreen effect
Posted by: TempodiBasic - 07-08-2024, 03:40 AM - Forum: Programs - Replies (7)

Hi
this is a first raw example to get multiscreen effect on the screen.

Code: (Select All)

Const Tot = 4, One = 1, Two = 2, Three = 3
Dim screens(One To Tot) As Long, Movies(One To Three) As Long
If _FileExists("QB64bee.jpeg") Then Movies(One) = _LoadImage("QB64bee.jpeg", 32)
If _FileExists("QB64.jpeg") Then Movies(Two) = _LoadImage("QB64.jpeg", 32)
If _FileExists("QB64pe.jpg") Then Movies(Three) = _LoadImage("QB64pe.jpg", 32)

screens(Tot) = _NewImage(1000, 700, 32)
Screen screens(Tot)
_Title "Multiscreen"
_ScreenMove 1, 1
For c% = 1 To 3
    _PutImage , Movies(c%), screens(Tot)
    _Delay 1
Next c%
Randomize Timer
Dim k(One To Three) As Integer, h(One To Three) As Integer
While InKey$ = ""
    Cls
    _PutImage (20 + k(One), 20 + h(One))-(333, 330), Movies(One), screens(Tot)
    _PutImage (20 + k(Two), 370 + h(Two))-(333, 680), Movies(Two), screens(Tot)
    _PutImage (350 + k(Three), 20 + h(Three))-(980, 680), Movies(Three), screens(Tot)
    _Delay .1
    _Display
    For c% = One To Three
        k(c%) = Int(Rnd * 4)
        h(c%) = Int(Rnd * 5)
    Next c%
Wend
_Delay .5

While InKey$ = ""
    Cls
    _PutImage (20 + k(One), 20 + h(One))-(333, 330), Movies(One), screens(Tot)
    _PutImage (20 + k(Two), 370 + h(Two))-(333, 680), Movies(One), screens(Tot)
    _PutImage (350 + k(Three), 20 + h(Three))-(980, 680), Movies(One), screens(Tot)
    _Delay .1
    _Display
    For c% = One To Three
        k(c%) = Int(Rnd * 4)
        h(c%) = Int(Rnd * 5)
    Next c%
Wend


End

Multiscreen in this videomusic

you can download images from google search or use those posted here.
Happy Coding!



Attached Files Thumbnail(s)
           
Print this item

  When BASIC was at the top, do you agree?
Posted by: TempodiBasic - 07-06-2024, 02:44 PM - Forum: General Discussion - Replies (25)

Hi wonderful QB64pe community!
The time runs as its nature, and today I'm lucky to get some time to make this thread.

The question is towards any experienced BASIC coder that want to remember old good days.


[Image: immagine-2024-07-06-164056816.png]

Is there another gold time for BASIC?

Fine to meet you today QB64's friends.

Print this item

  Wave Function Collapse
Posted by: aadityap0901 - 07-06-2024, 10:01 AM - Forum: Programs - Replies (8)

Hello, this is my first post.  Big Grin
I don't know where to post this, this place looked likely.

I learnt WFC yesterday, and it seemed easy, so I thought I would code and share it as my first program on this new forum:
If anyone wants to change images, you can change it in LoadImage function.
I wanna see how people use this idea, please share your creative designs (if possible)  Smile.

Code: (Select All)
Screen _NewImage(640, 640, 32)

Type Tile
    As _Byte Omit 'BULDR in bits
    As _Byte STATE
End Type

Const TILE_STATE_BLANK = 1, TILE_STATE_UP = 2, TILE_STATE_LEFT = 3, TILE_STATE_DOWN = 4, TILE_STATE_RIGHT = 5

Dim As Tile Tile_Empty, Tiles(1 To 64, 1 To 64), Tile_Up, Tile_Down, Tile_Left, Tile_Right

Dim As Long TileImages(0 To 5): For I = 0 To 5: TileImages(I) = LoadImage(I): Next I

'Place a random tile at center'
Randomize Timer: RandomTile Tiles(16 + CInt(Rnd * 32), 16 + CInt(Rnd * 32))

'Start the loop
S = 1
Do
    Cls
    '_Limit 16
    If S = 0 Or Stuck Then
        If S = 0 Then _Title "Finished" Else _Title "Stuck"
        Do
            _Limit 60
            If _KeyDown(32) Then Run
            If _KeyDown(27) Then System
        Loop
    Else
        S = 0
        For I = 1 To 64
            For J = 1 To 64
                If J > 1 Then Tile_Up = Tiles(I, J - 1) Else Tile_Up = Tile_Empty
                If J < 64 Then Tile_Down = Tiles(I, J + 1) Else Tile_Down = Tile_Empty
                If I < 64 Then Tile_Right = Tiles(I + 1, J) Else Tile_Right = Tile_Empty
                If I > 1 Then Tile_Left = Tiles(I - 1, J) Else Tile_Left = Tile_Empty
                UpdateTile Tiles(I, J), Tile_Up, Tile_Down, Tile_Left, Tile_Right
                If J > 1 Then Tiles(I, J - 1) = Tile_Up
                If J < 64 Then Tiles(I, J + 1) = Tile_Down
                If I < 64 Then Tiles(I + 1, J) = Tile_Right
                If I > 1 Then Tiles(I - 1, J) = Tile_Left
                If Tiles(I, J).STATE Then _Continue
                If TryTile(Tiles(I, J)) = 0 Then Stuck = -1
                S = S + 1
        Next J, I
    End If
    _Title "Working"
    For I = 1 To 64: For J = 1 To 64: _PutImage (I * 10 - 10, J * 10 - 10)-(I * 10 - 1, J * 10 - 1), TileImages(Tiles(I, J).STATE): Next J, I
    _Display
Loop
System
'--------------
Sub RandomTile (T As Tile)
    Dim __T As Tile
    T.STATE = Int(Rnd * 5) + 1
    UpdateTile T, __T, __T, __T, __T
End Sub
Sub UpdateTile (T As Tile, TU As Tile, TD As Tile, TL As Tile, TR As Tile)
    Select Case T.STATE
        Case TILE_STATE_BLANK
            TU.Omit = TU.Omit Or &B00111
            TD.Omit = TD.Omit Or &B01101
            TL.Omit = TL.Omit Or &B01011
            TR.Omit = TR.Omit Or &B01110
        Case TILE_STATE_UP
            TU.Omit = TU.Omit Or &B11000
            TD.Omit = TD.Omit Or &B01101
            TL.Omit = TL.Omit Or &B10100
            TR.Omit = TR.Omit Or &B10001
        Case TILE_STATE_DOWN
            TU.Omit = TU.Omit Or &B00111
            TD.Omit = TD.Omit Or &B10010
            TL.Omit = TL.Omit Or &B10100
            TR.Omit = TR.Omit Or &B10001
        Case TILE_STATE_LEFT
            TU.Omit = TU.Omit Or &B11000
            TD.Omit = TD.Omit Or &B10010
            TL.Omit = TL.Omit Or &B10100
            TR.Omit = TR.Omit Or &B01110
        Case TILE_STATE_RIGHT
            TU.Omit = TU.Omit Or &B11000
            TD.Omit = TD.Omit Or &B10010
            TL.Omit = TL.Omit Or &B01011
            TR.Omit = TR.Omit Or &B10001
    End Select
End Sub
Function TryTile (T As Tile)
    Options$ = "BULDR"
    SetOptions$ = ""
    If T.Omit And &B10000 Then Asc(Options$, 1) = 0
    If T.Omit And &B01000 Then Asc(Options$, 2) = 0
    If T.Omit And &B00100 Then Asc(Options$, 3) = 0
    If T.Omit And &B00010 Then Asc(Options$, 4) = 0
    If T.Omit And &B00001 Then Asc(Options$, 5) = 0
    For I = 1 To 5
        If Asc(Options$, I) > 0 Then SetOptions$ = SetOptions$ + Chr$(Asc(Options$, I))
    Next I
    If Len(SetOptions$) = 0 Then Exit Function
    If Len(SetOptions$) < 4 Then STATE = Asc(SetOptions$, Int(Rnd * Len(SetOptions$)) + 1)
    Select Case STATE
        Case 66: T.STATE = TILE_STATE_BLANK
        Case 85: T.STATE = TILE_STATE_UP
        Case 76: T.STATE = TILE_STATE_LEFT
        Case 68: T.STATE = TILE_STATE_DOWN
        Case 82: T.STATE = TILE_STATE_RIGHT
    End Select
    TryTile = -1
End Function
Function LoadImage& (I)
    Select Case I
        Case 0: LoadImage& = load_Empty&
        Case 1: LoadImage& = load_Blank&
        Case 2: LoadImage& = load_Up&
        Case 3: LoadImage& = load_Left&
        Case 4: LoadImage& = load_Down&
        Case 5: LoadImage& = load_Right&
    End Select
End Function
Function load_Empty&
    O& = _NewImage(5, 5, 32)
    __Dest = _Dest: _Dest O&
    Restore Empty_data
    For __X = 0 To 4: For __Y = 0 To 5
            Read __P&
            PSet (__X, __Y), __P&
    Next __Y, __X
    _Dest __Dest
    load_Empty = O&
    Exit Function
    Empty_data:
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
End Function
Function load_Blank&
    O& = _NewImage(5, 5, 32)
    __Dest = _Dest: _Dest O&
    Restore Blank_data
    For __X = 0 To 4: For __Y = 0 To 5
            Read __P&
            PSet (__X, __Y), __P&
    Next __Y, __X
    _Dest __Dest
    load_Blank = O&
    Exit Function
    Blank_data:
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
End Function
Function load_Up&
    O& = _NewImage(5, 5, 32)
    __Dest = _Dest: _Dest O&
    Restore Up_data
    For __X = 0 To 4: For __Y = 0 To 5
            Read __P&
            PSet (__X, __Y), __P&
    Next __Y, __X
    _Dest __Dest
    load_Up = O&
    Exit Function
    Up_data:
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
End Function
Function load_Left&
    O& = _NewImage(5, 5, 32)
    __Dest = _Dest: _Dest O&
    Restore Left_data
    For __X = 0 To 4: For __Y = 0 To 5
            Read __P&
            PSet (__X, __Y), __P&
    Next __Y, __X
    _Dest __Dest
    load_Left = O&
    Exit Function
    Left_data:
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
End Function
Function load_Down&
    O& = _NewImage(5, 5, 32)
    __Dest = _Dest: _Dest O&
    Restore Down_data
    For __X = 0 To 4: For __Y = 0 To 5
            Read __P&
            PSet (__X, __Y), __P&
    Next __Y, __X
    _Dest __Dest
    load_Down = O&
    Exit Function
    Down_data:
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
End Function
Function load_Right&
    O& = _NewImage(5, 5, 32)
    __Dest = _Dest: _Dest O&
    Restore Right_data
    For __X = 0 To 4: For __Y = 0 To 5
            Read __P&
            PSet (__X, __Y), __P&
    Next __Y, __X
    _Dest __Dest
    load_Right = O&
    Exit Function
    Right_data:
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,&HFF00CFD4,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
    Data &HFF1D2B3A,&HFF1D2B3A,&HFF00CFD4,&HFF1D2B3A,&HFF1D2B3A,
End Function

Print this item