[edit] Oops, I mean CSV files, not CVS.
Edited by SHiLLySiT, 15 December 2010 - 05:45 AM.
Posted 15 December 2010 - 05:42 AM
Edited by SHiLLySiT, 15 December 2010 - 05:45 AM.
Posted 15 December 2010 - 05:49 AM
string="Bob,21,1,16,1975" open_variables(string,",") name=Var[1] age=real(Var[2]) bornmonth=real(Var[3]) bornday=real(Var[4]) bornyear=real(Var[5]
Posted 15 December 2010 - 05:52 AM
Posted 15 December 2010 - 05:58 AM
I have been using this script ever since I made it for many of my games and it does the job well.
If I may direct you to the website I have posted this script at:
http://sigonasr2.servegame.org/zgamers/v5/forum/index.php?topic=16.msg77#msg77
How you would use it is as follows. Let's say you had a list of numbers and Strings that you would like to parse. Let's say they're separated by commas, like most CSV files. "Bob,21,1,16,1975"
Now, using this script, you can do this:string="Bob,21,1,16,1975" open_variables(string,",") name=Var[1] age=real(Var[2]) bornmonth=real(Var[3]) bornday=real(Var[4]) bornyear=real(Var[5]
Notice that I converted the numbers to real? This script returns all values as strings. The first argument of my custom script is the string itself to parse. The second argument is what the values are separated by. In this case, a comma. It has to be a string, so I wrap it in quotes. The script returns each value in an array in Var[X] format, so you can then extract everything that way!
It can return the number of values it parsed and also where it parsed them, but I doubt you will need those unless you are doing some serious automation work. Hope that helps! If you need me to elaborate more, I can. There is an example gmk on the site where the script is located also.
0 members, 0 guests, 0 anonymous users