rudi Posted March 31, 2008 Posted March 31, 2008 Hi,is there a direct way to edit sections in batch files inbetween batch labels?Two things would have to be solved: Labels look like this: ":LABEL", and the lines normaly do not have a "=" in them.@echo off keyb gr goto %config% :minidos --- actions here goto END :fulldos --- actions there goto END :server --- other ones here goto END :ENDRegards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
PsaltyDS Posted March 31, 2008 Posted March 31, 2008 Hi, is there a direct way to edit sections in batch files inbetween batch labels? Two things would have to be solved: Labels look like this: ":LABEL", and the lines normaly do not have a "=" in them. @echo off keyb gr goto %config% :minidos --- actions here goto END :fulldos --- actions there goto END :server --- other ones here goto END :END Regards, Rudi. Choices: 1. Learn to use StringRegExpReplace() 2. Read the file to a string and parse it there. 3. Read the file to an array and parse it there. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
rudi Posted April 3, 2008 Author Posted April 3, 2008 Hi.Choices:1. Learn to use StringRegExpReplace()2. Read the file to a string and parse it there.3. Read the file to an array and parse it there. Currently I use 3. to get the content, then stringinstring() and 1.), but the ini*() functions are far more convenient. That's why I asked ...Any other suggestions?Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
PsaltyDS Posted April 3, 2008 Posted April 3, 2008 Hi.Currently I use 3. to get the content, then stringinstring() and 1.), but the ini*() functions are far more convenient. That's why I asked ...Any other suggestions?Regards, Rudi....so, take what you've got and put in functions that work like the native Ini*() functions. What are you looking for suggestions on? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
rudi Posted April 3, 2008 Author Posted April 3, 2008 ...so, take what you've got and put in functions that work like the native Ini*() functions.Sorry, I completely miss the sens of this advice What are you looking for suggestions on?Is the code of Iniwrite and Iniread available? Then I could learn from it to improve my ugly approach...Thanks for your reply, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
flyingboz Posted April 3, 2008 Posted April 3, 2008 Just write your parser, already... I would suggest: _BatReadSection _BatRead _BatWrite _BatWriteSection matching the parameter order to those used by the INI functions. Nobody is seriously going to add something this oddball to the native lang funcs. Read the file into memory. Loop through files creating your sections, identified with lines that begin with a single ":" , remember that "::" is a comment (more accurately, an illegal line ignored by the parser) each line beginning with "set " and containing an "=" sign creates a variable / value section ends with another valid section or EOF. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
rudi Posted April 3, 2008 Author Posted April 3, 2008 (edited) Hi,thanks for your suggestionsremember that "::" is a comment (more accurately, an illegal line ignored by the parser)Beside this one :LABELs have *NOT* to start with numbers.:PRO100 is OK :3C90X will not work That's the real reason, why it's better to choose a Intel NIC Regards, Rudi. Edited April 3, 2008 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE!
flyingboz Posted April 3, 2008 Posted April 3, 2008 (edited) :3C90X will not work You better either test first or clarify more, or provide a link to your documentation reference, which you perhaps misread or misapplied On XPPSP2: :foo goto :3cfoo exit /b 1 :3cfoo echo 3cfoo exit /b 0 echos 3cfoo and exits with errorlevel set to 0 .... edit: adjusted tonality. Edited April 4, 2008 by flyingboz Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now