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 Discussion / How do you search strings? (DBC)

Author
Message
aticper
19
Years of Service
User Offline
Joined: 27th Jan 2006
Location:
Posted: 29th Oct 2006 21:25
Hi all, I have a question about strings.

I'm trying to program a chatbot, and I want it to be able to look through the text put into it for keywords and assign the input with emotional values accordingly. The problem is that I'm not sure how one would go about searching strings for keywords or phrases.

If anyone could give me a hand with this, I'd be much obliged.


Ati

I'm not paranoid. Stop thinking that I'm paranoid!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th Oct 2006 22:29
You can use a for/next loop to look at all the characters to find combinations.

The function at the bottom is something that all old Basic programmers here eventually make for themselves. In Darkbasic "mid$" only outputs one character... this function acts just like "mid$" we're used to in Basic.

I wrote this in Pro but it should work in Classic.
aticper
19
Years of Service
User Offline
Joined: 27th Jan 2006
Location:
Posted: 30th Oct 2006 18:25
Okay, I see. I'll have to adapt it a bit for my uses but that looks like it'll do quite nicely.

Thanks!

Ati.

I'm not paranoid. Stop thinking that I'm paranoid!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 30th Oct 2006 20:30
Np.
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 1st Nov 2006 17:03
One thing I used to do is look for spaces " ", as this would indicate the beginning of a new word. Then look for the next space, which should indicate the end of that word. Check what's between the spaces (your found word$ within the string) against your word bank. I did this for an old text adventure back in QBasic days.

D

Login to post a reply

Server time is: 2025-05-25 22:12:25
Your offset time is: 2025-05-25 22:12:25