Home / Microsoft / Microsoft DOS / Batch file save/load variables
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: Batch file save/load variables  (Read 580 times)
Risen91
Topic Starter
Rookie



Posts: 24

Experience: Beginner
OS: Unknown

« Reply #15 on: January 22, 2012, 10:27:01 AM »

The OUTPUT of the batch file!!!! You obviously didn't even bother to read the code and SEE THE SIX ECHO STATEMENTS IN THERE AND THE TYPE COMMAND THAT WAS OUTPUTTING WHAT IT NOW IN THE STATS FILE!

dude chill out? When you put the output as:
Quote
Strength 25
Health 100
Intellect 50
Strength 35
Health 95
Intellect 42
strength=35
health=95
intellect=42
I thought that it was simply adding the new values to the end, not overwriting them... and no I didn't bother to read it, want to know why? Because I don't understand the code, I'm new to batch files. Simple misunderstanding that's all.
IP logged
Squashman
Hopeful



Thanked: 25
Posts: 341

Experience: Experienced
OS: Other



« Reply #16 on: January 22, 2012, 03:04:44 PM »

dude chill out? When you put the output as:I thought that it was simply adding the new values to the end, not overwriting them... and no I didn't bother to read it, want to know why? Because I don't understand the code, I'm new to batch files. Simple misunderstanding that's all.
So are you going to just run any code someone gives you just willy nilly without knowing what the code does?  For all you know I could have thrown in some code to delete all your My documents!  I could have sat there and called a bunch of sub routines or built some other undecipherable variable that when expanded would would delete all your My Documents.

If you don't understand the code you should have asked what the code was doing or at least ran it to see what it was doing instead of assuming it did something.  Because we all know what happens when we assume!

IP logged
Risen91
Topic Starter
Rookie



Posts: 24

Experience: Beginner
OS: Unknown

« Reply #17 on: January 22, 2012, 03:25:52 PM »

"or at least ran it to see what it was doing instead of assuming it " you just contradicted yourself by telling me not to run code that I don't understand, then telling me to run it despite not knowing  ::)
Its a help forum, I asked for help and I got the help I needed, I know a little and that the code you showed me isn't malicious, but not enough to know the things like: echo %%I=!%%I!>>settings.ini

Thread closed I got the help I needed.
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,950

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #18 on: January 22, 2012, 03:33:11 PM »

Because we all know what happens when we assume!

What happens when we rant immoderately?

IP logged


Proud to be European
Salmon Trout
Sage



Thanked: 546
Posts: 7,950

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #19 on: January 22, 2012, 03:38:27 PM »

dude chill out? When you put the output as:I thought that it was simply adding the new values to the end, not overwriting them

Well, I thought that at first, and I been dealing with batch files since Moses was knee high to a mezuzah. Risen91, please don't assume (!) we're all as crabby as that other guy.

IP logged


Proud to be European
Squashman
Hopeful



Thanked: 25
Posts: 341

Experience: Experienced
OS: Other



« Reply #20 on: January 22, 2012, 03:39:38 PM »

What happens when we rant immoderately?
Apparently I become that same guy.

I guess my whole point was that I find it very disrespectful when people don't even bother to understand the code and then just say that it won't work for them.  We all spend hours upon hours a week helping people on the Internet and the least they could do is take the time to learn what we are trying to teach.  You know the old saying "Give a man a fish.....Teach a man too fish...."  In this instance I think it was the former.
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,950

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #21 on: January 22, 2012, 03:44:54 PM »

I find it very disrespectful when people don't even bother to understand the code

You're going to see a lot of that at Computerhope. For the sake of your own sanity learn to get over it.

IP logged


Proud to be European
patio
Moderator
Genius



Thanked: 1069
Posts: 11,351

Experience: Beginner
OS: Windows 7


Maud' Dib

« Reply #22 on: January 22, 2012, 03:53:38 PM »

Or maybe take a break for awhile...
IP logged

   
"
All generalizations are false, including this one.  "
Squashman
Hopeful



Thanked: 25
Posts: 341

Experience: Experienced
OS: Other



« Reply #23 on: January 22, 2012, 05:48:15 PM »

or more compact... choose a unique variable name prefix and then you can use Set to do all the work of writing the values to file with one command.

settings.ini:

Code: [Select]
MyVarStrength=100
MyVarHealth=50
MyVarIntellect=65

Code: [Select]
@echo off

REM Read settings from file
for /f %%S in (settings.ini) do set %%S

REM Show settings now stored in memory
echo strength  %MyVarStrength%
echo health    %MyVarHealth%
echo intellect %MyVarIntellect%

REM alter a setting in memory
set /p MyVarHealth="Enter new value for health ? "

REM Write settings to file
set MyVar > settings.ini


One difference is that after a write to file the variable names in settings.ini will be in alphabetical order of name. Like this...

Code: [Select]
MyVarHealth=67
MyVarIntellect=65
MyVarStrength=100
I like this a lot better than my code.
IP logged
Pages: 1 [2]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / Batch file save/load variables « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.112 seconds with 19 queries.