Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How can I read a variables in PC-DOS?
Strangely things that work in MSDOS wont work in PC-DOS:Set this=that
echo %this%This works in Ms-Dos , but PC-Dos doesnt!?
Try it...
Anyone knows why?
I.love.scripting

Tried putting spaces around the = ??
Rule #1 Good computers don't go down.
Rule #2 There is no such thing as a good computer.

Thanks, I tried it before, test it again...
but doesnt work either!
PC-DOS keeps echoing me "%this" instead of "that" Online sources say PC-DOS using the same syntax as MS-DOS for environmental variables though...
I.love.scripting

Thanks Nigel, now I know at least the variable is set correct as it shows me the value when entering the SET command :)
Starting PC DOS...
PC DOS Version 7.00
(C)Copyright International Business Machines Corp 1981-1995.
A:\>SET X=Y
A:\>SET
PATH=
COMSPEC=A:\COMMAND.COM X=Y A:\>ECHO %X%
%X%A:\>
I'm using IBM PC-DOS 7.0 and 7.0 2000
Thanks :)
I.love.scripting

Damn, the board screwed up the spaces, so I post the code again:
Starting PC DOS...PC DOS Version 7.00
(C)Copyright International Business Machines Corp 1981-1995.A:\>SET X=Y
A:\>SET
PATH=
COMSPEC=A:\COMMAND.COM
X=YA:\>ECHO %X%
%X%A:\>
I.love.scripting

Of course we still dont know how to read back X.... So what's the use of storing variables if you cant use them? Maybe I have to write IBM?
I.love.scripting

Normally you use the variables to set up a program to start with certain parameters, not seldom hardware depending, or to "steer" a BAT file.
Assuming you are using a BAT file I think IF is what you are looking for.
http://www.computerhope.com/if.htm
Nigel

No come on... it has to work I also did it in MS-DOS. Look at the following batch example and try it in your windows command (add choice.com to C:\) or real DOS:
@ECHO OFF
CLS
PATH=C:\
ECHO Settings Menu
ECHO ================
ECHO.
ECHO blah blah blah...?
ECHO.
ECHO.
ECHO [1] Option 1
ECHO [2] Option 2
ECHO.
ECHO.
ECHO Enter your choice:
ECHO.
CHOICE /C:12 >NULSET SRC=%ERRORLEVEL%
ECHO You have entered %SRC%PAUSE >NUL
MS-DOS echos the correct value of the variable but in PC-DOS I cant seem to read it this way though it is stored. It seems that PC-DOS doesnt support Echo-ing a variable value. Besides...the IF statement doesnt work either, I tried that as well like:SET X=Y
IF "%X%"=="Y" ECHO OK...nothing is echoed by PC-DOS.
MS-DOS echoes OK!!
I.love.scripting

Beats me since I haven't used PC-DOS since the late 80's, and my DOS machine only comes up from the basement a few times a year :)
Maybe this will help a bit.Anyway good luck
Nigel

You example: set x=y works just fine under PC DOS 7.0 (Rev 0) - - and without the quotes or caps - - as a batch file.
Computers in the future may have only 1,000 vacuum tubes and perhaps only weigh 1 1/2 tons.
- Popular Mechanics, 1949

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |