Length of a string - my first contribution
Posted: 20 May 2018 16:10
Hi guys!
First I would like to say big Thank You! Thank you dbenham, jeb, Aacini, aGerman and others.
Although I dont use your amazing results at my work nor for making any profit I really appreciate them. It is not only about your results but it is rather about your attitude.
It may sound a little bit theatrically: Thank you for your existence!
Our world is full of idiots which we have to deal with and it is much easier trying to live my life knowing that somewhere on a planet somebody is thinking the very similar way as myself.
Many years ago I tried to write my first cmd script and I needed to measure a lenght of a string. Because this forum didnt exist at that time I had to type my own.
At the very same moment I tried to find out what big boys from Microsoft might mean when they talked about "Unicode". I worked with Excel at that time.
My whole idea was this:
@set "myVar=qwertyuiop"
@cmd /U /S /D /c set myVar|find /V /N ""
It is not necessary to write more details at this forum I am sure.
Another obvious option is a switch /C instead of /N
(Btw My biggest problem during those old days was to accept using an empty string with the switch /V. I had no idea that this sort of cripled thinking might exist in IT business at all. It is so obvious to me only by pure logic that empty string is a substring of every string - apparently not obvious for MS. My script without /V worked well and with shorter and shorter string-to search argument the number of found lines went up and up and at he very last step the script stopped working totally - no results at all. I had no idea why, it was very frustrating.
@cmd /U /S /D /c set myVar|find /V /C ""
I am almost sure that this method is totally "toxic-character-proof". According to some scripts I have seen at this board I dont dare to say my usual and humble estimate of my own certainty - I mean 100%
My second contribution in a few next days will be a small one. How to avoid disaster if any toxic character is in a path of your data and scripts. How to safely call them using CMD command. Yes, I was so naive that I have created my own system of naming backups and incremental backups of all my files and in this system the most frequent character is a ^ carret
. Lucky guy I am. I simply read MS documents and it was written that it is possible and no problem was meant - so I did it. I was young, naive and happy.
My biggest (not from the pragmatic point of view of course) contribution which I am really proud of will be an ultimate method of obtainig all command line arguments of a sript inside from the script of course. With no compromise, without any temp file. And storing these arguments inside a normal named variable like %myVar%, not %1.
I dont care about the speed (I care but there is no principal difference in a speed - the upper bound of time is polynomial depending on a lenght of an input
)
I took this goal as my personal chalenge. I have to addmit I almost gave up but finally it is done.
I can say I would have absolutely no chance to create such a script without a knowledge from this forum especially of Jeb, dbenham and Aacini.
To be honest I dont believe that such a script has not been written till this time. The same feeling I have with the idea of this post - measuring the lenght of a given string. But I tried really hard to search the Web and no success.
If anybody thinks that it would be better to move this post to somewhere where it belongs more I will be pleased.
Jan Antonin
First I would like to say big Thank You! Thank you dbenham, jeb, Aacini, aGerman and others.
Although I dont use your amazing results at my work nor for making any profit I really appreciate them. It is not only about your results but it is rather about your attitude.
It may sound a little bit theatrically: Thank you for your existence!

Many years ago I tried to write my first cmd script and I needed to measure a lenght of a string. Because this forum didnt exist at that time I had to type my own.
At the very same moment I tried to find out what big boys from Microsoft might mean when they talked about "Unicode". I worked with Excel at that time.
My whole idea was this:
@set "myVar=qwertyuiop"
@cmd /U /S /D /c set myVar|find /V /N ""
It is not necessary to write more details at this forum I am sure.
Another obvious option is a switch /C instead of /N
(Btw My biggest problem during those old days was to accept using an empty string with the switch /V. I had no idea that this sort of cripled thinking might exist in IT business at all. It is so obvious to me only by pure logic that empty string is a substring of every string - apparently not obvious for MS. My script without /V worked well and with shorter and shorter string-to search argument the number of found lines went up and up and at he very last step the script stopped working totally - no results at all. I had no idea why, it was very frustrating.
@cmd /U /S /D /c set myVar|find /V /C ""
I am almost sure that this method is totally "toxic-character-proof". According to some scripts I have seen at this board I dont dare to say my usual and humble estimate of my own certainty - I mean 100%

My second contribution in a few next days will be a small one. How to avoid disaster if any toxic character is in a path of your data and scripts. How to safely call them using CMD command. Yes, I was so naive that I have created my own system of naming backups and incremental backups of all my files and in this system the most frequent character is a ^ carret

My biggest (not from the pragmatic point of view of course) contribution which I am really proud of will be an ultimate method of obtainig all command line arguments of a sript inside from the script of course. With no compromise, without any temp file. And storing these arguments inside a normal named variable like %myVar%, not %1.
I dont care about the speed (I care but there is no principal difference in a speed - the upper bound of time is polynomial depending on a lenght of an input

I took this goal as my personal chalenge. I have to addmit I almost gave up but finally it is done.
I can say I would have absolutely no chance to create such a script without a knowledge from this forum especially of Jeb, dbenham and Aacini.
To be honest I dont believe that such a script has not been written till this time. The same feeling I have with the idea of this post - measuring the lenght of a given string. But I tried really hard to search the Web and no success.
If anybody thinks that it would be better to move this post to somewhere where it belongs more I will be pleased.
Jan Antonin