QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: FilipeEstima on March 04, 2020, 10:32:57 pm
-
Hi guys, I'm very excited to try the new QB64 version 1.4. These keyboard LEDs functions and statements were something I was needing very badly. I want to create a piece of software "kbdleds.exe" that can be called from command-line with arguments passed like this:
kbdleds.exe c1 n0 s1 (this will make Caps Lock ON, Num Lock OFF, Scroll Lock ON)
kbdleds.exe a0 (this will make all 3 LEDs OFF)
kbdleds.exe ct (this will toggle Caps Lock)
However, I don't know how to read arguments passed via command line, or from a batch file. Help here, please?
-
Nevermind, I figured it out: I can get the parameters with COMMAND$ :-)
Now it's coding time.
-
Yay! 😁
-
If your LEDs are in a line, and you blink them back and forth, the cat will clean your keyboard.
-
I'm having a problem with COMMAND$; whatever is after ">" is discarded and I don't know how to prevent it. I want my program to be able to receive ">nul" after all parameters, so instead of printing it will do the task then go SYSTEM. But since COMMAND$ suppresses everything that comes after ">", I can't get ">nul" into the program.
-
Anything beyond > is dealt with by your os. Anything before that is yours to manipulate.
-
Thanks FellippeHeitor, I didn't realize that had to do with the OS. Anyway, here's the code:
curr$
= LEFT$(param$
, 2): param$
= MID$(param$
, 4)
IF wrong
THEN PRINT "Usage: TOGGLEW [+c|-c] [+n|-n] [+s|-s] [-silent]":
END
PRINT "TOGGLEW 1.0 (c) Filipe Estima" PRINT "Inspired by TOGGLE (c) 1988 Ziff Communications Co."
I drew inspiration from TOGGLE, an utility developed by Jeff Prosise for MS-DOS back in 1988, while he worked at PC Magazine. It is just 338 bytes long and does exactly the same as this code.
-
What are the tags I need to use in order to post code that looks like QBASIC code in this forum?
Edit: nevermind, I figured it out.
-
What are the tags I need to use in order to post code that looks like QBASIC code in this forum?
It is the QB64 Icon button or
[ code = qb64 ] [ / code ]
without spaces
-
You may benefit from using COMMAND$ as an array. Try:
-
I took the liberty:
CASE "-silent": silent
= 1
PRINT "TOGGLEW 1.0 (c) Filipe Estima" PRINT "Inspired by TOGGLE (c) 1988 Ziff Communications Co."
-
Hey, much better! Thanks FellippeHeitor, I didn't have a clue it was possible to write directly to the prompt: never knew _DEST _CONSOLE even existed.
-
I noticed that, since the program is now writing to the console, I don't need the -silent switch anymore. It will work just fine with >nul.
-
Glad I could help 🙂