Simplicty and flexibility!


Function::String

StringFind
StringFind("StringToSearch","TextToSearchFor")
StringFind("This is a test","test") .
retval := StringFind(FieldToSearch,Search) .
StringFind("Hello World in the world", "world", 0, "exact") return 19
StringFind("Hello World in the world", "world", 0, "count") returns 2
StringFind("Hello World in the world", "Mars", 0, "count") return 0


Search a string to find if the substring is find in it. If it is find it will return the position of the first substring. 

From 9.0 onwards this function support 4GB large strings both as donor string and sub string. This is mostly theoretical but highlight how much more useful this function now and whey we had to add the new features.

This function can now be used to unwind large texts. You can for instance split up HTML, XML, JSON etc.


Parameters


StringToSearch; String

The string where we look for substring in.

StringToSearchFor: String

The string we are looking for.

Start Position in String: Number

If you search for a sub-string that can have multiple occurrence the function will give the position of the first so if you want to search "onward" in the string you need to repeat the search and input the position returned+lengt of substring to start after the previous occurrence.

Keyword: String

Currently None,Exact and Count.
None (default): Case insensitive search for word i.e world will find World, WORLD, wORLD etc.
Exact: Search for the sub-string exactly as entered i.e. case sensitive.
Count: Return the number of occurrences of sub-string in string.

Returns/Result


Integer: Postion of Substring in string. 0 if no match. Will be changed to the count of substring in string.

Examples


Example 1:

Using while loop to run trough large multi-line string and split it up in single lines.

define "retval" text 255.

define "vMemo" memo .

define "start" number .

define "stop" number .

define "linelength" number .

vMemo := getvalue("MyMemo") . -- This is a ExecDQL and we are lazy and read value out of underlying form (execdql)

while StringFind(vMemo,chr(13),start) not = -1 do -- looking for CR if we don't find it we have finished (-1). Start where we stopped last loop

stop :=StringFind(vMemo,chr(13),start) . -- find the actual position of CR.

linelength := stop - start+1 . -- find lenght of line to cut out.

retval := stringReplace(midc(vMemo,start,linelength),chr(10),"") . -- getting rid of LF as we don't need that.

enter a record in SomeData -- enter the line into a table of single lines.

ID := getvalue("ID") ;

Start := temp Start ;

Stop := temp Stop ;

SomeText := retval .

start := stop+2 .

Retval := blank .

message retval .

end

stop := length(vMemo) .

if start <stop then -- check if there is text after last CR 

linelength := stop - start .

retval := stringReplace(midc(vMemo,start,linelength),chr(10),"") .

enter a record in SomeData

ID := getvalue("ID") ;

Start := temp Start ;

Stop := temp Stop ;

SomeText := retval .

end

retval := refreshscreen() . -- simply refresh screen/form to see lines in subform.

Reference

Returns start position of StringToFind i.e larger than 0 if a string is part of a text. Returns +1 if it isn't.

int StringFind(StringToSearch,StringTofind)

It is a complimentary function to *string* which is a simply boolean function.

See Also


StringBetween()

StringTo()

StringFrom()
MemoStringBetween()
MemoStringTo()
MemoStringFrom()

On the forum about StringFind

[@EOF@]...

Product: . Written by alembagheri tahmas 07/12/13 at 13:37:32

Hi there,I am trying to use an external MySQL DB in dataease. I have successfully create the ODBC link and added the DB to dataease. I can also access the DB from dataease. Now, just for testing purposes, I am trying to create a simple report b...

Product: DataEase for Windows 7.x. Written by George Washington 11/04/14 at 08:26:17

no se pude exportar ahora archivos a pdf, ni a excel o otros cosa mala. en verdad creo que hace faltaen las versiones anteriores me funcionaba mas o menos bien.&nbsp;le hace falta a los aplicativos que se desarrollan en Dataeasegr...

Product: DataEase 8 Reporter. Written by eduardo paez 02/05/14 at 14:40:11

Thanks. Anyway I'm trying to use this fuction but it seems to me that it doesn't work on 8.2. I tried also in a DQL.There's something wrong?<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9IAAAJ3CAYAAAB4NWk3AAAAAXNSR0IArs4...

Product: . Written by Marco Marchesi 15/02/16 at 14:50:46

[@EOF@]...

Product: Dataease [{8}]FIVE. Written by Chamil Rajindra 21/02/19 at 10:17:46

Thanks for the very good explanation!AS...

Product: . Written by afonso santos 28/10/19 at 00:50:14

I am pleased to see that the migration from Dos 4.53 is then sa 5.5 works. A really useful thing would be a compiler of SQL languages. Will you get there?Original Text:Mi compiaccio a vedere che la migrazione da Dos 4.53 รจ poi sa 5.5 funzio...

Product: . Written by Grossi Gioacchino 18/11/19 at 14:33:44

How can i delete a Style sheet?...

Product: Dataease [{8}]FIVE. Written by Rainer 22/03/21 at 11:13:10

I run W7 and since a few days&nbsp;Dataease 8.5 is not starting any more, do you have an idea? i installed it again but that did not help....

Product: Dataease [{8}]FIVE. Written by Rainer 08/06/21 at 14:12:40

[@EOF@]...

Product: . Written by Hiralal Rampul 01/12/21 at 17:47:10

On the blog about StringFind


dg3_HelpView