Search found 59 matches

by shodan
30 Apr 2024 03:22
Forum: DOS Batch Forum
Topic: Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !
Replies: 2
Views: 220

Re: Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !

Improved version of the functions This now works with strings at least 8100 characters long Mostly works with everything that doesn't contain poison characters New extensive test setup is very effective at finding any remaining bugs ! See function GetSubstringIndex-demo at the bottom and ready to us...
by shodan
30 Apr 2024 03:00
Forum: DOS Batch Forum
Topic: pushd popd depend on batch filenames with which they run... why?
Replies: 11
Views: 722

Re: pushd popd depend on batch filenames with which they run... why?

Tried adding filename to the tests The code AAA BBB.bat @ECHO OFF echo this is AAA BBB.bat echo 1 %~dp0 PUSHD %~dp0 echo 2 %~dp0 cd .. echo 3 %~dp0 popd echo 4 %~dp0 echo this is AAA BBB.bat part2 echo 1 %~dpn0 PUSHD %~dp0 echo 2 %~dpn0 cd .. echo 3 %~dpn0 popd echo 4 %~dpn0 AAABBB.bat @ECHO OFF ech...
by shodan
30 Apr 2024 02:51
Forum: DOS Batch Forum
Topic: pushd popd depend on batch filenames with which they run... why?
Replies: 11
Views: 722

Re: pushd popd depend on batch filenames with which they run... why?

Hi, Just tried a simpler version Code for AAABBB.bat @ECHO OFF CLS echo this is AAABBB.bat echo 1 %~dp0 PUSHD %~dp0 echo 2 %~dp0 cd .. echo 3 %~dp0 popd echo 3 %~dp0 Code for AAA BBB.bat @ECHO OFF CLS echo this is AAA BBB.bat echo 1 %~dp0 PUSHD %~dp0 echo 2 %~dp0 cd .. echo 3 %~dp0 popd echo 3 %~dp0...
by shodan
29 Apr 2024 17:31
Forum: DOS Batch Forum
Topic: Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !
Replies: 2
Views: 220

Re: Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !

New version of Works to 8155 characters with byref input string, now supports byref parameters for either or both or none input and replace string Still breaks on poison characters Call :CreateRandomStringPS PUNCTUATION NOPOISON SPACE EXTENDED 8155 testvar ::Usage Call :ReplaceString InputString Rep...
by shodan
29 Apr 2024 17:26
Forum: DOS Batch Forum
Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Replies: 8
Views: 2250

Re: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile

Thanks, My current solution is certainly derived from this comment. I found it in an old version of my functions but the use of echo( and the very similar structure, I'm sure that's where I got it from ! Looking at the differences He explicitely uses SETLOCAL DisableDelayedExpansion Which I don't be...
by shodan
29 Apr 2024 05:48
Forum: DOS Batch Forum
Topic: Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !
Replies: 2
Views: 220

Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !

See latest version at https://www.dostips.com/forum/viewtopic.php?p=69907#p69907 ------------------------------------ This was a lot of work ! If it wasn't so late, I think this directly leads to a fast and robust :split function as well ! This substring uses the similar mechanism as the :len functi...
by shodan
23 Apr 2024 15:03
Forum: DOS Batch Forum
Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Replies: 8
Views: 2250

Re: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile

I have cracked it Posting before the forum times out again ! This will write the line number and line ranges from inputfile to output file ::Usage Call :AppendFileLineToFile inputfile outputfile 3 4 50-75 5 6 7 ... N :AppendFileLineToFile set "_AppendFileLineToFile_prefix=_AFLTF" set "_AFLTF_InputFi...
by shodan
22 Apr 2024 15:06
Forum: DOS Batch Forum
Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Replies: 8
Views: 2250

Re: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile

Thank you that is some top tier wizardry In my current design, I planned to mostly rely on %~0 for function switching. I would achieve that with shortcuts / softlinks and/or hardlink I am creating a function, that lists all functions in a batch file, then creates/updates/deletes shortcuts/softlink/h...
by shodan
22 Apr 2024 04:54
Forum: DOS Batch Forum
Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Replies: 8
Views: 2250

Re: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile

Looking in my older code, I found a function called "SimpleFileToArray" that takes lines of text from a file and loads them in an array of variable I just tested it and I think it might work for this. Here is the function itself. ::Usage Call :SimpleFileToArray OutputArray Filename :SimpleFileToArra...
by shodan
22 Apr 2024 03:54
Forum: DOS Batch Forum
Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Replies: 8
Views: 2250

Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile

Hello I made this function to copy arbitrary lines of text, from one file to another ::Usage Call :AppendFileLineToFile inputfile outputfile 3 4 50-75 5 6 7 ... N :AppendFileLineToFile set "_AppendFileLineToFile_prefix=_AFLTF" set "_AFLTF_InputFile=%~1" set "_AFLTF_OutputFile=%~2" :AppendFileLineToF...
by shodan
09 Apr 2024 22:54
Forum: DOS Batch Forum
Topic: How to output a range of lines from a text file using findstr
Replies: 0
Views: 265

How to output a range of lines from a text file using findstr

You might have seen a method using findstr, where you want to output chosen lines of text from a text file. type "myfile.txt" | %SystemRoot%\System32\findstr /N /R /C:".*" | %SystemRoot%\System32\findstr /B /C:"5785:" /C:"5786:" /C:"5787:" /C:"5788:" And that certainly works but it gets unwieldly if...
by shodan
06 Apr 2024 23:38
Forum: DOS Batch Forum
Topic: Difficulty with substring substitution
Replies: 1
Views: 250

Re: Difficulty with substring substitution

So I think I will need to break down the task further. But maybe there are shortcuts to be taken. For now, here is what I imagine it might look like. find internal call index and replace Loop through every character, look for following (case insensitive) Call : return functionname = all characters a...
by shodan
06 Apr 2024 23:23
Forum: DOS Batch Forum
Topic: Difficulty with substring substitution
Replies: 1
Views: 250

Difficulty with substring substitution

Hi, I have a particularly thorny problem for you guys. I am making a function which can modify batch file function calls. I have identified 3 types of function calls and I need to change any one type to another. Here are the name I gave to batch function calls Internal function call Call :myfunction...
by shodan
25 Mar 2024 04:54
Forum: DOS Batch Forum
Topic: ListFunctions.bat This list all "functions" in a .bat file
Replies: 1
Views: 606

Re: ListFunctions.bat This list all "functions" in a .bat file

And now ListFunctionRows.bat This new version lists every function and it's row number in the file. The definition of a function here is, At least one empty row before A label Either an "exit" or a label that starts with EndOf_ and then the label name then another empty row There is a minor bug with...
by shodan
25 Mar 2024 03:47
Forum: DOS Batch Forum
Topic: ListFunctions.bat This list all "functions" in a .bat file
Replies: 1
Views: 606

ListFunctions.bat This list all "functions" in a .bat file

Usage ListFunctions.bat batchfile.bat Will list all functions found in that batch file, minus a pre-defined list of exclusions Example cmd_YFVGop7naG.png The exclusion are one of the following words, when the function name is tokenized, in the last position As well as any function that starts with "...