Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, kzhao), 642 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
File_seek #396935
03/12/12 11:28
03/12/12 11:28
Joined: Feb 2006
Posts: 33
Herts, UK
D
danohu Offline OP
Newbie
danohu  Offline OP
Newbie
D

Joined: Feb 2006
Posts: 33
Herts, UK
Hi

I want to search for multiple words in a .txt file:

file_seek(filehandle,0,0);
xndex = file_find (filehandle, "john");
xndexi = file_find (filehandle, "sam");

if...
if...
if...

When I run the code it will only look for the first name. How can I search for multiple criteria (i.e. multiple names at the same time).

I have been trying options without much success e.g.

xndex = file_find (filehandle, "john"; "sam");

Would anyone be able to point me in the right direction please?

I could search for a single word followed by if statements but without searching for multiple criteria at the same time (i.e. different names) the code is inefficient and very long.

Thanks for your help in advance!

D

Re: File_seek [Re: danohu] #396945
03/12/12 13:46
03/12/12 13:46
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
try this:

file_seek(filehandle,0,0);
xndex = file_find (filehandle, "john");
file_seek(filehandle,0,0); // set the reader back to the beginning of the file
xndexi = file_find (filehandle, "sam");

Re: File_seek [Re: danohu] #432263
11/03/13 17:58
11/03/13 17:58
Joined: Feb 2006
Posts: 33
Herts, UK
D
danohu Offline OP
Newbie
danohu  Offline OP
Newbie
D

Joined: Feb 2006
Posts: 33
Herts, UK
I have a follow-up question having come back to this after some time. If one has a single word for xndex i.e. "john" and a single word for xndexi "sam", then if one is searching for lots of names one will have a lot of xndexs and a lot of code i.e.

if (xndex > 0 && xndexi > 0 && xndexii > 0 etc etc)

I wondered if anyone could help me explain the following?

I have written:

file_seek(filehandle,0,0);
xndex = file_find (filehandle, "john") && file_find (filehandle, "sam");

if (xndex > 0)
..then xyz

The code runs without an error appearing and is less involved. However, if on searches for the two words in a word document (coding for finding the words in a word document has not been included but is in my script)
the code says xndex is greater than 0 if the two words are found as well as if they are not. Clearly the code is not working.

My question is... I wonder if there is a way to make xndex represent more than one word?

Many thanks for your help.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1