Action
Returns the position of a single character in a string.
Syntax
pos = CHARPOS(string , search )
Remarks
Pos |
Numeric variable that will be assigned with the position of the sub string in the string. Returns 0 when the sub string is not found. |
String |
The string to search. |
Search |
The search string. This can be a numeric variable too. For example a byte. When a string is used, only the first character will be used for the search. |
No constant can be used for string it must be a string variable.
The search is sensitive to case.
See also
Example
'-------------------------------------------------------------------------------
' charpos.bas
' (c) 1995-2009 MCS Electronics
$regfile = "m88def.dat"
$crystal = 8000000
$baud = 19200
'-------------------------------------------------------------------------------
Dim S As String * 20
Dim Bpos As Byte
Dim Z As String * 1
Z = "*"
Do
Input "S:" , S
Bpos = Charpos(s , Z)
Print Bpos
Loop Until S = ""
Do
Input "S:" , S
Bpos = Charpos(s , "A") ' notice charpos is sensitive to case
Print Bpos
Loop