Computing.Net > Forums > Windows XP > 'echo' multiple variables with wildcard

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.

'echo' multiple variables with wildcard

Reply to Message Icon

Name: dleite
Date: October 4, 2009 at 18:52:10 Pacific
OS: Windows XP
Product: Microsoft Windows xp pro with sp3 multilingual - oem
Subcategory: General
Tags: command, variable, echo, wildcard
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: Ed in Texas.
Date: October 5, 2009 at 01:09:26 Pacific
Reply:

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.


0

Response Number 2
Name: dleite
Date: October 5, 2009 at 12:29:34 Pacific
Reply:

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.


0

Response Number 3
Name: Ewen
Date: October 5, 2009 at 18:43:32 Pacific
Reply:

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/


0

Response Number 4
Name: Judago
Date: October 5, 2009 at 21:52:00 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: 'echo' multiple variables with wildcard

Multiple Desktops With Diff. Icons www.computing.net/answers/windows-xp/multiple-desktops-with-diff-icons/54655.html

Search Text With Wildcards www.computing.net/answers/windows-xp/search-text-with-wildcards/170308.html

backup batch with input www.computing.net/answers/windows-xp/backup-batch-with-input/161552.html