[Gambas-user] Workaround for LEN()

Norarg norarg at ...2311...
Sat Dec 12 17:21:00 CET 2009


don't get any mails today, it seems.

I solved the LEN()-problem with a not very pretty function.

' Workaround LEN()-Function
PUBLIC FUNCTION SetLenght(txt AS String, leng AS Integer) AS String
  DIM L AS Integer
  DIM T1 AS String 
  DIM T2 AS String
  T1 = ""
  L = 0
  DO WHILE L < leng
    L = L + 1
    TRY T2 = String.Mid(txt, L, 1)
    ' hmmm does not get error here
    IF ERROR THEN
      T1 = T1 & " "
    ELSE
      ' Workaraound  because of no error
      ' (does the pointer exceeds the string-length, or is the lenght 
set to max. by default?)
      IF T2 = "" THEN
          T1 = T1 & " "
        ELSE
          T1 = T1 & T2
    ENDIF
  LOOP
  RETURN T1
END


Still it would be nice to hear from someone about this, I do not find 
this solution
good. I assume it has something to do with the characterset, but I can 
not really figure it out.

regards
norarg



More information about the User mailing list