Hi all...
I'm having a bit of fun playing with JSTalk (using 1.0.1 downloaded from
jstalk.org), trying to write a text-meddling script which I would normally throw together in awk (!).
I'd like to use -[NSScanner scanUpToString:intoString:], but this returns a string by reference, and I don't see how to get that string into a variable in JSTalk. Is this possible?
The relevant NSScanner API is:
- (BOOL)scanUpToString:(NSString *)stopString intoString:(NSString **)stringValue
I've tried the following, but this crashes JSTalk Editor...
var inputContent = [NSString stringWithContentsOfFile:inputPath encoding:NSUTF8StringEncoding error:nil];
var scanner = [NSScanner scannerWithString:inputContent];
var input = @"";
var ret = [scanner scanUpToString:@"," intoString:input];
print("ret = " + ret);
print("input = " + input);
Using the & operator like the following gives "Unexpected token '&'":
var ret = [scanner scanUpToString:@"," intoString:&input];
Is there a suitable magic incantation?
Best wishes,
Ashley.