Game Development Community

Nulls and Numbers Broke

by Howard Dortch · in Torque Game Engine · 02/13/2007 (12:31 pm) · 3 replies

I save data to a file in the form of a 0. When I read the file and try to use that value as an array reference it fails because the number is null, not zero null, nothing, nadda.
I have noticed this in other areas where you set a value to 0 and the engine/script or what ever thinks it's a nothing, null.
So question is does the engine/script mechanism have a way to force something to a zero instead of a null?

$file.writeLine("SEQ "@$Stat.seq); this value is a zero and is in the file as a zero

$Stat.seq = getWord($file.readLine(),1); this is now null not a zero but a null

%mission = $MapList.m[$Stats.seq].path; << massive failure here because there is no number for array index.

Anyone care to help, comment ?

#1
02/13/2007 (1:11 pm)
You are writing to the first word in the line, then trying to read the second word of the line.

getWord() is zero based. use getWord($file.readLine(), 0); instead.
#2
02/13/2007 (1:49 pm)
I might have to disagree with that Stephen.

the file writes the following

SEQ 0

therefore wouldn't I want the readline(),1 to get the 0?
I hope so because I have 100 other lines that all read properly.
#3
02/13/2007 (2:35 pm)
Good point, I didn't look at it fully. Sorry about that!

WHat is the actual line that is being read in when you are getting the null? To be pedantic by the way, it won't be a true null, but an empty string (or possibly a space, which can be hard to detect).