sexta-feira, 19 de fevereiro de 2016

Editor Script Batch

Masvat-v2.0 

Além de editar também podemos compilar e gerar um executável

font: http://masim-masosoft.blogspot.com.br/2012/08/masbat-v20-beta.html




quarta-feira, 17 de fevereiro de 2016

Batch Script que retorna tamanho da string


Retornando tamanho de variável

Script StrLen
@echo off
:novo
echo Entre com um texto:
set /p "mystring="
call :strlen result myString
echo %result%
goto :eof

:strlen <resultVar> <stringVar>

(   
    setlocal EnableDelayedExpansion
    set "s=!%~2!#"
    set "len=0"
    for %%P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (
        if "!s:~%%P,1!" NEQ "" ( 
            set /a "len+=%%P"
            set "s=!s:~%%P!"
        )
    )
)

    endlocal
    set "%~1=%len%"
    exit /b
)
:eof
pause < nul

DOS String Manipulation

Font: http://www.dostips.com/DtTipsStringManipulation.php

Basic string manipulation in batch like you are used to from other programming languages.


Align text to the right i.e. to improve readability of number columns.
Extract characters from the beginning of a string.
Use Key-Value pair list to lookup and translate values.
Extract a Substring by Position.
Remove a substring using string substitution.
Remove the first and the last character of a string.
Remove all spaces in a string via substitution.
Replace a substring using string substitution.
Extract characters from the end of a string.
Split a String, Extract Substrings by Delimiters.
Add one string to another string.
Trim spaces from the beginning of a string via "FOR" command.
Remove surrounding quotes via FOR command.
Trim spaces from the end of a string via "FOR" command.
Trim spaces from the end of a string via substitution.



Related Posts Plugin for WordPress, Blogger...