Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Mon Mar 28, 2011 1:48 am   

Providing line numbers while searching text files for specific text
 
Basically I am looking for a way to be able to %read a file to search for certain things, but at the same time retrieve the line number in the file that it is in.
The goal is to be able to search several lines immediately before or after the line that comes up using %read.

On a side note, is it possible to use %read or similar commands on files using their directory without loading them via #FILE?
Thanks in advance for your help.
Reply with quote
Myrkul
Wanderer


Joined: 21 Aug 2008
Posts: 85

PostPosted: Mon Mar 28, 2011 4:03 am   
 
[edit][/edit]


Last edited by Myrkul on Thu Apr 14, 2011 10:55 pm; edited 1 time in total
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Mar 28, 2011 4:08 am   
 
1)the easiest way is perhaps to read in the file into a stringlist variable and doing your lookups there instead of at the point of the read-in. Stringlists, unless you set them to be sorted, retain their assignment order so it'd be a trivial thing to do a forwards/backwards lookup of nearby items.

2)I don't think so (should be easy and harmless enough to try, though, if it works and you know the targeted line is not blank then the return result should be that line's text.) It's something that goes way back to the days when flat-file formats were created (DOS, BASIC, etc), and it's been honored by more advanced technologies ever since. First you set up a pointer to the file, then you use that pointer when doing actions to said file.
_________________
EDIT: I didn't like my old signature
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net