ICT
the blog for ICT
ken013194
暱稱: ホロ
性別: 男
國家: 香港
地區: 葵青區
« July 2026 »
SMTWTFS
1234
567891011
12131415161718
19202122232425
262728293031
最新文章
Text File
Arrays
String Procedures
String Functions
String Operation
文章分類
全部 (23)
Programming Language (23)
訪客留言
最近三個月尚無任何留言
每月文章
日誌訂閱
尚未訂閱任何日誌
好友名單
尚無任何好友
網站連結
尚無任何連結
最近訪客
最近沒有訪客
日誌統計
文章總數: 23
留言總數: 0
今日人氣: 0
累積人氣: 80
站內搜尋
RSS 訂閱
RSS Feed
2009 年 9 月 11 日  星期五   晴天


String Functions 分類: Programming Language

High-level Programming Language (Pascal)

String Functions

  • length (<InStr>)
    • return the length of a <InStr> (i.e. the number of characters in the string)
    • for example,

     L := length ('computer studies'); {assign a value of 16 to L}
     L := length (''); {assign a value of 0 to L}
     L := length (' '); {assign a value of 1 to L}

  • Concatenation
    • is a process of joining strings together to form a longer string
    • strings can be concatenated using the function concat or the concatenation operator (+)
    • for example,


     String1 := 'Pascal';
     String2 :='Programming';
     CombineString := concat (String1, String2);
      {or CombineString := String1 + String2;}
     writeln (CombineString); {the output is PascalProgramming}

  • copy (<InStr>,<Start>,<Size>)
    • returns a substring with the specified <Size> from the <InStr>,
    • beginning at position <Start>
    • for example,

       copy ('A programming course', 3, 11); {returns the value programming}

      • if <Start> is larger than the length of the <InStr>, an empty string (i.e. null string) is returned
      • if <Size> goes beyond the end of the <InStr>, whatever is present is copied and returned

       

    Ordering functions

  • ord (<Character>)
    • returns the ASCII value of a <Character>
    • for example,

      Character
      ord (Character)
      'A'
      65
      'Z'
      90
      ' ' {a space}
      32
      '2'
      50
      '9'
      57
      '' {Null string}
      0


       
  • chr (<Code>)
    • where <Code> is a non-negative integer
    • the inverse of the ord function
    • returns the ASCII character associated with <Code>
    • for example,

      Code
      chr (Code)
      49
      '1'
      50
      '2'
      65
      'A'
      66
      'B'
      97
      'a'

       





訪客留言 (返回 ken013194 的日誌)

訪客名稱:
電郵地址: (不會公開)
驗證碼:  按此更新驗證碼 (如看不清楚驗證碼請點擊圖片刷新)
俏俏話: (必需 登入 後才能使用此功能)
[ 開啟多功能編輯器 ]