•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileRINSTR(a$,b$)
RINSTR(a$,b$[,x])
RINSTR([x,]a$,b$)

a$, b$: sexp
x: iexp

The function RINSTR() searches the character string a$ for an occurrence of the
string b$. If x is specified, then the search begins at character position x in
a$, otherwise the whole string is searched.

If b$ is found within a$, the character position at which it begins is
returned, or, if it is not found the function returns zero (0). This value may
be assigned to a variable or used to determine whether a particular string was
present in a$. If a$ and b$ are both null strings (""), one (1) is returned.

The search goes from right to left.

Example:

    PRINT RINSTR("a:\FOLDER\*.GFA","\")

--> The string '\' is sought in the string 'a:\FOLDER\*.GFA', starting
    from the end. Its first occurrence is found at position 10.

Memo: RINSTR() has a bug which only appears if parameter 'x' is used.
      Use the following code listing instead:

FUNCTION rinstr(a$,b$,i&)
  $F%
  LOCAL v&
  v&=RINSTR(a$,b$,i&)
  IF i&=LEN(b$) !bug?
    v&=-(LEFT$(a$,i&)=b$)
  ELSE IF i&<LEN(b$) !bug?
    v&=0
  ENDIF
  RETURN v&
ENDFUNC