View Full Version : line() oddness.

12-31-2012, 12:05 PM
Based on Mike Green's LScript documentation(*), I tried this :


in the hope that this would move the file pointer to the fifth line. Instead, I always get an error that 5 is out of range (even for a many line file that's being otherwise successfully read or written).

I'm unable to find the official documentation for this - the LScript docs are an exercise in frustration. Is this supposed to work in the way I attempted?


12-31-2012, 06:11 PM
Not in front of my PC at the moment, but Lscipt is funny in many ways as a lot of arrays are 1 based not 0 based. Perhaps this is the opposite, does moving to line 4 take you to the beginning of what you think is 5?

12-31-2012, 06:14 PM
Nope. I've tried 10 line files with .line(4) and .line(5). Both fail with the same error. I'm beginning to wonder if Mike's docs are wrong, but since the official LScript docs are such a godawful mess, I haven't yet found where they discuss .line at all. :/

01-01-2013, 03:17 AM
dumb question, but is the file you are reading binary? the line() function doesn't work with binary (non-text) files...

01-01-2013, 09:19 AM
Nope. However, I must be doing something wrong because other scripts use this approach and it seems to work for them. I'll have to take a closer look once I'm through with this QA of the latest Passport code. *gulp*

01-02-2013, 01:22 PM
This seems to work for me in 11.0.3 on Mac UB. Just change the starting directory path as needed at the beginning, and the line you want to read.

@script generic

var startingPath = "/";
var lineToRead = 111;

scenePath = getfile("Choose a LightWave Scene File","*.lws",startingPath,1);
input = File(scenePath,"ra");
string = input.read();

01-04-2013, 02:41 AM
the line you are trying to read, is the final one? if so, it can be necessary to add an empty line to the next line.