Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

yanklines

- - - - -

  • Please log in to reply
52 replies to this topic

#51
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,579 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
[quote name='bphlpt' timestamp='1348209986' post='1012342']
Some like to have redundant checks everywhere, trying to make their code absolutely bulletproof. It will never happen, human error, machine error, and fate will prevent it, but you can get close.
[/quote]

I call that foolproof instead. :ph34r:

And of course:

[quotename='Dougals Adams' ]
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
[/quote]
;)
Usually it is a no-win/no-win situation, what you get at the end is more complex code/script, and anyway someone will be able to have it break or do something else. :(

I believe more in making the bare minimum checks and make the final user break it at will until he/she learns how to use it properly, i.e. make him/her more responsible, or if you prefer to behave more proactively than the usual "passive mode", expecially since batches/little .vbs scripts are normally a QUICK workaround around an issue or a more convenient way to run a set of otherwise complex commands.

The fact that I know not any other programming language and the usual guy which comes out saying "it can't be done in batch" sometimes causes the creation of one of my senselessly complex :w00t: batches (that a real programmer would write in a much more suitable language), but they still remain "quick and dirty tools" or (working ;) ) POC's, I would say that a suitable adjective for batches (and to a lesser extent .vbs) is "legacy":
http://homepage.ntlw...pejorative.html
[quote='Peter Langston' ]legacy (adj) — A pejorative term used in the computer industry meaning "it works"[/quote]

Now, the essence of a "quick and dirty" tool is to be BOTH quick AND dirty..... :whistle:


jaclaz


How to remove advertisement from MSFN

#52
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

IMHO this is - besides smaller - "plainer":
1.000 bytes instead of 1.356 BUT including 10 bytes for the "@ECHO OFF", so actually 366 bytes smaller or almost 27% smaller :w00t: ;).

Spoiler


jaclaz

How about this one :angel

SET tokens=1
:yanks
FOR /F "tokens=%tokens% delims=;" %%A IN ("If WScript.Arguments.Count <> 2 then;WScript.Quit;end If;Const ForReading=1, ForWriting=2;Dim i,j;Set objFSO=CreateObject("Scripting.FileSystemObject");Set objInputFile=objFSO.OpenTextFile(WScript.Arguments.Item(0),ForReading);Set objOutputFile=objFSO.OpenTextFile (WorkingDir & WScript.Arguments.Item(1),ForWriting,True);Set objDict=CreateObject("Scripting.Dictionary");objDict.CompareMode=1;j=0;On Error Resume Next;While Not objInputFile.AtEndOfStream;arrinputRecord=split(objInputFile.Readline,"vbNewLine");strFirstField=arrinputRecord(0);If objDict.Exists(strFirstField) then;j=j+1;Else;objDict.add strFirstField,strFirstField;End If;Wend;colKeys=objDict.Keys;For Each strKey in colKeys;objOutputFile.writeline objDict.Item(strKey);Next;objInputFile.Close;objOutputFile.Close") DO IF NOT "%%A"=="" (ECHO>>yanklines.vbs %%A& SET /a tokens+=1& GOTO :yanks)
It's smaller (924 bytes vs. 998 bytes) and you also don't need to use any carets. The lines are merged into one and separated using semicolons.
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#53
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,579 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

It's smaller (924 bytes vs. 998 bytes) and you also don't need to use any carets. The lines are merged into one and separated using semicolons.

And also completely unreadable.

jaclaz




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users