Declare an instance of the MiscCtlsLib's String class. Note AVR Classic does not need (nor does it support) the New() keyword like .NET does.
DclFld as Type(MiscCtlsLib.String)Get the length of a string.
BEGSR buttonLength Click
DclFld Length Type(*Integer) Len(4)
Length = as.Length(textboxValue1.Text)MsgBox Msg('Length is ' + %Trim(%Char(%EditC(Length, 'C'))))
MsgBox ConvertTextAndNumberToString('Length is ', Length)
ENDSRConvert the case of a string.
BEGSR buttonConvertCase Click
If optionUpperLower[0].Value
MsgBox as.ToLower(textboxValue1.Text)
Else
MsgBox as.ToUpper(textboxValue1.Text)
EndIf
ENDSRReplace a part of a string.
BEGSR buttonReplace Click
DclFld NewValue Type(*String)The value to replace is case-sensitive!
NewValue = as.Replace(textboxValue1.Text, textboxValue2.Text, textboxValue3.Text)
MsgBox NewValue
ENDSRSplit a string on a delimiter.
BEGSR buttonTokenize Click
DclFld TokenCount Type(*Integer) Len(4)
DclFld i Type(*Integer) Len(4)
If %Trim(%Trim(textboxValue2.Text) = '')
MsgBox 'Value 2 must contain a delimiter'
LeaveSr
EndIf
TokenCount = as.Tokenize(textboxValue1.Text, %Trim(textboxValue2.Text))
If TokenCount > 0
Do FromVal(0) ToVal(TokenCount-1) Index(i)The Words array property is zero-based!
MsgBox as.Words[i]
EndDo
EndIf
ENDSRFind the position of one string in another.
BEGSR buttonFind Click
DclFld Position Type(*Integer) Len(4)
Position = as.Find(textboxValue1.Text, textboxValue2.Text)
MsgBox ConvertTextAndNumberToString(textboxValue2.Text + ' found at position ', Position)
ENDSR
BegFunc ConvertTextAndNumberToString Type(*String)
DclSrParm Text Type(*String)
DclSrParm Number Type(*Integer) Len(4)
LeaveSr Value(Text + %Trim(%Char(%EditC(Number, 'C'))))
EndFunc
BEGSR buttonLength MouseMove
DclSrParm Button TYPE(*INTEGER) LEN(2)
DclSrParm Shift TYPE(*INTEGER) LEN(2)
DclSrParm X TYPE(*INTEGER) LEN(4)
DclSrParm Y TYPE(*INTEGER) LEN(4)
labelDescription.Caption = buttonLength.Tag
ENDSR
BEGSR buttonConvertCase MouseMove
DclSrParm Button TYPE(*INTEGER) LEN(2)
DclSrParm Shift TYPE(*INTEGER) LEN(2)
DclSrParm X TYPE(*INTEGER) LEN(4)
DclSrParm Y TYPE(*INTEGER) LEN(4)
labelDescription.Caption = buttonConvertCase.Tag
ENDSR
BEGSR buttonFind MouseMove
DclSrParm Button TYPE(*INTEGER) LEN(2)
DclSrParm Shift TYPE(*INTEGER) LEN(2)
DclSrParm X TYPE(*INTEGER) LEN(4)
DclSrParm Y TYPE(*INTEGER) LEN(4)
labelDescription.Caption = buttonFind.Tag
ENDSR
BEGSR buttonReplace MouseMove
DclSrParm Button TYPE(*INTEGER) LEN(2)
DclSrParm Shift TYPE(*INTEGER) LEN(2)
DclSrParm X TYPE(*INTEGER) LEN(4)
DclSrParm Y TYPE(*INTEGER) LEN(4)
labelDescription.Caption = buttonReplace.Tag
ENDSR
BEGSR buttonTokenize MouseMove
DclSrParm Button TYPE(*INTEGER) LEN(2)
DclSrParm Shift TYPE(*INTEGER) LEN(2)
DclSrParm X TYPE(*INTEGER) LEN(4)
DclSrParm Y TYPE(*INTEGER) LEN(4)
labelDescription.Caption = buttonTokenize.Tag
ENDSR
BEGSR buttonCopyToClipboard Click
Clip.ClearClipboard()
Clip.AddToClipboard(textboxValue1.Text)
ENDSR
BEGSR buttonCopyFromClipboard Click
Clip.GetFromClipboard(textboxValue2.Text)
ENDSR