Computing.Net > Forums > Disk Operating System > IF Statement Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

IF Statement Help

Reply to Message Icon

Name: Troncc
Date: July 3, 2003 at 18:06:23 Pacific
OS: Win98SE
CPU/Ram: more than enough
Comment:

I am writing a batch program using input environment variables. My problem deals with the dos limitation in comparing punctuation variables. Partial Example:

:: %KEY% CAN EQUAL ANY PUNTUATION
GETKEY
IF %KEY%==, SET Y=1
IF %KEY%==; SET Y=2
----------------
The following does not work. (Almost every other puntuation variable works). And I need to be able to compare all puntuation %variables%.
IF ,==, SET Y=1
IF ;==; SET Y=2
...

I am completely stumped on how to work around this problem. I have been looking for different "freeware" programs to output different %variables% for the typed keys that can be compared using the IF statement, but the closest I've come is XSET 5.37 and that program is a @%&^ing "shareware" program that has a pause delay built in.

If nobody has any ideas then I'm just going to output the variables to a temp.txt file then do a running file compare/match on it. It's slower, but at least then I can continue my program.

For anyone that has a good workaround to my problem e-mail me and I'll make it worth your while.

Thanks in advance




Sponsored Link
Ads by Google

Response Number 1
Name: Troncc
Date: July 3, 2003 at 18:11:43 Pacific
Reply:

I forgot to include my e-mail address sorry:

Troncc @hotmail.com


0

Response Number 2
Name: Secret_Doom
Date: July 4, 2003 at 07:24:40 Pacific
Reply:

Comparing files is a way around, but as you said, it's too slow. I know a work around that will not use files, just variables. You can use it to compare any sort of SETable strings (so, they may contain commas, semicolons, spaces, etc). It is not that simple, though:

:: Check if "%KEY%"==";"
set _;=
set _%KEY%=$
if "%_;%"=="$" echo TRUE!
if not "%_;%"=="$" echo FALSE!
set _%KEY%=

It is a strange syntax, and is pretty counter-intuitive, but it works and you can understand it if you look at the code for a while.

I explained that method on the following thread:
http://www.computing.net/dos/wwwboard/forum/13310.html

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: IF Statement Help

Add IF statement to batch file www.computing.net/answers/dos/add-if-statement-to-batch-file/13947.html

IF command-Batch file help needed! www.computing.net/answers/dos/if-commandbatch-file-help-needed/13047.html

Help with deleting files by date... www.computing.net/answers/dos/help-with-deleting-files-by-date/9101.html