'echo' multiple variables with wildcard

Microsoft Windows xp pro with sp3 multil...
October 4, 2009 at 18:52:10
Specs: Windows XP
I have a script I just wrote which function
serves as a message encoder/decoder.

Simplified steps include:

1) It asks the user for input.
2) Each key stroke is given it's own variable
name/number (ie, char1ac, char2ac ...etc).
3) Each keystroke is re-assigned a new value
but keeping the same variable name.
4) The messages is re-built and displayed
using the echo command | and piped into a
.txt file for future use.

My problem is step 4. Since the user input
could be 3 keystrokes or 30, there is no set
number of variables created (char1ac) so I
can't just create a line that says:

echo %char1ac% %char2ac% ...etc

so I want a line that will echo all the variables
on one line but using a wildcard (or something
similar).

What I have now is just a loop that will echo
each keystroke, but this will appear on a
different line.

The goal is to keep the original keystroke
number intact... and the script does not create
empty variables.

How can I do this?


See More: echo multiple variables with wildcard

Report •


#1
October 5, 2009 at 01:09:26
dleite, what if you let it loop as it is until it encounters a carriage return (you can tell the user to hit 'return' when finished)?
HTH.
Ed in Texas.

Report •

#2
October 5, 2009 at 12:29:34
I need the output on one line after the
batch has processed the message...

One way I can get around is >> the
message to a .doc and then in Word
manually remove the paragraph breaks...
but this is an extra step.


Report •

#3
October 5, 2009 at 18:43:32
This should really be posted in the Programming Forum (on the right) where you will get much more expert help!

Home Page http://ewen.uuuq.com/


Report •

Related Solutions

#4
October 5, 2009 at 21:52:00
If you at least have a a counter to know how many variables you have you could do something like this:

for /l %%z in (1 1 %count%) do set /p = !char%%zac!<nul


You would also need to use "setlocal enabledelayedexpansion".

Their is one problem with using set /p this way, it won't take "=" as the first character, that's why I used the space as the first character(which will leave you with a leading space).


Batch Variable how to


Report •


Ask Question