QBASIC SET VARIABLE in DOS
QBASIC SET VARIABLE in DOS
Hello,
I have a Qbasic problem and I hope you can help me.
I would write a Qbasic program who ask me a 4 digit code
e.g. 1234
(and not A...z or 123)
And then use the "4 digit code" and SET it in the DOS variable NUMBER
In the DOS prompt I can type the followed code
SET NUMBER=1234
And if I check it in DOS
type: SET
And I see: NUMBER=1234
But how can I make this in Qbasic?
Greetings,
Andries.
I have a Qbasic problem and I hope you can help me.
I would write a Qbasic program who ask me a 4 digit code
e.g. 1234
(and not A...z or 123)
And then use the "4 digit code" and SET it in the DOS variable NUMBER
In the DOS prompt I can type the followed code
SET NUMBER=1234
And if I check it in DOS
type: SET
And I see: NUMBER=1234
But how can I make this in Qbasic?
Greetings,
Andries.
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Use INPUT "Enter a 4 digit number: ", number%
PRINT number%
PRINT number%
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Try this:
This can be used as a temporary setting that will not work after the QB program is done. It will be added to the list to view with:
PRINT ENVIRON$("NUMBER") ' will display the number only
To view the entire list of settings as SET would display them:
Use SHELL to SET it in DOS. By the way, how would you UNSET it in DOS? Restart PC? I don't recommend messing with SET as the QB program could set it temporarily and invisibly.
Code: Select all
PRINT "Enter a 4 digit number"
num$ = INPUT$(4)
PRINT num$
ENVIRON "NUMBER=" + num$
This can be used as a temporary setting that will not work after the QB program is done. It will be added to the list to view with:
PRINT ENVIRON$("NUMBER") ' will display the number only
To view the entire list of settings as SET would display them:
Code: Select all
DO
count = count + 1
PRINT ENVIRON$(count)
IF count MOD 20 = 0 THEN
PRINT "Press a key!": SLEEP
CLS
END IF
LOOP until ENVIRON$(count) = ""
Last edited by burger2227 on Tue Jun 22, 2010 3:05 pm, edited 1 time in total.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Mhh, I think it's the good way but it works not yet.
The followed error does I have:
With sample 1:
By running the code There is a error bij "INPUT$"
Expected: statement
(Sample 1 does not compile)
But by sample 2:
I can read the params from DOS but there is no setting from QB45 into this params field set.
And by the sample 3:
If I try to compile this rule:
ENVIRON "NUMBER=HELLO"
The following error is displayed on the screen:
"Out of Memory"
-------------------------------------------
What is the aim?
On my company we proceed to Windows 7.
We have create one "golden Image" for all type's of computers / notebooks.
All of this computers (I think approximately 1500) must have a unique number.
We fill in on each computer the ASSETTAG (from the BIOS)
And if we get the image on the computer we can read the ASSETTAG of the BIOS with *.VBS script.
And this number is the number of the Windows machine.
But we have different tools to set the ASSETTAG of this machine's
(different manufacturers)
I have create a BOOTABLE USB-key with a batch file.
But each tool has different params.
Now I would make a Batch or QB45 (DOS) tool
And if the USB start up I pressed a PCNumber.
Then SET the PCNumber in the DOS PARAMS
And also I can fill in the PCnumber without the list of params from the ASSETTAGTool.
e.q.
(QB?)Which PC number do you have?
Answer: 1234
(QB?) SET PCNUMBER=1234
And then I can make:
ASSETTAG.EXE /D /CA /-y %PCNUMBER%
And the I can RESET the computer and set the GoldenImage on this machine.
-------------------------------------------
I hope you can understand me, my English is not optimum
The followed error does I have:
With sample 1:
By running the code There is a error bij "INPUT$"
Expected: statement
(Sample 1 does not compile)
But by sample 2:
I can read the params from DOS but there is no setting from QB45 into this params field set.
And by the sample 3:
If I try to compile this rule:
ENVIRON "NUMBER=HELLO"
The following error is displayed on the screen:
"Out of Memory"
-------------------------------------------
What is the aim?
On my company we proceed to Windows 7.
We have create one "golden Image" for all type's of computers / notebooks.
All of this computers (I think approximately 1500) must have a unique number.
We fill in on each computer the ASSETTAG (from the BIOS)
And if we get the image on the computer we can read the ASSETTAG of the BIOS with *.VBS script.
And this number is the number of the Windows machine.
But we have different tools to set the ASSETTAG of this machine's
(different manufacturers)
I have create a BOOTABLE USB-key with a batch file.
But each tool has different params.
Now I would make a Batch or QB45 (DOS) tool
And if the USB start up I pressed a PCNumber.
Then SET the PCNumber in the DOS PARAMS
And also I can fill in the PCnumber without the list of params from the ASSETTAGTool.
e.q.
(QB?)Which PC number do you have?
Answer: 1234
(QB?) SET PCNUMBER=1234
And then I can make:
ASSETTAG.EXE /D /CA /-y %PCNUMBER%
And the I can RESET the computer and set the GoldenImage on this machine.
-------------------------------------------
I hope you can understand me, my English is not optimum
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
My bad! I was kinda busy when I posted code:
Sorry!
You can also try SET by using SHELL.
Code: Select all
PRINT "Enter a 4 digit number"
num$ = INPUT$(4)
PRINT num$
ENVIRON "NUMBER=" + num$
You can also try SET by using SHELL.
Code: Select all
SHELL "SET NUMBER=1234"
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
gives nothing.
I am already glad that you try to help me!
but....
the first code works!
But you can not see the key who I pressed (realtime)?
Is that correct?
(I can see it with the PRINT COMMAND but it is less beautyfull)
And
gives immediately a "Memory error"
I Hope that you can help me again..
I am already glad that you try to help me!
but....
the first code works!
Code: Select all
PRINT "Enter a 4 digit number"
num$ = INPUT$(4)
PRINT num$
Is that correct?
(I can see it with the PRINT COMMAND but it is less beautyfull)
And
![Sad :-(](./images/smilies/icon_sad.gif)
Code: Select all
ENVIRON "NUMER=" + num$
I Hope that you can help me again..
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Either the computer is blocking the change or the environmental variable is overflowing the memory allowed. It is limited!
DID you try the SHELL?
SHELL "SET NUMBER=" + num$
That should work same as DOS. You said it worked in DOS right?
You can try LOCATE , , 1 to display the cursor, but it does not work on my XP. After INPUT$(4) procedure use LOCATE , , 0 to set it back.
DID you try the SHELL?
SHELL "SET NUMBER=" + num$
That should work same as DOS. You said it worked in DOS right?
You can try LOCATE , , 1 to display the cursor, but it does not work on my XP. After INPUT$(4) procedure use LOCATE , , 0 to set it back.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Thanks for your reply again...
But I think, I must give it up.
If I try the there is no memory error.
But if I look on the DOS prompt with the command SET there is no variable NUMBER.
I do not get it.
If I start up with DOS and type
And I type SET the variable NUMBER is set to 3 (NUMBER=3)
But if I would make it in QB45 it seems that it is not possible.![Question :?:](./images/smilies/icon_question.gif)
But I think, I must give it up.
If I try the
Code: Select all
SHELL "SET NUMBER=" + num$
But if I look on the DOS prompt with the command SET there is no variable NUMBER.
I do not get it.
![Sad :(](./images/smilies/icon_sad.gif)
If I start up with DOS and type
Code: Select all
SET NUMBER=3
But if I would make it in QB45 it seems that it is not possible.
![Question :?:](./images/smilies/icon_question.gif)
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
You have to view the settings INSIDE a Qbasic program!
The value will disappear when the Qbasic program ends! It is not permanent! I cannot get it to work either. Out of memory.
However if you set the number at the beginning of the QB program it may be there when you need it IN the program. NOT DOS!
If that does not work, then create a batch file IN the Qbasic program and run it after it is made.
The value will disappear when the Qbasic program ends! It is not permanent! I cannot get it to work either. Out of memory.
However if you set the number at the beginning of the QB program it may be there when you need it IN the program. NOT DOS!
If that does not work, then create a batch file IN the Qbasic program and run it after it is made.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0