Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
|
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
|
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
|
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,032
|
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
|
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
|
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
|
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
|
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
|
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155
|
|
|
Alt-Keys pattern |
Posted by: eoredson - 07-07-2023, 04:52 AM - Forum: Utilities
- Replies (3)
|
|
I have been looking at the keyboard scancodes for the keys Alt-A to Alt-Z and found no pattern to them!
Are they internal to the electronic keyboard itself?
Thanks, Erik.
Here is a program to trap and display them:
Code: (Select All) Rem $Dynamic
DefInt A-Z
Dim Keys(1 To 26) As Integer
' scancodes for Alt-A to Alt-Z.
Data 30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44
' read Alt-<key> data.
For Var = 1 To 26
Read Keys(Var)
Next
Color 15
Print "Press <escape> to exit. Otherwise press Alt-A to Alt-Z."
Color 14
Do
_Limit 50
I$ = InKey$
If Len(I$) Then
If I$ = Chr$(27) Then Color 7: End
End If
If Len(I$) = 2 Then
X = Asc(Right$(I$, 1))
For Z = 1 To 26
If Keys(Z) = X Then
Print "Pressed Alt-"; Chr$(Z + 64); " scan"; X
End If
Next
End If
Loop
End
' scancodes for Alt-A to Alt-Z.
Rem ALT-A = 30
Rem ALT-B = 48
Rem ALT-C = 46
Rem ALT-D = 32
Rem ALT-E = 18
Rem ALT-F = 33
Rem ALT-G = 34
Rem ALT-H = 35
Rem ALT-I = 23
Rem ALT-J = 36
Rem ALT-K = 37
Rem ALT-L = 38
Rem ALT-M = 50
Rem ALT-N = 49
Rem ALT-O = 24
Rem ALT-P = 25
Rem ALT-Q = 16
Rem ALT-R = 19
Rem ALT-S = 31
Rem ALT-T = 20
Rem ALT-U = 22
Rem ALT-V = 47
Rem ALT-W = 17
Rem ALT-X = 45
Rem ALT-Y = 21
Rem ALT-Z = 44
|
|
|
Archive-dot-org simple helper |
Posted by: mnrvovrfc - 07-06-2023, 10:39 PM - Forum: Utilities
- Replies (11)
|
|
This is a program that could make life a bit easier to navigate "archive-dot-org" if the user is only looking to download music or video.
N.B. This requires a bit of research to configure the program as desired. As it stands it only works for audio (FLAC, MP3, OGG, WAV etc.) This research is to obtain the "subjects" which are tags that have to be written precisely into a web address. On "archive-dot-org" some categories are written out like plain English, capitalized short phrases with spaces, which cannot stand into a web address. The site has a chooser of subjects which puts down stuff which could be unpredictable. (Sometimes it chooses "multiple categories" which is the same word or words but in different upper-lower-case combinations.) Therefore the user must tinker a little bit to obtain a subject tag for use with this program. It's a vain attempt to make this program more flexible.
This program requires one text file, and it's recommended to provide another. The required file has one line which is the full path of the executable to the web browser. Because I programmed this on Linux, I'm not familiar with a way to launch the web browser from an user's QB64 program on MacOS or on Windows. I also programmed to launch the AppImage which might appear clumsy to some of you. This file is not provided, you will have to create it. It is called "helparchorg-browser.txt", it must reside in the same directory as the executable. This program only reads the first line of this file, so make sure it has a correct entry.
It's recommended to have also "helparchorg-category.txt". It could also be called "helparchorg-subject.txt". Here you will put down a subject, one per line, for the media that is sought. If you want two categories at a time then put each tag joined by a plus sign. At the moment no more than two categories could be joined.
The program reads the text files, tells the user that it found the web browser, and then shows a menu with the categories. If there's only one then it's "electronic", at the moment, but this could be changed in the source code. The user types in a number for the subject or subjects he/she desires and presses [ENTER]. Pressing [ENTER] with no entry quits the program.
After that, the user is asked what year of creation or release for the media sought, starting with 2013. Again, this could be modified in the source code. Type in the menu choice for the year, not the year itself LOL, and press [ENTER]. Press [ENTER] without entry at this point to leave the program.
This program then launches the web browser with the address fabricated from the data it was given.
Code: (Select All)
'by mnrvovrfc 6-July-2023
OPTION _EXPLICIT
DIM AS INTEGER c, lsubj, j, plu
DIM prefx$, afile$, launchprog$, comd$, asubj$, ayear$, entry$
DIM fe AS LONG
prefx$ = "helparchorg-"
afile$ = prefx$ + "browser.txt"
IF NOT _FILEEXISTS(afile$) THEN
PRINT "The web browser wasn't found! Aborting."
END
END IF
fe = FREEFILE
OPEN afile$ FOR INPUT AS fe
DO UNTIL EOF(fe)
LINE INPUT #fe, entry$
entry$ = _TRIM$(entry$)
IF entry$ <> "" AND launchprog$ = "" THEN
launchprog$ = entry$
EXIT DO
END IF
LOOP
CLOSE fe
IF NOT _FILEEXISTS(launchprog$) THEN
PRINT "The web browser wasn't found! Aborting."
END
END IF
PRINT "Discovered web browser executable called:"
PRINT launchprog$
afile$ = prefx$ + "subject.txt"
IF NOT _FILEEXISTS(afile$) THEN
afile$ = prefx$ + "category.txt"
END IF
IF _FILEEXISTS(afile$) THEN
fe = FREEFILE
OPEN afile$ FOR INPUT AS fe
DO UNTIL EOF(fe)
LINE INPUT #fe, entry$
entry$ = _TRIM$(entry$)
IF entry$ <> "" THEN lsubj = lsubj + 1
LOOP
CLOSE fe
IF lsubj < 1 THEN
PRINT "At least one entry required from input file!"
END
END IF
REDIM subj(1 TO lsubj) AS STRING
c = 0
fe = FREEFILE
OPEN afile$ FOR INPUT AS fe
DO UNTIL EOF(fe)
LINE INPUT #fe, entry$
entry$ = _TRIM$(entry$)
IF entry$ <> "" THEN
c = c + 1
subj(c) = entry$
END IF
LOOP
CLOSE fe
ELSE
lsubj = 1
REDIM subj(1 TO lsubj) AS STRING
subj(lsubj) = "electronic"
END IF
PRINT "*** archive-dot-org helper ***"
IF lsubj = 1 THEN
PRINT: PRINT "There's only one category available: "; subj(1)
asubj$ = subj(1)
ELSE
PRINT: PRINT "Please choose your category."
FOR j = 1 TO lsubj
PRINT USING "(##)"; j;
PRINT " "; subj(j)
NEXT
LINE INPUT entry$
entry$ = _TRIM$(entry$)
IF entry$ = "" THEN SYSTEM
c = VAL(entry$)
IF c > 0 AND c <= lsubj THEN
asubj$ = subj(c)
ELSE
PRINT "Incorrect input given! Aborting."
END
END IF
END IF
PRINT: PRINT "Please choose the year of release."
FOR j = 2013 TO 2023
PRINT USING "(####)"; j - 2012;
PRINT " "; j
NEXT
LINE INPUT entry$
entry$ = _TRIM$(entry$)
IF entry$ = "" THEN SYSTEM
c = VAL(entry$)
IF c > 0 AND c < 12 THEN
ayear$ = _TRIM$(STR$(c + 2012))
ELSE
PRINT "Incorrect input given! Aborting."
END
END IF
comd$ = launchprog$ + " 'https://archive.org/details/audio?and[]=year%3A%22" + ayear$ + _
"%22&and[]=mediatype%3A%22audio%22&and[]=subject%3A%22"
plu = INSTR(asubj$, "+")
IF plu > 0 THEN
comd$ = comd$ + LEFT$(asubj$, plu - 1) + "%22&and[]=subject%3A%22" + MID$(asubj$, plu + 1) + "%22'"
ELSE
comd$ = comd$ + asubj$ + "%22'"
END IF
SHELL _HIDE _DONTWAIT comd$
SYSTEM
For this program as it stands, try this as "helparchorg-category.txt":
Code: (Select All) electronic
podcast
Popular Music+Jazz
|
|
|
Auto reload program upon RUN |
Posted by: Cobalt - 07-06-2023, 08:58 PM - Forum: Help Me!
- Replies (2)
|
|
Anybody have any clever ideas on how one would get the IDE to reload a program when it was run? The program in question actually updates itself when it runs, and I was just wondering if there was a way to get the ide to reload the code so I wouldn't forget to reload it and go change some code save it and destroy the changes the program made last time it ran.
|
|
|
Calculating Anti-Primes |
Posted by: Space_Ghost - 07-06-2023, 06:56 PM - Forum: Works in Progress
- Replies (17)
|
|
Can this be sped up? The code below calculates the first 45 anti-primes in ~6.3 seconds on my W11 PC.
Definition of anti-primes: A natural number that has more divisors (factors, not just prime factors) than any number less that it. For example, 6 has 4 factors, including 1 and itself, and this is more than 1,2,3 or 5 which have only the minimum of 2 factors and 4 which has 3 factors.
Code: (Select All)
'Anti-Primes: Calculate first 45 anti-primes
'date of code: 06 JUL 2023
'Space Ghost (modified QBasic 4.5 from Rosetta Code)
'HOUSEKEEPING -----------------------------------
$CONSOLE:ONLY
OPTION _EXPLICIT
CLS
'VARIABLE DECLARATIONS -------------------------
DIM t AS DOUBLE
DIM tmp AS STRING
DIM AS INTEGER MaxAntiPrime, AntiPrimeCount
DIM AS LONG MaxDivisors, Divisors, n
'MAIN BLOCK ------------------------------------
t = TIMER(0.001)
MaxAntiPrime = 45
n = 0
MaxDivisors = 0
AntiPrimeCount = 0
PRINT "The first 45 anti-primes are:"
PRINT
WHILE AntiPrimeCount < MaxAntiPrime
n = n + 1
Divisors = DivisorCount(n)
IF Divisors > MaxDivisors THEN
PRINT n;
MaxDivisors = Divisors
AntiPrimeCount = AntiPrimeCount + 1
END IF
WEND
PRINT: PRINT
tmp = "Execution Time in secs:##.###"
PRINT USING tmp; TIMER(0.001) - t
END
'FUNCTIONS AND SUBROUTINES ----------------------
FUNCTION DivisorCount (v)
DIM AS LONG total, count, n, p
total = 1
n = v
WHILE n MOD 2 = 0
total = total + 1
n = n \ 2
WEND
p = 3
WHILE (p * p) <= n
count = 1
WHILE n MOD p = 0
count = count + 1
n = n \ p
WEND
p = p + 2
total = total * count
WEND
IF n > 1 THEN total = total * 2
DivisorCount = total
END FUNCTION
'END OF PROGRAM --------------------------------
CONSOLE OUTPUT
The first 45 anti-primes are: 1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560 10080 15120 20160 25200 27720 45360 50400 55440 83160 110880 166320 221760 277200 332640 498960 554400 665280 720720 1081080 1441440 2162160 2882880 3603600 4324320 6486480
Execution Time in secs: 6.334
|
|
|
Boring plot of 5000 functions! |
Posted by: mnrvovrfc - 07-05-2023, 10:38 PM - Forum: Works in Progress
- Replies (4)
|
|
This is another program that would only display graphic silliness. Don't expected colored, fractal stuff; a program such as this might have been attempted with QuickBASIC or Turbo Pascal, trying to burn those weak single-core CPU's to a crisp. Many pictures are just an useless line at the top or at the side of the screen. Others are just near-diagonal lines. Others are "steps" as if trying to plot binary or something else. But there are a few good ones here.
The program tries to plot a function with 500 points of Cartesian coordinates taking part in a polar scheme. If the function is not plottable, it's skipped. The "Illegal function call" had to be trapped for it. The functions were fabricated from another QB64 program I wrote. Don't spend too much time looking at them or it will cause some loss of sanity!
Press [ESC] to quit, or on Linux leave it for long enough and then it seg-faults, I don't know why. (shrugs)
At the terminal command line it's possible to follow the executable file's name with an integer from 1 to 5000, to start from the function indicated by the huge "SELECT CASE... END SELECT" block. This has nothing to do with random numbers. It was already taken care of by my "extreme function maker" LOL.
That is the first parameter. There is a second parameter which is a float-type factor. The default is to just plot a circle with X,Y for 500 points. The circle is always created by this program with a "radius" of 2. The factor in this program can only cause the effect of an open shape. In other words, the chosen factor by the user cannot be smaller than the default value of 1.3888.
The actual program is too big to post into this forum, so I'm posting only a portion of it. Otherwise you will have to download the attachment.
Code: (Select All)
'by mnrvovrfc 06-Jun-2023
option _explicit
dim v(1 to 500) as double
dim as double n, x, y, z, mult, factdiv, smaller, largger
dim as integer i, j, cn
dim redu$
if command$(1) = "" then
cn = 1
else
cn = val(command$(1))
if cn = 0 then
cn = 1
elseif cn < 1 or cn > 5000 then
cn = 1
end if
end if
if command$(2) = "" then
mult = 1.3888
else
mult = val(command$(1))
if mult < 1.3888 or mult > 5.0 then
mult = 1.3888
end if
end if
screen _newimage(1000, 500, 12)
for i = cn to 5000
on error goto 100
for z = 1 to 500
x = 2 * cos(_d2r(z / mult))
y = 2 * sin(_d2r(z / mult))
select case i
case 1
n = Z10B46#(x, y, z)
case 2
n = Z10B48#(x, y, z)
case 3
n = Z10B4A#(x, y, z)
case 4
n = Z10B4C#(x, y, z)
case 5
n = Z10B4E#(x, y, z)
case 6
n = Z10B50#(x, y, z)
case 7
n = Z10B52#(x, y, z)
case 8
n = Z10B54#(x, y, z)
case 9
n = Z10B56#(x, y, z)
case 10
n = Z10B58#(x, y, z)
' :
' :
case 4990
n = Z13240#(x, y, z)
case 4991
n = Z13242#(x, y, z)
case 4992
n = Z13244#(x, y, z)
case 4993
n = Z13246#(x, y, z)
case 4994
n = Z13248#(x, y, z)
case 4995
n = Z1324A#(x, y, z)
case 4996
n = Z1324C#(x, y, z)
case 4997
n = Z1324E#(x, y, z)
case 4998
n = Z13250#(x, y, z)
case 4999
n = Z13252#(x, y, z)
case 5000
n = Z13254#(x, y, z)
end select
endoflongcase:
v(z) = n
next
on error goto 0
smaller = 0
largger = 0
for z = 1 to 500
if v(z) < smaller then smaller = v(z)
if v(z) > largger then largger = v(z)
next
if int(smaller * 1e+6) = 0 and int(largger * 1e+6) = 0 then
cls
_continue
end if
redu$ = ""
if abs(smaller) > abs(largger) then factdiv = abs(smaller) else factdiv = abs(largger)
do while factdiv > 1e+6
redu$ = "*"
smaller = smaller / 100
largger = largger / 100
if abs(smaller) > abs(largger) then factdiv = abs(smaller) else factdiv = abs(largger)
loop
_title _trim$(str$(i)) + ": " + redu$ + "Smaller =" + str$(smaller) + "| " + redu$ + "Larger =" + str$(largger)
window screen(smaller, 1)-(largger, 500)
doscreen:
pset(v(1), 1), 15
for z = 2 to 500
line -(v(z), z), 15
next
for j = 1 to 30
_delay 0.1
if _keydown(27) then exit for
next
cls
if _keydown(27) then exit for
next
system
100 n = 0
resume endoflongcase
' :
' :
'then what follows are the functions to plot graphs with.
forceq-graph.bas.zip (Size: 125.59 KB / Downloads: 34)
|
|
|
|