http://www.sil.org/iso639-3/default.asp
Code: Select all
Structure CharField
c.c[0]
EndStructure
Procedure ConcatenateUAlphaLong(Long.s)
Protected DigitAscii.l
Protected Concatenate.l
Protected StringLength.l=Len(Long.s)
Protected *CharacterString.CharField=@Long.s
;/ Max digits is 4 ((10 - 1)/2) to support first digit up to 9 where max ucase ascii char is two digits
If Not StringLength Or StringLength>4
ProcedureReturn -1
EndIf
;/ Convert string to upper-case to use a maximum of two numbers per digit
Long.s=UCase(Long.s)
;/ Append each ascii result to the end of the integer
For i=0 To StringLength-1
DigitAscii=*CharacterString\c[i]
;/ Only characters A-Z are supported
If DigitAscii<65 Or DigitAscii>90
ProcedureReturn -2
EndIf
Concatenate*100
Concatenate+DigitAscii
Next i
ProcedureReturn Concatenate
EndProcedure
String.s="abcd"
Result=ConcatenateUAlphaLong(String.s)
For i=1 To Len(String.s)
StringAscii.s+Str(Asc(UCase(Mid(String.s,i,1))))+" "
Next i
If Result>0
Debug StringAscii.s
Debug Result
Else
If Result=-1
Debug "Illegal number of digits."
ElseIf Result=-2
Debug "Illegal character in string. Only alphabetical characters are supported."
EndIf
EndIf