Welcome, Guest
Username: Password: Remember me
Components and Libraries for Scripting Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

TStringList 9 years 3 months ago #8007

  • Chris
  • Chris's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
Hi All

I'm trying to add a TStringList variable into a pascalscript - using the demo application in CodeOcean which supposedly has the classes register at compile and execution time I still see errors;

The program is trivial;
program Test;

uses Classes; 

var T:TStringList;
begin
  T := StringList.Create;
  T.Add('Test');
  T.Free;
end.

as above I get the compilation error;

Compiling
Compiler: [Error] (3:6): Unknown identifier ''
Compiling failed

if I take out the uses clause I get;

Compiling
Compiler: [Error] (3:7): Unknown type 'TStringList'
Compiling failed


Weird thing is I can register a variable as type TStringList externally (pre-compilation from within CT) and then use it and it's methods within pascalscript but I don't seem to be able to declare a new variable of this type within the script itself.

I'm presuming there's some registration method I need to call but the CodeOcean demo appears to have all the methods already registered.

Is there something I'm missing? I'm sure it used to work fine as I have a couple of old scripts that use TStringList variables and I wasn't aware they didn't work (I've tried CT4.5 and CT5.5 although they probably use the same version of pascalscript).

TheBlackSheep

Please Log in or Create an account to join the conversation.

TStringList 9 years 3 months ago #8008

  • wilhelm
  • wilhelm's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 5
  • Thank you received: 0
T := TStringList.Create;

Please Log in or Create an account to join the conversation.

TStringList 9 years 3 months ago #8010

  • Chris
  • Chris's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
ok - small typo, but it still doesn't work - tested on CT5.4 on Linux64 (Fedora), CT5.2 Win7 32bit, CT5.4, CT5.5 Win8.1 64bit - on all of these platforms I get the same results.

Basically I'm trying instantiate a TStringList from within a script...Is it possible and if so how? I'm using the CodeOcean TestApp application in the PascalScript samples folder.

The registration functionality appears to be in there (note, you do have to assign the ...Import events of the pascalscript component to the code that's in the Test App although I've tried calling these manually and you get the same result);

CompileImport;
  SIRegister_Std(x);
  SIRegister_Classes(x, true);
   ...

ExecImport;
  RIRegister_Std(x);
  RIRegister_Classes(x, True);
  ...

and the registration code for these functions calls the functions to register the TStringList (and all the other classes);
  ...
  RIRegisterTStrings(cl, Streams);
  RIRegisterTStringList(cl);
  ...

However when you do this and instantiate and use a TStringList variable you get a runtime 216 error/exception.

It looks like it should work, anyone any ideas?

Chris

Please Log in or Create an account to join the conversation.

Last edit: by Chris. Reason: typo

TStringList 9 years 3 months ago #8013

  • Chris
  • Chris's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
Also checked that the Classes unit does register and work ok in Delphi2007 - there are other issues with the registration of other units (forms, controls - drawevents specifically) but the Classes unit - strings, collections etc appears to work ok.
program Test;
var T:TStringList;
begin
  T := TSTringList.Create;
  T.Add('1234');
  ShowMessage(T.Text);
  T.Free;
end.

I've registered the ShowMessage function in the compile event and that works fine (testing a slimmed down version of the above) but as soon as it hits the class instantiation "T:= TStringList.Create;" it throws the exception; specifically in the CREATE$$OBJECT method;

0040D166 7411 je 0x40d179 <SYSTEM$_$TOBJECT_$__$$_CREATE$$TOBJECT+89>

Please Log in or Create an account to join the conversation.

  • Page:
  • 1