Sign in to follow this  
Followers 0
rudi

Some function like IniWrite() to edit sections in .BAT batches?

8 posts in this topic

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.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

...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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi,

thanks for your suggestions

remember 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 :)

:party::lmao: That's the real reason, why it's better to choose a Intel NIC ^_^:idea:

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

:3C90X will not work :party:

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 by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0