Problem

We have a string of which we don't know, if its characters are in upper or lower case or even mixed. To compare it's content we have to convert it into one case.

Solution

We define two parallel strings with all characters to convert. A loop through the input string searchs the single characters in the transformation strings. If it is found it will repaced by the character of the other string. The variable "case" switches between converting to lower (=0) or upper (=1) case. So we can use the same sub for both needs.

Script

!»»» Define Conversion string
DIM UPlo[2]
UPlo[1]="abcdefghijklmnopqrstuvwxyzäöüßáàéèç"
UPlo[2]="ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜßÁÀÉÈÇ"

!»»» Example
txt="HelLO wORlD!"
: PRINT txt
case=0 : GOSUB 700 : PRINT txt
case=1 : GOSUB 700 : PRINT txt

END

! »»» SUB for changing string
700:
lenT=
STRLEN(txt)
FOR i=1 TO lenT
  s=STRSTR(
UPlo[2-case],STRSUB(txt,i,1))
  IF s THEN txt=STRSUB(txt
,1,i-1)+STRSUB(UPlo[1+case],s,1)+STRSUB(txt,i+1,lenT-i)
  NEXT i
RETURN
Um unsere Webseite für Sie optimal zu gestalten und fortlaufend verbessern zu können, verwenden wir nur essenzielle Cookies.
Durch die weitere Nutzung der Webseite stimmen Sie der Verwendung von Cookies zu.
Weitere Informationen zu Cookies erhalten Sie in unserer Datenschutzerklärung