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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Baldur
Beginner


Joined: 20 Sep 2002
Posts: 26
Location: Austria

PostPosted: Tue Apr 15, 2003 1:09 pm   

Read
 
Hi,

i have a txt-file where i have some values stored.
It looks like this:

[Weapon]
Sword
Knife
[Armour]
Trousers
[Player]
Player1
Player2
Player3

now i want to read only the lines after the values in [].
eg: ShowMe Player
Then i want to add all the entries after [Player] in a variable.

Can someone tell me how i can do that?

Best Regards,

Baldur
Reply with quote
Talahaski
Enchanter


Joined: 10 Oct 2000
Posts: 656
Location: USA

PostPosted: Tue Apr 15, 2003 3:22 pm   
 
why don't you store this in a database instead.

Talahaski
Processor PIII 1000
Memory 265MB
Video NVIDIA 64MB
Windows XP
Zmud Version 6.55a
Zmapper Version 1.14

http://www.dartmud.com
Reply with quote
Baldur
Beginner


Joined: 20 Sep 2002
Posts: 26
Location: Austria

PostPosted: Wed Apr 16, 2003 1:46 am   
 
Because i create the txt-files with a Visual Basic Programm. If you can tell me how to write into a Zmud-Database from VB i can do that :)
Reply with quote
Talahaski
Enchanter


Joined: 10 Oct 2000
Posts: 656
Location: USA

PostPosted: Wed Apr 16, 2003 6:15 pm   
 
is this the entire file, or can your text file have multiple occurances like:

[Weapon]
Sword
Knife
[Armour]
Trousers
[Player]
Player1
Player2
Player3
[Weapon]
Sword
Knife
[Armour]
Trousers
[Player]
Player1
Player2
Player3

I', sure there are more efficient ways to do this.

Anyway, here is something to get you started.
#alias load_players {#FILE 1 test.txt;read_file}
#alias read_file {#if (%read(1) = "[Player]") {get_players} {read_file}
#alias get_players {#var temp_player {%read(1)};if (@temp_player =~ (~[*~])) {#noop} {#if (@temp_player = "") {#nopp} {#additem player_list @temp_player}}

This should get you started, there are some things i did not consider, if the file does not contain a [player] then the alias may blow up.


Talahaski
Processor PIII 1000
Memory 265MB
Video NVIDIA 64MB
Windows XP
Zmud Version 6.55a
Zmapper Version 1.14

http://www.dartmud.com
Reply with quote
Talahaski
Enchanter


Joined: 10 Oct 2000
Posts: 656
Location: USA

PostPosted: Wed Apr 16, 2003 6:23 pm   
 
just to give you a walk through.

#alias load_players {#FILE 1 test.txt;read_file}

This alias will kick off the entire process. It will open the file and call a seperate alias to start reading it.

#alias read_file {#if (%read(1) = "[Player]") {get_players} {read_file}

this alias will read the file and look for [Player] string, if found, it will call the alias to get the players name, else it will read the next line in the file.

#alias get_players {#var temp_player {%read(1)};if (@temp_player =~ (~[*~])) {#noop} {#if (@temp_player = "") {#nopp} {#additem player_list @temp_player}}

This last alias will put the lines after the [player] into a holding variable, check if that line has any bracket values or if the line is empty. if not, it will load the line into the player list


Talahaski
Processor PIII 1000
Memory 265MB
Video NVIDIA 64MB
Windows XP
Zmud Version 6.55a
Zmapper Version 1.14

http://www.dartmud.com
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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