Aztec® Programming Language

Version 1.0 Alpha

Copyright © 2010-2013

Cold Spring® Development Group

All Rights Reserved

Download Aztec

Site Help

♦ Syntax

 

♦ The expression must be a boolean expression for both statements.

♦ For the 'while' statement (standalone)

♦ The expression is evaluated at the top of the loop, and the block of statements is executed if the expression is true.

♦ The expression is then re-evaluated and the block is again executed if true.

♦ This process is repeated until the expression is false or the code manually exits the block (break, return, etc.).

♦ For the 'until' statement (standalone)

♦ The expression is evaluated at the top of the loop, and the block of statements is executed if the expression is false.

♦ The expression is then re-evaluated and the block is again executed if false.

♦ This process is repeated until the expression is true or the code manually exits the block (break, return, etc.).

♦ Both statements can also be used together with the 'repeat' statement.

♦ The 'while' and 'until' statements can only be used inside a "compiler" method or a "normal" method.

♦ Full source code examples showing 'while' and 'until' statement usage (standalone)

 
#  This constant uses a compiler method to initialize its value.
data<string> const  StartupName = CompilerStrUprLwrRange("abCdhJuiREew",'P','o')

# This method is used at compile-time to return a modified version of the string (upr/lwr within range).
public compiler method<string> CompilerStrUprLwrRange(string Text, string LowChar, string HighChar)
{
    data<int>       Length
    data<int>       Index = 1
    data<string>    TmpChar
    data<string>    RetStr = Text

    #-----------------------------------------------------------------------------------
    # Loop through the entire length and check original string using 'while' statement
    # and one method of testing for the character being within a range. This logic
    # converts upper case and "in range" characters (in original string) to upper case.
    #-----------------------------------------------------------------------------------
    Length = CompilerStrLen(Text)
    while ( Index <= Length )
    {
        # Get the character at this position and determine if it should be changed.
        TmpChar = CompilerStrSub(Text,Index,1)
        
# If upper case and in range, flip the case and overlay it back into the string.
if ( (TmpChar >= LowChar & TmpChar <= HighChar) & (TmpChar in 'A'..'Z') ) { RetStr = CompilerStrOvr(RetStr,CompilerStrLwr(TmpChar),Index) }
CompilerInc(@Index) } #------------------------------------------------------------------------------------
# Loop through the entire length and check original string using 'until' statement
# and 'in' keyword for testing a character within a range. This logic converts
# lower case and "in range" characters (in original string) to upper case.
#------------------------------------------------------------------------------------
Index = 1
until ( Index > Length )
{
# Get the character at this position and determine if it should be changed.
TmpChar = CompilerStrSub(Text,Index,1)

# If lower case and in range, flip the case and overlay it back into the string.
if ( (TmpChar >= LowChar & TmpChar <= HighChar) & (TmpChar in 'a'..'z') )
{
RetStr = CompilerStrOvr(RetStr,CompilerStrUpr(TmpChar),Index)
}

CompilerInc(@Index)
} return(RetStr) } # This class is used to startup the script. public class Main from<Thread> { public method Main() { Thread() # Must invoke base constructor. }
public virtual method Run { data<int> Index = 1 data<string> TmpChar data<string> Name = StartupName #------------------------------------------------------
# Use the 'while' statement to change each character.
#------------------------------------------------------
while ( Index <= Name.Len() )
{
# Get the character and modify it based on lower case vs upper case.
TmpChar = Name.Sub(Index,1)
if ( TmpChar in 'A'..'Z' )
{
# Increase character by one and write it back into the string.
Name.Ovr(TmpChar.Inc(),Index)
}
else if ( TmpChar in 'a'..'z' )
{
# Decrease character by one and write it back into the string.
Name.Ovr(Char(TmpChar.Ascii() - 1),Index)
}

Index.Inc()
} Script().WriteLog("And the name is... " + Name) return } }

Page UpPage DownCopyright © 2010-2013
Cold Spring Development Group
All Rights Reserved

Download Aztec