Assignment operation

# Assignment operation Assignment operation
The assignment is the "plainest" of the operators: it works just like in any other programming language. The syntax is: <target> = <source> <target> must be a variable, <source> can be any parameter. If the <target> variable doesn't exist, it is created. If it already exists, it is eventually converted to the type of <souce> (scalar, hash or array). If <source> evaluates to an empty value then the <target> variable is unset.
    # Assigning a constant to the variable %Tmp
    %Tmp = 1
    echo %Tmp
    # Assigning a string constant to the variable %Tmp
    %Tmp = some string
    echo %Tmp
    # Assigning a string constant to the variable %Tmp
    %Tmp = "some string with whitespace         preserved"
    echo %Tmp
    # Assigning a variable to another variable copies its contents
    %Someothervariable = "Contents"
    %Tmp = %Someothervariable
    echo %Tmp
    # Assigning a variable string to the variable %z
    %color = blue
    %z = my eyes are %color
    echo %z
    # Assigning a variable string (with a function call inside) to the variable %x
    %x = the system os is $system.osname
    echo %x
    # Assigning an empty string to the local variable %y unsets %y
    %x =
    echo %y
    # This is equivalent to the above
    %y = ""
    # This is equivalent too, if $function evalutates to an empty string
    %y = $function()
    # Assigning a variable string to a hash entry
    %Dict{key} = $system.osname\ian
    # Unsetting an array entry
    %mydict[23] = ""
    # Assigning a hash to another: %mydict[] becomes a copy of %anotherdict[]
    %anotherdict{"The key"} = "Some dummy value"
    %mydict = %anotherdict
    echo%mydict{"The key"}
    # This will convert %mydict to be a scalar variable (deleting all the %mydict contents!)
    %mydict = "some default value"
    # Unsetting a whole hash
    %anotherdict =

Index, Language Overview

KVIrc 3.4.0 Documentation
Generated by loris at Mon Mar 17 20:35:38 2008