|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming | |
help with turning lines of text into variables
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | |||||||||||
|
Security Sleuth
|
Hello again,
Is it possible to take a list of words from one text file and use each one as a variable in a batch file?? Right now I'm doing something like this... Echo %1 %2 %3 so in the command prompt I have to type each variable in after the batch file name (C:\>test.bat var1 var2 var3 etc.) So instead of typing the variables, the text file would provide them for me. Am I even making sense?
__________________
There's no place like 127.0.0.1 Life Lesson: Procrastinate Later Never hold a dust buster and a cat at the same time How manually restore system registry windows How see security tab my windows XP Machine
|
|||||||||||
|
|
|
|
|
#2 (permalink) | ||||||||||||
|
Security Sleuth
|
I got it!
Put the default arguments into a file with the same name as the batch and extension arg Quote:
__________________
There's no place like 127.0.0.1 Life Lesson: Procrastinate Later Never hold a dust buster and a cat at the same time How manually restore system registry windows How see security tab my windows XP Machine
|
||||||||||||
|
|
|
|
|
#3 (permalink) | ||||||||||||
|
110100001101001111000
|
Very helpful. Is this possible in other languages? Something where you could could have a text file containing:
int x = 5; double y = 3; And have a program read those lines as if they were in the code themselves? I would imagine not, since the code gets compiled and built before running, but I guess I can hope.
__________________
|
||||||||||||
|
|
|
|
#4 (permalink) | ||||||||||||||
|
Photography nut
![]() |
I know you can do it in other languages like perl and ruby, where you can have it go through a whole file of number or whatever, and it'll use them like args.
file would be something simple like: 5 10 12.2 Some text 4 56 etc... Something similar could be done in java using args[#]. If its a mix of primitive types though it'd become harder b/c everything would have to be a string and if you need something to act like a number then you'd have to parse it. Where in something like perl it converts between string and numbers depending on how its being used, so its a much easier process in a high level language like that.
__________________
"UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." - Doug Gwyn Try out the latest Programming Challenge Quote:
CPU-Z Validation @ 2.97-prime95 stable 16 hours @ 1.48v Proof | CPU-Z Validation @ 3.15 Getting Mouse Side Buttons to work in Linux, Compile a custom Kernel, More
|
||||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|