Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Searching a string

Author
Message
FieldDoc
23
Years of Service
User Offline
Joined: 30th May 2003
Location: London, UK
Posted: 14th Jun 2003 23:19 Edited at: 14th Jun 2003 23:20
Hi!
Suppose I have 2 strings. One called small$ and one called big$. They are as follows:

small$ = "program files\office\"
big$ = "program files\office\word\"

I want to somehow work out a way to search the contents of big$ for small$. It would have to be a generic function of some sort as small$ and big$ alter all the time. I also need to flag somehow that small$ is found in big$.

Thanks in advance

Life is like a penis:
When it's soft you can't beat it, when it's hard you get screwed.
The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 14th Jun 2003 23:42
Um, off the top of my head it would be:

for i=0 to (len(big$)-len(small$))
if mid$(big$,i,len(small$))=small$ then flag=1:break
next i

Once I was but the learner,
now, I am the Master.
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 15th Jun 2003 00:39
Ask IanM for his Matrix1 Utility DLL or get the string functions DLL from http://www.realgametools.com - they both have InString$ commands which do exactly what you want.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_103.zip
FieldDoc
23
Years of Service
User Offline
Joined: 30th May 2003
Location: London, UK
Posted: 15th Jun 2003 00:52
Thanks RobK....how does his INSTR function work.....i'm not to clear on the syntax in his readme for it. It says:

INSTR - Search for a string within a string.
Pos=INSTR(Source$, Search$, StartPos)
Pos=INSTR(Source$, Search$)

Life is like a penis:
When it's soft you can't beat it, when it's hard you get screwed.

Login to post a reply

Server time is: 2026-07-17 21:22:13
Your offset time is: 2026-07-17 21:22:13