• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

HGS: can it output to XML?

No problem, Andrew, thanks. I see you have a CSV format, which is fine.

Would you be interested in talking about a slightly more flexible file structure? I don't use Delphi, but I've done pascal back in the day, and I'd be up for writing a bit of it if that would help.

Tell me what environment yre using, and I'll see what I can dig up. Object Pascal and DWScript?


Would you consider trying out JSON? There are libraries for Delphi here: http://www.json.org/

In a nutshell, JSON is a way of storing arrays and dictionaries (a k a hash tables) of data into text. So for example, you could store a structure containing keyed data with one write command, and read it back in with one corresponding read. It takes away the pain of writing and reading the data field by field line by line. You still have to move the data into and out of a has table structure, but you've abstracted away the data in the physical file. It is a flexible structure which can grow as you need it without requiring you to manage the file format.

So instead of a CSV of file data, yd have a mixture of CSV and key-value pairs, nested if you want.

Ok, enough evangelizing.
 
Last edited:
Ok, a bit more evangelization.

You've got a bit of an HGS ship in a file that looks like this:

{ ship name: 'Beowulf', tons: 200, drives: [], weapons: [] }

I'm lazy, so I left the drives array and weapons array empty. Anyway, you'd slurp the file into a string. Then to parse it, you'd call the provided library function:

var obj:TJSONObject = TJSONObjest.ParseJSONValue( mystring );

From there you extract the appropriate data out, according to their keys.

TJASONPair snpair = obj.Get( "ship name" );
TJASONPair weapons = obj.Get( "weapons" );
TJASONPair drives = obj.Get( "drives" );
TJASONPair hull = obj.Get( "hull data" );

...and so on. Anyway, it still requires loading the data, but it decouples your data from the physical details of the file.
 
Last edited:
Now. Even if you don't go the JSON route, what about a file with headers used to split up the data into sections, sort of vaguely like how SEC files are set out?

One potential example:

Code:
HULL

Hull, B, 200 tons, MCr 20
Configuration, Streamlined, 0 tons, MCr 2
Computer, Model/1 bis, 1 ton, MCr 1

DRIVES

Jump, 1, 4 tons, MCr 4
Maneuver, 1, 4 tons, MCr 8
Power, 1, 4 tons, MCr 4

WEAPONS

Turret, Triple, 1 ton, MCr 1
Weapon, Beam Laser, MCr 1
Weapon, Missile, MCr 0.1
Weapon, Sand, MCr 0.1

PAYLOAD

Cargo, Standard, 80 tons, MCr 0
Staterooms, Passenger, 40 tons, MCr 5
Staterooms, Crew, 20 tons, MCr 2.5
 
Back
Top