I am trying to make my program read and edit text. I was trying to use the Position=find ( String , 0 )
method but I get the error:
The method "find" isn't declared in the current class.
I have tried different classes but I cant find the correct one. Which would that be? How may I find the correct class in the future?
Thanks in advance.
The find
is in the String
class.
From the documentation:
int find ( String what, int from=0 )
Finds the first occurrence of a substring. Returns the starting position of the substring or -1 if not found.
So what happens?
When you do Position = find(String, 0)
You are calling find
from which ever class your code is inside, not from String
.
Furthermore, I only see one String
there… Which String
do you want to find in which one? You need two. Yes, find
only takes one String
, but it is an instance method, not a static method. You are meant to call it on the one you want to search, like this:
var position := string_in_which_you_are_looking.find(string_you_are_looking_for, 0)