Jump to content
Sign in to follow this  
WolfWorld

Legez, String Handling.

Legez  

3 members have voted

  1. 1. Do you like it?

    • Yes
      1
    • No
      1
    • How do I use it?
      1
  2. 2. Can you get it to work(try before voting)

    • Yes
      0
    • No
      1


Recommended Posts

WolfWorld

Comment! I put a lot of work into this.

Here after you are using Legez you can handle string like this

$string = 'Hello Am'

Msgbox(0,'',_('$string.left.4.&1.rest.smid.7.1.lwwr.&2.*$1&$2&+ World'))

This will output Hella World

This allow you to do things with string very fast the example above only took about 25 second to write and think.

It also allow back-end use to control the string

Just put this into your autoit file

#include <String.au3>

Func _($sString, $vGlobal = 0)
    Local $aSplit = StringSplit($sString, '.'), $BaseString, $Reset
    If $aSplit[0] < 1 Then Return -1
    For $i = 1 To $aSplit[0]
        Switch StringLeft($aSplit[$i], 4)
            Case 'left'
                $BaseString = StringLeft($BaseString, $aSplit[$i + 1])
                $i += 1
            Case 'rght'
                $BaseString = StringRight($BaseString, $aSplit[$i + 1])
                $i += 1
            Case 'trlt'
                $BaseString = StringTrimLeft($BaseString, $aSplit[$i + 1])
                $i += 1
            Case 'trrt'
                $BaseString = StringTrimRight($BaseString, $aSplit[$i + 1])
                $i += 1
            Case 'smid'
                $BaseString = StringMid($BaseString, $aSplit[$i + 1], $aSplit[$i + 2])
                $i += 2
            Case 'srpl'
                $BaseString = StringReplace($BaseString, $aSplit[$i + 1], $aSplit[$i + 2])
                $i += 2
            Case 'inst'
                $BaseString = StringInStr($BaseString, $aSplit[$i + 1])
                $i += 1
            Case 'reve'
                $BaseString = _StringReverse($BaseString)
            Case 'uppr'
                $BaseString = StringUpper($BaseString)
            Case 'lwwr'
                $BaseString = StringLower($BaseString)
            Case 'rest'
                $BaseString = $Reset
            Case 'seto'
                $Reset = $BaseString
            Case 'adda'
                If StringLeft($aSplit[$i + 1], 1) = '$' Then
                    $BaseString &= Eval(StringTrimLeft($aSplit[$i + 1], 1))
                ElseIf StringLeft($aSplit[$i + 1], 1) = '+' Then
                    $BaseString &= StringTrimLeft($aSplit[$i + 1], 1)
                EndIf
                $i += 1
            Case 'addb'
                If StringLeft($aSplit[$i + 1], 1) = '$' Then
                    $BaseString = Eval(StringTrimLeft($aSplit[$i + 1], 1)) & $BaseString
                ElseIf StringLeft($aSplit[$i + 1], 1) = '+' Then
                    $BaseString = StringTrimLeft($aSplit[$i + 1], 1) & $BaseString
                EndIf
                $i += 1
            Case Else
                If StringLeft($aSplit[$i], 1) = '$' Then
                    $BaseString = Eval(StringTrimLeft($aSplit[$i], 1))
                    $Reset = $BaseString
                EndIf
                If StringLeft($aSplit[$i], 1) = '+' Then
                    $BaseString = StringTrimLeft($aSplit[$i], 1)
                    $Reset = $BaseString
                EndIf
                If StringLeft($aSplit[$i], 1) = '&' Then
                    Assign(StringTrimLeft($aSplit[$i], 1), $BaseString, 2)
                EndIf
                If StringLeft($aSplit[$i], 1) = '*' Then
                    $aJoin = StringSplit(StringTrimLeft($aSplit[$i], 1), '&')
                    $BaseString = ''
                    For $x = 1 To $aJoin[0]
                        If StringLeft($aJoin[$x], 1) = '$' Then
                            $BaseString &= Eval(StringTrimLeft($aJoin[$x], 1))
                        ElseIf StringLeft($aJoin[$x], 1) = '+' Then
                            $BaseString &= StringTrimLeft($aJoin[$x], 1)
                        EndIf

                    Next
                EndIf

        EndSwitch
    Next
    If $vGlobal Then
        Assign($vGlobal, $BaseString, 4)
    Else
        Return $BaseString
    EndIf
EndFunc   ;==>_

Example.

This will give you the same thing

$string1 = '000Hello000'

$string2 = ' emaN'

$string3 = ' sI'

$string4 = 'LeGez'

$1 = stringmid($string1, 4, 5)

$2 = _StringReverse($string2)

$3 = _StringReverse($string3)

$4 = stringupper($string4)

msgbox(0,'Testing',$1 & ' my ' & $2 & $3 & $4)

OR

$string1 = '000Hello000'

$string2 = ' emaN'

$string3 = ' sI'

$string4 = 'LeGez'

_('$string1.smid.4.5.&1.$string2.reve.&2.$string3.reve.&3.$string4.uppr.&4')

msgbox(0,'Testing',$1 & ' my ' & $2 & $3 & $4)

Try it!

DOC. very bad english!

#cs ----------------------------------------------------------------------------
    
    Legez Version: 0.0.1.0, Update 2 Everytime update changes your script may/WILL be broken if you update so check and learn first.
    Next update would be a join function so adda does not need to be call all the time and amek the thing long.
    Note: For people who use update 0 please see assg, adda/b, and all variable and raw string handling. Its a lot shorter now.
    Note update from 1>2 see adda and addb, its still use able but there is a new join function and its a lot shorter.
    Author:      Athiwat Chunlakhan
    
    Script Function:
    Legez add-on language for Autoit is a very powerful tool for handling a string.(Very fast both programming and running)
    The base core is based on WaterVapor and WaterVaporX but its strip down (by 1700 line or so, and transilate to Autoit from Delphi) to make it work as I want with Autoit native language
    This is an add-on to Autoit to make your development speed go faster!
    
    It act as a single function called "_" for shortness as you will be using it a lot I mean a lot
    
    Need #include <String.au3> as of reverse function
    
    Documents:
    
    example _('+Hello.reve.rght.4.reve')
    This will spell Hell it can be written as _('+Hello.left.4') also but this is just a show off to show you how short can it be.
    
    Another one this one will be long pure Autoit first
    $string1 = '000Hello000'
    $string2 = ' emaN'
    $string3 = ' sI'
    $string4 = 'LeGez'
    $1 = stringmid($string1, 4, 5)
    $2 = _StringReverse($string2)
    $3 = _StringReverse($string3)
    $4 = stringupper($string4)
    msgbox(0,'Testing',$1 & ' my ' & $2 & $3 & $4)
    
    Now in Autoit with Legez, AM going to keep the string variable.
    
    $string1 = '000Hello000'
    $string2 = ' emaN'
    $string3 = ' sI'
    $string4 = 'LeGez'
    _('$string1.smid.4.5.&1.$string2.reve.&2.$string3.reve.&3.$string4.uppr.&4')
    msgbox(0,'Testing',$1 & ' my ' & $2 & $3 & $4)
    
    Now the most powerful thing you can do with it, IT may confuse you(it did on me by the way) call the whole thing in one line like normal autoit!
    Legez   msgbox(0,'Testing', _('+000Hello000.smid.4.5.&1.+ emaN.reve.&2.+ sI.reve.&3.+LeGez.uppr.&4.*$1&+ my &$2&$3&$4'))
    Autoit  msgbox(0,'Testing', stringmid('000Hello000', 4, 5) & ' my ' & _StringReverse(' emaN') & _StringReverse(' sI') & stringupper('LeGez'))
    It's a bit longer on Legez (but in update 2 I promise it will be shorter 100%)(Upadted now update 2 now its shorter!) ! Don't blame me but the time taken to write is about 20 second on Legez and 43 second on Autoit(without ScITE help), try test it yourself!
    Oh, and in Legez you are declearing all the variable properly and you can use it again outside the function also.
    
    And using ByRef, in this mode you will need to pass in one more parameter the second one this will return to the variable but it will not return in normal mode.
    $string = "Helloo"
    _('$string.trrt.1.reve.trlt.1.reve','string'); return nothing at all
    Msgbox(0,'',$string)
    
    Function List, all function name are 4 length long for speedy reason but you will get use to it I promise!
    left.x StringLeft($BaseString, x)
    rght.x StringRight($BaseString, x)
    trlt.x StringTrimLeft($BaseString, x)
    trrt.x StringTrimRight($BaseString, x)
    smid.x.y StringMid($BaseString, x, y)
    inst.x StringInStr($BaseString, x)
    reve _StringReverse($BaseString)
    upper StringUpper($BaseString)
    lwwr StringLower($BaseString)
    assg.x(Not useable now as of 0.0.0.2), use "&" to indicate that the value will be store in, example _('&outputvariable'), build in function, Assign(x, $BaseString, 2)
    rest, build in function, reset the value to the original one.
    seto, build in function, Set the value to be original one.
    read.x(Not useable now as of 0.0.0.2), Now you can just use $ and for raw string use + example _('$test.reve.$test2.reve'), build in function, this will read a new variable and reset will be set to this new one, you will not need to call the whole function again.
    adda.$+x, build in function, This will add a string in the front of it.
    addb.$+x, build in function, This will add a string in the back of it.
    Join, BIF, "*" to start and "&" to join the variable and string, This will delete all $BaseString and put $BaseString as the input example _('*$variable1&+ line &$variable2'), $BaseString is = to $variable1&+ line &$variable2
    
    PLEASE READ THIS:
    I want everyone who uses this to help develop this by creating more function and sent back to me your name will be add to the credit list.
    
    MORE TODO:
    I want to put this in Autoit it self so you can do something like $test.reve.left.4
#ce ----------------------------------------------------------------------------
Edited by athiwatc

Share this post


Link to post
Share on other sites
Authenticity

lol I like the Visual C function macro style. _T("Test") ;] Looks interesting, thanks for the share.

Share this post


Link to post
Share on other sites
Skrip

Very nice! This could be very useful.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
Authenticity

There is a problem though. The source code is not readable by any mean so I believe it's only for writing code without the need to ask for help or so people will be able to understand it with at list AutoIt's help file. What do you think? You'll need sort of Legez help file. Anyway, the concept is indeed cool in my opinion and I'm well fine with method chaining. ;] Thanks once again.

Share this post


Link to post
Share on other sites
WolfWorld

Sorry for my bad english but here are the list of functions, It compare it to the autoit function.

Function List, all function name are 4 length long for speedy reason but you will get use to it I promise!

left.x StringLeft($BaseString, x)

rght.x StringRight($BaseString, x)

trlt.x StringTrimLeft($BaseString, x)

trrt.x StringTrimRight($BaseString, x)

smid.x.y StringMid($BaseString, x, y)

inst.x StringInStr($BaseString, x)

reve _StringReverse($BaseString)

upper StringUpper($BaseString)

lwwr StringLower($BaseString)

assg.x(Not useable now as of 0.0.0.2), use "&" to indicate that the value will be store in, example _('&outputvariable'), build in function, Assign(x, $BaseString, 2)

rest, build in function, reset the value to the original one.

seto, build in function, Set the value to be original one.

read.x(Not useable now as of 0.0.0.2), Now you can just use $ and for raw string use + example _('$test.reve.$test2.reve'), build in function, this will read a new variable and reset will be set to this new one, you will not need to call the whole function again.

adda.$+x, build in function, This will add a string in the front of it.

addb.$+x, build in function, This will add a string in the back of it.

Join, BIF, "*" to start and "&" to join the variable and string, This will delete all $BaseString and put $BaseString as the input example _('*$variable1&+ line &$variable2'), $BaseString is = to $variable1&+ line &$variable2

-

Edited by athiwatc

Share this post


Link to post
Share on other sites
WolfWorld

There is a problem though. The source code is not readable by any mean so I believe it's only for writing code without the need to ask for help or so people will be able to understand it with at list AutoIt's help file. What do you think? You'll need sort of Legez help file. Anyway, the concept is indeed cool in my opinion and I'm well fine with method chaining. ;] Thanks once again.

The source code is like autoit itself, you are not suppose to read it at all its just there for handling the function calls.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.