Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file save/load variables  (Read 28568 times)

0 Members and 1 Guest are viewing this topic.

Risen91

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Unknown
    Re: Batch file save/load variables
    « 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.

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: Batch file save/load variables
    « 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!


    Risen91

      Topic Starter


      Rookie

      • Experience: Beginner
      • OS: Unknown
      Re: Batch file save/load variables
      « 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.

      Salmon Trout

      • Guest
      Re: Batch file save/load variables
      « 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?


      Salmon Trout

      • Guest
      Re: Batch file save/load variables
      « 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.


      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Batch file save/load variables
      « 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.

      Salmon Trout

      • Guest
      Re: Batch file save/load variables
      « 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.


      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: Batch file save/load variables
      « Reply #22 on: January 22, 2012, 03:53:38 PM »
      Or maybe take a break for awhile...
      " Anyone who goes to a psychiatrist should have his head examined. "

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Batch file save/load variables
      « 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.