Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 06-28-07   #1 (permalink)
Security Sleuth
 
SoBe8503's Avatar
 
amd nvidia

Join Date: Jan 2005
Location: Fort Collins, CO
Posts: 738

Rep: 81 SoBe8503 is acknowledged by some
Unique Rep: 60
FAQs Submitted: 3
Trader Rating: 0
Default help with turning lines of text into variables

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
Quote:
Originally Posted by FrankenPC View Post
When my GF asked me if I thought she was fat, I said yes.

System: Dont be lookin at my junk!
CPU
AMD 64 3500+
Motherboard
Asus A8N SLI Delux
Memory
1024 MB
Graphics Card
128 MB
Hard Drive
Almost a TB
Sound Card
built in MB
Power Supply
600 watt
Case
embarassing
OS
XP Pro
Monitor
Some cheap Flat Panel
SoBe8503 is offline   Reply With Quote
Old 06-28-07   #2 (permalink)
Security Sleuth
 
SoBe8503's Avatar
 
amd nvidia

Join Date: Jan 2005
Location: Fort Collins, CO
Posts: 738

Rep: 81 SoBe8503 is acknowledged by some
Unique Rep: 60
FAQs Submitted: 3
Trader Rating: 0
Default

I got it!
Put the default arguments into a file with the same name as the batch and extension arg
Quote:
@echo off
if "%~1" EQU "" if exist %~dpn0.arg (
set /P StdArg=<%~dpn0.arg
call "%~f0" %StdArg%
exit /B
)
:: batch code here
__________________
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
Quote:
Originally Posted by FrankenPC View Post
When my GF asked me if I thought she was fat, I said yes.

System: Dont be lookin at my junk!
CPU
AMD 64 3500+
Motherboard
Asus A8N SLI Delux
Memory
1024 MB
Graphics Card
128 MB
Hard Drive
Almost a TB
Sound Card
built in MB
Power Supply
600 watt
Case
embarassing
OS
XP Pro
Monitor
Some cheap Flat Panel
SoBe8503 is offline   Reply With Quote
Old 07-01-07   #3 (permalink)
110100001101001111000
 
C-bro's Avatar
 
intel nvidia

Join Date: Jan 2006
Location: Hamilton, ON
Posts: 1,832

Rep: 283 C-bro is a proven memberC-bro is a proven memberC-bro is a proven member
Unique Rep: 215
FAQs Submitted: 6
Folding Team Rank: 237
Hardware Reviews: 9
Trader Rating: 1
Default

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.

System: RAID0R
CPU
Intel E2180 3.33GHz
Motherboard
Asus P5K-E/WIFI-AP vMod
Memory
2GB Kingmax DDR2-1066
Graphics Card
EVGA 8800GT
Hard Drive
2x250GB WD+500GB 7200.11
Sound Card
SB Audigy 2
Power Supply
Corsair CMPSU-550VX
CPU cooling
Arctic Cooling Freezer 7 Pro
GPU cooling
Zalman VF900-Cu
OS
Windows Vista Business 32-Bit
Monitor
HP F2105 21" & Samsung 712N
C-bro is offline I fold for Overclock.net Overclocked Account C-bro's Gallery   Reply With Quote
Old 07-02-07   #4 (permalink)
Photography nut
 
dangerousHobo's Avatar
 
amd nvidia

Join Date: Dec 2005
Location: ~/
Posts: 3,470

FAQs Submitted: 7
Folding Team Rank: 390
Trader Rating: 0
Default

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:
Originally Posted by Melcar
Only one reasonable way to solve this... a dance off.

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

System: Anomaly
CPU
Athlon 3700 SD(KACAE)0546 @3.02ghz
Motherboard
DFI UT nF4 Ultra-D
Memory
G.Skill 2x512 UTT(BH-5)
Graphics Card
evga 6800gs
Hard Drive
Maxtor 300GB + WD 250GB
Sound Card
onboard
Power Supply
Ultra 500w V-series
Case
one from Ultra
CPU cooling
Big Typhoon
GPU cooling
80mm fan mounted on
OS
Arch64
Monitor
Acer AL2216W 22" WS LCD
dangerousHobo is offline I fold for Overclock.net Overclocked Account dangerousHobo's Gallery   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 01:22 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.20452 seconds with 8 queries