Jump to content

Need batch to create and read thru' Arrays.


Recommended Posts

I've attached the CMD that works for me in XPx64. The only change made from the script I posted above was to replace the reference from Disks.txt to %~dpnx1, so it takes the input file as a parameter.

Unbound.cmd

Link to comment
Share on other sites


I tried to reply to this forum and then I saw 'you cannot reply to this Thread' :wacko: !! I looked around and realized -- I wasn't logged in :lol: !!

So now I'm logged in! ( Obviously !!)

I tried 5eraph's script and it worked like a charm (tested on a x64 machine with 64 bit OS).... so it seems it might not work properly on a 32 bit OS (good to know).

Anyways, enough of chatter ! I will put all ur scripts to test ! I will be running them on some servers to see how it goes...

Thanks again for the Posts !! U GUYZ R AWESOME :thumbup !!!

Link to comment
Share on other sites

You're welcome, Marcos. And thanks for testing my script yourself. :)

In the following example the text file should be named "Disks.txt".
I tried the various batches timing them on the sample file posted, which I saved as "unbound.txt".

This is why jaclaz's copy of my script failed. It depended upon the file being named Disks.txt.

Updated, copy/paste problem was to blame.

A 10x run of my script takes 1.1 seconds on my machine, when PAUSE is removed.

My speedtest script:

@ECHO OFF
SETLOCAL EnableDelayedExpansion
CALL :Func_TimeStamp
SET /A nStartTime=!nTimeStamp_FuncResult!
FOR /L %%G IN (1,1,10) DO (CALL Unbound.cmd Unbound.txt)
CALL :Func_TimeStamp
CALL :Func_ElapsedTime !nStartTime! !nTimeStamp_FuncResult!
PAUSE
GOTO :eof

:Func_TimeStamp
:: Set TimeStamp as the number of hundredths of seconds so far today
FOR /F "tokens=1-3 delims=:" %%Q IN ("!TIME!") DO (
SET "H_TimeStamp=%%Q"
SET "M_TimeStamp=%%R"
IF "!H_TimeStamp:~0,1!"=="0" (SET "H_TimeStamp=!H_TimeStamp:~1!")
IF "!M_TimeStamp:~0,1!"=="0" (SET "M_TimeStamp=!M_TimeStamp:~1!")
FOR /F "tokens=1-2 delims=." %%T IN ("%%S") DO (
SET "S_TimeStamp=%%T"
SET "SS_TimeStamp=%%U"
IF "!S_TimeStamp:~0,1!"=="0" (SET "S_TimeStamp=!S_TimeStamp:~1!")
IF "!SS_TimeStamp:~0,1!"=="0" (SET "SS_TimeStamp=!SS_TimeStamp:~1!")
SET /A "nTimeStamp_FuncResult=!H_TimeStamp! * 360000 + !M_TimeStamp! * 6000 + !S_TimeStamp! * 100 + !SS_TimeStamp!"
) )
GOTO :eof

:Func_ElapsedTime
:: Work out the elapsed time to the hundredth of a second. Do the correct calculation to
:: account for roll-over (assumes the whole elapsed time is always less than 24 hours).
IF %2 GEQ %1 (SET /A "Local_ElapsedTime=%2 - %1") ELSE (SET /A "Local_ElapsedTime=%2 + 8640000 - %1")
SET "LocalMessage_ElapsedTime=Total time elapsed: "

:: Split elapsed time into hours, minutes and seconds
SET /A "Hours_ElapsedTime=!Local_ElapsedTime! / 360000"
SET /A "Minutes_ElapsedTime=(!Local_ElapsedTime! - !Hours_ElapsedTime! * 360000) / 6000"
SET /A "Seconds_ElapsedTime=(!Local_ElapsedTime! - !Hours_ElapsedTime! * 360000 - !Minutes_ElapsedTime! * 6000) / 100"
SET "Hundredths_ElapsedTime=!Local_ElapsedTime:~-2!"
IF "!Hundredths_ElapsedTime!"=="!Hundredths_ElapsedTime:~0,1!0" (SET "Hundredths_ElapsedTime=!Hundredths_ElapsedTime:~0,1!")

:: If a field is zero then do not display that field in the formatted result
IF "!Hours_ElapsedTime!"=="0" (SET "Hours_ElapsedTime=") ELSE (SET "Hours_ElapsedTime= !Hours_ElapsedTime!h")
IF "!Minutes_ElapsedTime!"=="0" (SET "Minutes_ElapsedTime=") ELSE (SET "Minutes_ElapsedTime= !Minutes_ElapsedTime!m")
IF NOT "!Hundredths_ElapsedTime!"=="0" (SET "Seconds_ElapsedTime= !Seconds_ElapsedTime!.!Hundredths_ElapsedTime!s") ELSE (
IF "!Seconds_ElapsedTime!"=="0" (SET "Seconds_ElapsedTime=") ELSE (SET "Seconds_ElapsedTime= !Seconds_ElapsedTime!s"))

:: If no time elapsed then set time as zero seconds.
IF "!Hours_ElapsedTime!!Minutes_ElapsedTime!!Seconds_ElapsedTime!"=="" (SET "Seconds_ElapsedTime= 0s")

ECHO !LocalMessage_ElapsedTime!!Hours_ElapsedTime!!Minutes_ElapsedTime!!Seconds_ElapsedTime!
GOTO :eof

Edited by 5eraph
Link to comment
Share on other sites

This is why jaclaz's copy of my script failed. It depended upon the file being named Disks.txt.

A 10x run of my script takes 1.1 seconds on my machine, when PAUSE is removed.

Well, I did change the name in the batch from disks.txt to unbound.txt, obviously.

Now that I can do a binary compare of the copy/paste with your original attachment, it is clear that the issue is "trailing spaces", replacing 200D0A with 0D0A solves the issue.

Opera browser, copy -> Paste in notepad, Win XP 32 bit.

On my machine it runs in a x10 loop in around 80/100th

Cross posting on:

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

My speedtest script introduces some error because it takes time to create the timestamp. It was written to measure time for operations taking hours, not fractions of a second.

Cross posting on:

That topic seems to have been moved to a place I cannot access, I can't read it.

The copy/paste works fine in Firefox, which is the reason I discounted that possibility. Thanks for checking. :)

Link to comment
Share on other sites

Yep, it is in a "developers" only test/report section, sorry for not noticing it.

However nothing that cannot be re-posted publicly:

It seems like text insode CODE tags gets some extra trailing spaces. :ph34r:

Of course this ***** up very often batch code inside it.

Example:

Is it a "new setting" of the board?

Can it be fixed?

Do we need a "trailing space eliminator" and/or to post a BIG WARNING SIGN?

:unsure:

jaclaz

Following are several tests, but not yet a definite solution (also because of the board software change).

The copy/paste works fine in Firefox, which is the reason I discounted that possibility. Thanks for checking. :)

This is strange.

I will post the following text but without double quotes : "This text has NO trailing spaces" normally, inside a QUOTE, inside a CODE and inside a CODEBOX:

This text has NO trailing spaces

This text has NO trailing spaces

This text has NO trailing spaces

This text has NO trailing spaces

In Opera, plain, QUOTE and CODE have NO trailing spaces, but the CODEBOX has it.

If I try with two lines:

"This text has NO trailing spaces

and is on 2 lines"

This text has NO trailing spaces

and is on 2 lines

This text has NO trailing spaces

and is on 2 lines

This text has NO trailing spaces
and is on 2 lines

This text has NO trailing spaces
and is on 2 lines

plain and QUOTE are OK, in CODE first line has an added trailing space, and in CODEBOX last line has a trailng space. :w00t:

With Ie, the results are similar. :ph34r:

What happens in Firefox? :unsure:

jaclaz

I am attaching opera.txt and ie.txt made by copying from "This is strange" (included) up to :w00t: (excluded) pasted in Notepad.

Run a binary comparison of the two and you will see the differences.

Can you do the same and upload firefox.txt?

opera.txt

ie.txt

Edited by jaclaz
Link to comment
Share on other sites

I usually use notepad2-mod, but have pasted the text from Firefox v10.0 into Microsoft's Notepad, saved with ANSI encoding, and attached it below for comparison.

I hope this helps.

I don't know which program is best for making comparisons since I don't do it often. mirkes.de Tiny Hexer shows a great many differences between Opera and IE, and Opera and Firefox. But not quite so many between Firefox and IE. Still quite a difference though.

firefox.txt

Edited by 5eraph
Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...