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.

Newcomers DBPro Corner / Finding text in files (DBP)

Author
Message
1tg46
20
Years of Service
User Offline
Joined: 1st Feb 2004
Location: I dont know!
Posted: 25th Sep 2004 11:28
I know their are the commands Find First and Find Next, but these only search for files. I want to be able to read certain files and search inside them for information.

For example:
A simple text document
[.txt]
This is the document
This is an example of my problem
Please help me with this problem
[.txt]

I want to be able to search the text file for a piece of text like "help me with" in this exanple.

I know that instead I could load individual lines of the file but the number of lines of the file are unknown and the number of lines is exceeding 100 lines.


1tg46 is my name coding is my game.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 25th Sep 2004 11:44
with dbp:
use Load Array() to fill an array with the files lines
use array count to get the upperbound
loop the array from 0 to upperbound
search each line for the text

with dbp_netlib:
if I am not mistaken you use our plugin, if so, use str_filetostring then use str_instr() to find the sought item.


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 25th Sep 2004 11:54
im not an expert in db but it seems to me like you could use the instr cmd for example

If InStr(YourFileLine(i), Thingyouwanttofile)
LineItsOn = i
Position = InStr(YourFileLine(i), Thingyouwanttofile)
end if


This would of cuarse haved to be tweaked alittle and im really sry if InStr is not in db im using that from mainly vb but im pretty sure it is (db not workin on comp right now sry cant check it ><

also there is another problem this has....if you want to find multiple instances you would have to cut out the first half before it found the string then you would have to do the search again for the cut off part
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 25th Sep 2004 13:26
there is no instr in dbp, thats why I mentioned our vb.net plugin because I think he already is using that.


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
1tg46
20
Years of Service
User Offline
Joined: 1st Feb 2004
Location: I dont know!
Posted: 26th Sep 2004 00:09
Yah I am using your plugin Cattlerustler, but the thing I don't like about it is that one of the dll's have to be the program directory, and it requires the .NET framework to be installed. This feature I am not sure how people will like with the new IDE I am making with your plugin.

@cattlerustler
I will try it with your plugin, but I am not sure if it will work how I want, hopefully it does.

Thanks,


For more information about my upcomind IDE please look in
http://forum.thegamecreators.com/?m=forum_view&t=39321&b=8
May not be much right now, but I am hoping that I can make it one of the best IDE's made in DBP, if the only made in DBP.


1tg46 is my name coding is my game.
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 26th Sep 2004 23:53 Edited at: 26th Sep 2004 23:55
alrihgt well if you dont like that plugin you can always make your own in string function...i did it a while back with hangman i just rememberd ^^

alirhgt well i did it a year ago so i cant remember exact code

but basicly there was a for loop to get a letter of the string your trying to look in and then there was an if statement that checked if that letter was teh first letter of the string your trying to look for and if it was then in my program that is all i had to do becuase it was hangman...1 letter...but with your thing youd then have to ether set a varible or make a sub that would check the next letter or something....

i could write the code if you cant figure it out or no1 else rights it...but i have to get back into db and writting my own find function.....oh witch reminds me you probobly want to have this in a function ><....well thats not one of the things thats very easy for me right now ><

myb some1 else can right this?


[edit]

oh yea i just rememberd...if your doing something and your looking throught a whole program....it might take a long time to do that for the whole program.....

and if your making an ide....id be so cool if you did colored parentheses
1tg46
20
Years of Service
User Offline
Joined: 1st Feb 2004
Location: I dont know!
Posted: 27th Sep 2004 00:05
Could you explain more clearly I was lost after you said
Quote: "alirhgt well i did it a year ago so i cant remember exact code"





Quote: "and if your making an ide....id be so cool if you did colored parentheses"

I'll think about that.


1tg46 is my name coding is my game.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 27th Sep 2004 01:06 Edited at: 27th Sep 2004 01:07
I am in the process of writing some drop in dba's for pro that will mimic some of the more useful functions from vb/dbp_netlib but they are written entirely in dbp code (the winch will love me now )

email me if you want a beta version, so far it contains:
cr_mid(str,start,length) - returns a substring
cr_instr(searchin,searchfor) - returns int of char pos
cr_split(str,delimiter*) - populates string array

these functions exactly mimic vb6/net functions of the same name but are pure dbp code.

*currently delimiter is limited to a single character.


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
1tg46
20
Years of Service
User Offline
Joined: 1st Feb 2004
Location: I dont know!
Posted: 27th Sep 2004 01:15
I'll try to send you an email requesting What is the program called? to you. No guarentee that I will be able to send the email though.I'll post if I do send you an email.


1tg46 is my name coding is my game.

Login to post a reply

Server time is: 2024-09-23 00:33:20
Your offset time is: 2024-09-23 00:33:20