Menu

Functions left ,Right for string manipulation

Help
2012-01-10
2013-05-30
  • Dimitris Katsaounis

    My proposal to the community for Left and Right Function in String.h library

    'Return the <SysCharCount> most left characters of a string
    Function Left (in SysInString() , SysCharCount) as string
       StringSize=SysInString(0)
       If StringSize <= SysCharCount  then
          Left=SysInString()   'If the size of the string is less than or equal to SysCharCount the entire string is return
       end if
       if StringSize > SysCharCount then
          SysInString(0)=SysCharCount
          Left=SysInString()
       end if
    end function

    'Return the <SysCharCount> most right characters of a string
    Function Right(in SysInString() , SysCharCount) as string
       StringSize=SysInString(0)
       if StringSize <= SysCharCount  then
          Right=SysInString()   'If the size of the string is less than or equal to SysCharCount the entire string is return
       end if
       if StringSize > SysCharCount  then
          For counter = 1 to SysCharCount
            Right(SysCharCount+1-counter)=SysInString(StringSize+1-counter)
          next
          Right(0)=SysCharCount
        end if
    end function

     
  • Dimitris Katsaounis

    What about the Mid Function below. Is Working just fine for me

    'Return the section of a string which begin from SysCharStart with length SysCharCount
    Function Mid (in SysInString() , SysCharStart , SysCharCount) as string
        if (SysInString(0)<=SysCharCount) OR (SysInString(0)<SysCharStart) then
          Mid(0)=0
          Exit Function
        end if
        SysInString(0)=SysCharStart+SysCharCount-1
        SysInStringSize=SysInString(0)
        Mid=""
        For i=0 to SysCharCount
            Mid(SysCharCount-i)=SysInString(SysInStringSize-i)
          next
          Mid(0)=SysCharCount
    end function

     
  • mmotte

    mmotte - 2012-01-12

    Thanks for working on the string functions.
    I will have to try them out.
    With GPS and other devices returning strings, these functions will be useful for parsing out what you need.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.