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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 496
» Latest member: braveparrot
» Forum threads: 2,845
» Forum posts: 26,661

Full Statistics

Latest Threads
Big problem for me.
Forum: General Discussion
Last Post: JRace
3 hours ago
» Replies: 11
» Views: 168
Virtual Arrays
Forum: Site Suggestions
Last Post: hsiangch_ong
8 hours ago
» Replies: 8
» Views: 293
QBJS v0.9.0 - Release
Forum: QBJS, BAM, and Other BASICs
Last Post: hsiangch_ong
8 hours ago
» Replies: 17
» Views: 287
QBJS - ASCII Draw
Forum: QBJS, BAM, and Other BASICs
Last Post: hsiangch_ong
8 hours ago
» Replies: 1
» Views: 34
Very basic key mapping de...
Forum: SMcNeill
Last Post: SMcNeill
9 hours ago
» Replies: 0
» Views: 27
Cautionary tale of open, ...
Forum: General Discussion
Last Post: mdijkens
10 hours ago
» Replies: 2
» Views: 62
Fun with Ray Casting
Forum: a740g
Last Post: Petr
Yesterday, 08:02 PM
» Replies: 5
» Views: 91
1990's 3D Doom-Like Walls...
Forum: Programs
Last Post: a740g
Yesterday, 06:12 PM
» Replies: 10
» Views: 312
Editor WIP
Forum: bplus
Last Post: aadityap0901
Yesterday, 08:54 AM
» Replies: 12
» Views: 682
discover graphics with xa...
Forum: Programs
Last Post: hsiangch_ong
01-14-2025, 10:39 PM
» Replies: 0
» Views: 35

 
  Word Finder.
Posted by: PhilOfPerth - 11-17-2022, 05:15 AM - Forum: Programs - Replies (8)

Here's a small prog I wrote that finds all words that can be formed from a selected word, using each letter only once. You can select a minimum and maximum word size, up to 13 letters. It uses the wordlists in a folder that are attached as a .zip file.

Code: (Select All)
Screen 9
_FullScreen

Common Shared base$, blngth, dictfile$, dummy$, dictwrd$, l, found, totfound, foundwords$(), unique$, min, max
Dim foundwords$(100)
min = 3

Color 14: Locate 6, 35: Print "Word-Find": Color 15
Print Tab(26); "Copyright Phil Taylor (2022)": Print
Print Tab(5); "This programme will find all English words up to 13 letters in length"
Print Tab(5); "that appear in the Collins (2019) dictionary, that can be formed from "
Print Tab(5); "the letters of a word or group of letters, with each letter only being"
Print Tab(5); "used once."
Print: Print Tab(10); "(You can specify minimum and maximum word-lengths to find)."
Print: Color 14: Print Tab(30); "Press a key to start": Color 15
While InKey$ <> "": Wend
While InKey$ = "": Wend
Print Tab(15);: Input "Minimum size of words (ENTER for default of 2)"; min$
If Val(min$) < 2 Then min = 2 Else min = Val(min$)
Print Tab(30); "Minimum set at "; min
Print
Print Tab(15);: Input "Maximum size of words (ENTER for default of 13)"; max$
If Val(max$) < 2 Then max = 13 Else max = Val(max$)
Print Tab(30); "Maximum set at"; max
Sleep 1
Start:
Cls
While InKey$ <> "": Wend
Locate 10, 20: Color 14: Input "What is the Base-Word (or group)"; base$: Color 15
If base$ < "A" Then base$ = "ANYTHING" '                                                                              just a word for demo purposes
base$ = UCase$(base$)
blngth = Len(base$)
Cls
Color 14: Print "Base-word is "; base$
Print "Minimum length:"; min; "  Maximum length:"; max
: Color 15: Print
base$ = UCase$(base$)
sorted$ = Left$(base$, 1)

FindUnique
For bletrnum = 1 To blngth '                                                                                              for each letter in base$
    fileletr$ = Mid$(base$, bletrnum, 1)
    po = InStr(unique$, fileletr$)
    If po = 0 Then GoTo skip
    Mid$(unique$, po, 1) = " "
    dictfile$ = "wordlists/" + fileletr$
    Close
    Open dictfile$ For Input As #1
    GetAWord:
    While Not EOF(1)
        Input #1, dictwrd$
        l = Len(dictwrd$): If l < min Or l > max Then GoTo GetAWord
        WORDCHECK
    Wend
    skip:
Next
Color 14: Print Tab(35); "Finished!"
Print Tab(29); "Total words found:"; totfound
Sleep
GoTo Start

Sub WORDCHECK
    fail = 0
    dummy$ = base$
    For a = 1 To l
        dictletr$ = Mid$(dictwrd$, a, 1)
        po = InStr(dummy$, dictletr$)
        If po = 0 Then
            fail = 1 '                                                                                                     letter is not in dummy$ so abandon word
        Else
            Mid$(dummy$, po, 1) = " "
        End If
    Next
    If fail = 1 Then Exit Sub
    found = found + 1: totfound = totfound + 1
    foundwords$(found) = dictwrd$
    If Pos(0) > 77 Then Print
    Print dictwrd$; Space$(13 - l);
    If found = 100 Then
        While InKey$ <> "": Wend
        Color 14
        Print
        Print Tab(27); "Press a key for next group"
        While InKey$ = "": Wend
        found = 0
        Cls
        Color 14: Print "Base-word is "; base$: Print
        Print "Minimum length:"; min; "  Maximum length:"; max
        Color 15
    End If
End Sub

Sub FindUnique
    unique$ = ""
    For a = 1 To blngth
        l$ = Mid$(base$, a, 1)
        po = InStr(unique$, l$)
        If po = 0 Then unique$ = unique$ + l$
    Next
End Sub



Attached Files
.zip   wordlists.zip (Size: 713.44 KB / Downloads: 43)
Print this item

  coming soon
Posted by: MasterGy - 11-16-2022, 09:36 PM - Forum: MasterGy - Replies (16)

there will be a game soon. It's just _maptriangle ! I couldn't wait to show a demo after I finished the water effect.

Print this item

  DAY 011: REM
Posted by: SMcNeill - 11-16-2022, 04:43 PM - Forum: Keyword of the Day! - Replies (33)

A command which everyone thinks they know flawlessly, and yet, they probably don't.  Tongue

What is it?  REM is a command that allows people to place remarks inside a program so that it helps clarify what's going on and makes it much easier to come back to the program at a future time and understand just what the BLEEP the programmer was thinking when he coded everything originially.

How to use it?  Just add REM to where you want to place a comment, and then type out your comment!



And with the basic description of this most basic command out of the way, let's touch back upon the opening sentence which begins this post, where I claimed: most folks don't know everything about REM, like they think they do.  WTH is up with that??  "What are people misunderstanding", you ask?

Most people think that REM and ' (the single quote) are interchangeable and completely the same.  In fact, most people think that ' (the single quote) is nothing more than a shortcut to reduce typing out the whole word REM.

This isn't true!!

REM is a *COMMAND*.

' (the single quote) is part of a *COMMENT*.

With REM, REM is an actual command which basically says, "Hey, everything past this point is a comment!"

With ' (the single quote), ' is PART of the comment itself, and is basically excluded from your code.

A subtle difference, but one which can have drastic effects upon a program.  Let's take the following code for example:

Code: (Select All)
IF foo THEN REM foo is a make-believe variable for my example!

Code: (Select All)
IF foo THEN 'foo is a make-believe variable for my example!

Now, at first glance, those two statements look *exactly* alike.  They're not.  Tongue

The first code box contains a single-line IF statement, whereas the second code box contains the start of a multi-line IF statement.  You're going to have to put an END IF in the second code box, or else run into all sorts of errors in your code.

WHY??

Because you ended the first IF statement with a command.  Sure, it's a command which says, "A comment is coming next," but it's still a command.  Think of it just like you would:  IF foo THEN PRINT.   That command (REM, in this case) is enough to close up that IF statement and make it a valid single-line statement.

On the other hand, the second segment of code is basically just IF foo THEN....  Then WHAT??  You're not telling that IF statement what to do on that line, so it's got to be a multi-line IF statement.

REM is a *COMMAND*, just like GOTO, PRINT, and all the other commands in the language.  It's just a command which says, "Comments to the right!"

' (the single quote) is an actual part of a comment, and is basically ignored when used as one inside your programs.  It's not a command, and that's the biggest difference -- and it's a significant one -- between the two.

Print this item

  QB64 Phoenix Edition 3.4.1 Released
Posted by: SMcNeill - 11-16-2022, 04:13 PM - Forum: Announcements - Replies (53)

Release v3.4.1 · QB64-Phoenix-Edition/QB64pe (github.com)  <-- Link to the download the new release, as folks somehow overlook all the other links we've pasted around the site.  Big Grin

Quote:
  • #236#237#238#239#245 - Several improvements made to the dialog functionality introduced in 3.4.0 - @mkilgore

    • Single and double quotes can now be used in any string provided to a dialog.
    • On Windows, the popup from _NotifyPopup will now be associated with the program using the command.
    • On Windows, _InputBox$ no longer spawns a separate process to display the dialog.
    • Previously some strings passed to the dialog functions were not properly escaped before being passed to the underlying dialog provider, those issues have been fixed.
  • #241 - Fixed bug in PAINT when a border color is not provided - @TheJoyfulProgrammer@mkilgore

    • The broken syntax was 


      Code: (Select All)
      PAINT (x, y), tileString$
      , where the optional border color was left off.
    • That would fill as though you provided zero as the border color, now it correctly fills any pixels matching the initial color at 


      Code: (Select All)
      (x, y)
      .
  • #247 - The 'Open' dialog in the IDE now makes use of the system provided Open dialog - @SteveMcNeill@mkilgore

    • This can be toggled off if necessary via the 'GUI Dialogs' option in the 


      Code: (Select All)
      Options
       menu.
    • The old dialogs may be removed in a future version.
  • #243 - The MinGW version on Windows was updated, it now provides gcc 12.2.0 - @a740g


New File Open Dialog!   YAY!!
Newest MinGW Compiler!  YAY!!
Bug Fixes!  YAY!!
Paint Expansion!  YAY!!
GUI Enhancements and Expansion!!  YAY!!

And it's all FREE!!  YAAAAAAAYYYY!!

What's not to love?  Hurry out and go grab your very own copy now, while unlimited supplies remain in time for the Holidays!  Release v3.4.1 · QB64-Phoenix-Edition/QB64pe (github.com) 

YAY!!  Big Grin

Print this item

  Finding Pi
Posted by: PhilOfPerth - 11-16-2022, 12:30 AM - Forum: Help Me! - Replies (18)

One for the Math (or ”outside-the-box-thinking”) gurus:  
Given an isoscles triangle ABC, with sides b and c (the sides opposite B and C) both 5 units in length, and with angle A=45degrees, is there a (simple?) way to find the length of side a, without resorting to pre-determined trig tables like sin, cos and tan, or pi
The reason I don’t want to use these is I’m trying to demonstrate how pi relates to the circumference of a circle, so I don’t want to involve anything that relies on pi – that would be “bootstrapping”,  sort of like lifting oneself up by the bootlaces.

Print this item

  Just an example: integration of documentation and IDE
Posted by: CharlieJV - 11-15-2022, 08:27 PM - Forum: General Discussion - No Replies

BAM is a stand-alone wiki for creation of BASIC programs.

It could also contain the programming reference, but that would make BAM heavier than I like, and would make the programming reference heavier than I like.  So the programming reference is a separate wiki.

When I look up documentation, I like to see sample source code, right there, embedded in the documentation.

But I also want to see the running program.

Here is what the programming reference does:

When I lookup a statement or function (let's say "CIRCLE"), the page for that documentation includes an iframe that shows relevant content from the BAM wiki.  The URL for the iframe is dynamically created by the programming reference, setup in a way that the BAM wiki is displayed in a way that matches the needs of the programming reference.  For CIRCLE, the programming reference generates the following URL fed to the iframe to use as SRC parameter, and now I have CIRCLE documentation enhanced with source code examples which I can run, right there:

The dynamically generated URL (click to see what the iframe in the programming reference would display.)

EDIT 2022-11-16: pasted the wrong URL in the code section below.  Fixed.

Code: (Select All)
https://basicanywheremachine.neocities.org/BAM_IDE.html?target=CIRCLE#View%20Program

That is my kind of documentation.  I've never seen this kind of thing done anywhere else, but it my world, it would be the norm.



Attached Files Thumbnail(s)
   
Print this item

  Day 010: _PUTIMAGE (Part II)
Posted by: SMcNeill - 11-15-2022, 07:40 PM - Forum: Keyword of the Day! - No Replies

So _PUTIMAGE has so many paramaters, and works so differently in so many unique situations, and since the conversation is still going so strongly about it and all its options, let's just devote another day to the subject.  

Join us at DAY 009:_PutImage (qb64phoenix.com), and ask all you want about the command and how it interacts with its 8 zillion parameters.  We'll do our best to answer all we can and give examples to help clarify any confusion and illustrate what we're talking about there.  Wink

Print this item

  ERROR: C++ compilation failed.
Posted by: Ed Davis - 11-15-2022, 07:13 PM - Forum: Help Me! - Replies (3)

I'm getting:

Quote:QB64-PE Compiler V3.4.0

Beginning C++ output from QB64 code...
[..............................................    ] 92%
Beginning C++ output from QB64 code...
[..................................................] 100%

Compiling C++ code into EXE...
ERROR: C++ compilation failed.
Check .\internal\temp\compilelog.txt for details.
On:

Code: (Select All)
declare sub main
declare sub get_numeric_args(args() as double)

dim args(4) as double
get_numeric_args(args())

sub get_numeric_args(args() as double)
  args(1) = 123
end sub

compilelog.txt:

Quote:internal\c\c_compiler\bin\c++.exe -O2 -w -std=gnu++11 -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/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:2529:
internal\c/..\\temp\\maindata.txt: In function 'void QBMAIN(void*)':
internal\c/..\\temp\\maindata.txt:13:2: error: 'pass1' was not declared in this scope
  pass1;
  ^~~~~
mingw32-make: *** [Makefile:412: internal\c/qbx.o] Error 1


maindata.txt
Code: (Select All)
if (!__ARRAY_DOUBLE_ARGS){
__ARRAY_DOUBLE_ARGS=(ptrszint*)mem_static_malloc(9*ptrsz);
new_mem_lock();
mem_lock_tmp->type=4;
((ptrszint*)__ARRAY_DOUBLE_ARGS)[8]=(ptrszint)mem_lock_tmp;
__ARRAY_DOUBLE_ARGS[4]= 0 ;
__ARRAY_DOUBLE_ARGS[5]=( 4 )-__ARRAY_DOUBLE_ARGS[4]+1;
__ARRAY_DOUBLE_ARGS[6]=1;
__ARRAY_DOUBLE_ARGS[0]=(ptrszint)mem_static_malloc(__ARRAY_DOUBLE_ARGS[5]*8);
memset((void*)(__ARRAY_DOUBLE_ARGS[0]),0,__ARRAY_DOUBLE_ARGS[5]*8);
__ARRAY_DOUBLE_ARGS[2]=1+2;
}
pass1;

main.txt
Code: (Select All)
S_0:;
do{

if(!qbevent)break;evnt(4);}while(r);
do{
SUB_GET_NUMERIC_ARGS(&(pass1=((double*)(__ARRAY_DOUBLE_ARGS[0]))[0]));
if(!qbevent)break;evnt(5);}while(r);
sub_end();
return;
}
void SUB_GET_NUMERIC_ARGS(ptrszint*_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS){
qbs *tqbs;
ptrszint tmp_long;
int32 tmp_fileno;
uint32 qbs_tmp_base=qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer=mem_static_pointer;
uint32 tmp_cmem_sp=cmem_sp;
#include "data1.txt"
mem_lock *sf_mem_lock;
new_mem_lock();
sf_mem_lock=mem_lock_tmp;
sf_mem_lock->type=3;
if (new_error) goto exit_subfunc;
do{
tmp_long=array_check(( 1 )-_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[4],_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[5]);
if (!new_error) ((double*)(_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[0]))[tmp_long]= 123 ;
if(!qbevent)break;evnt(8);}while(r);
exit_subfunc:;
free_mem_lock(sf_mem_lock);
#include "free1.txt"
if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;
cmem_sp=tmp_cmem_sp;
}
void SUB_VWATCH(){
qbs *tqbs;
ptrszint tmp_long;
int32 tmp_fileno;
uint32 qbs_tmp_base=qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer=mem_static_pointer;
uint32 tmp_cmem_sp=cmem_sp;
#include "data2.txt"
mem_lock *sf_mem_lock;
new_mem_lock();
sf_mem_lock=mem_lock_tmp;
sf_mem_lock->type=3;
if (new_error) goto exit_subfunc;
exit_subfunc:;
free_mem_lock(sf_mem_lock);
#include "free2.txt"
if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;
cmem_sp=tmp_cmem_sp;
}

Thanks for any help!

Print this item

  Small 25 line program
Posted by: Gadgetjack - 11-15-2022, 06:40 PM - Forum: Programs - Replies (22)

I found this on the "mmbasic" site and converted it to run on qb64.

Screen 12
n = 255
r = (2 * pi) / 235
x = 0
v = 0
t = 0
sz = 200
s = 0
scrw = 640: scrh = 480
sw = scrw / sz: sh = scrh / sz
offset = scrh / 4.5
Do
    Cls
    For i = 50 To n
        For j = 50 To n
            u = Sin(i + v) + Sin(r * i + x)
            v = Cos(i + v) + Cos(r * i + x)
            x = u + t
            q = scrw / 2 + u * offset
            a = scrh / 2 + v * offset
            PSet (q, a), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
        Next j
    Next i
    t = t + .025
Loop


A screen shot really does not look as good so run it and see.

Print this item

  _TITLE and extended ASCII characters.
Posted by: Pete - 11-15-2022, 04:25 PM - Forum: Help Me! - Replies (37)

I'd like to put CHR$(240), three small horizontal lines, in my title bar, but the _TITLE function cannot convert extended ASCII characters. Is there another method that wold print the 3 horizontal bars into the title bar so it doesn't look like this: ð

Pete

Print this item