Selecting which command to use.

Oem / Oem
March 21, 2009 at 15:25:33
Specs: XP Pro, p4-1.6/1GB
In Windows XP when writing batch scripts, and there is more than one command, or series of commands, which will achieve an outcome, how do you decide which command or commands to use?

Example:
To extract details from the %date% variable you could use a For loop or you could use a series of Set commands.

Do you use any guidelines as to which is the better/more efficient/faster command, not just in extracting details from the %date% but in other circumstances where an option is available?

Note that I'm not asking which command to use to achieve an outcome, I'm asking why you choose one option instead of another.

Thanks


See More: Selecting which command to use.

Report •


#1
March 21, 2009 at 20:53:58
In a word; experiance.

Stuart


Report •

#2
March 21, 2009 at 21:53:19
What, you're looking for style guidelines?

Use CALL for subfunctions and GOTO for loops. Use substring parsing as required; token based when convenient. Avoid nesting parentheses, as it can only end (prematurely) in pain.. Delayed expansion is nice, but you must sacrifice exclamation marks. Follow these rules, and you'll avoid some headaches.

Valerie: which is the better/more efficient/faster command
Boy, did you pick the wrong language. The better command is the one that'll fail on you less often, and is thus dependent on the situation. Efficiency is whichever command is easier to read. And speed has nothing to do with this conversation.


Report •

#3
March 21, 2009 at 23:39:43
StuartS: In a word; experiance.

Not prepared to give us the benefit of your experiance.? Somewhere along the line you must have picked up a idea or two as to which command performs better than others.

Razor2.3 - Thank you for your comments.


Report •

Related Solutions

#4
March 22, 2009 at 00:02:55
Not quite to the point, but for use on CN I avoid long lines because if I don't use tags the linebreaks get all wonky. And if I do... well, you've seen it. rest of the thread is 4 screens wide.


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#5
March 22, 2009 at 00:22:38
>> Efficiency is whichever command is easier to read.

No, that's readability.

Efficiency does deal with speed, in both writing code and code execution.


Report •

#6
March 22, 2009 at 00:25:58
FishMonger: No, that's readability.
Admittedly yes, but that wasn't the point.

Report •


Ask Question