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
A command which everyone thinks they know flawlessly, and yet, they probably don't.
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.
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.
#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.
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.
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:
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.
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
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.
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: ð