Jump to content
zippoxer

Record with methods?

Recommended Posts

I know of the type TForm in SCAR that has methods, so I thought maybe we can do something like this in SCAR 3.28.

The difference is minimal (writing item.Move instead of Move(item)), but if there is a syntax that a language recommends more than it's alternatives then I prefer to use it.

Edited by zippoxer
Link to comment
Share on other sites

I know of the type TForm in SCAR that has methods, so I thought maybe we can do something like this in SCAR 3.28.

The difference is minimal (writing item.Move instead of Move(item)), but if there is a syntax that a language recommends more than it's alternatives then I prefer to use it.

 

You are referring to classes, which SCAR Divi doesn't support yet(Titan does). But basically item.Move means call the Move procedure on an instance of the class called item(do i make sense?)

Link to comment
Share on other sites

It's not a matter of just adding this. The script engine in SCAR Divi simply does not support user-defined classes. Only ones exported to the engine like TForm. You can however define method pointer type fields in records, but they will not be able to directly influence the data of the record. Support for all fo this is added in SCAR 4.

Link to comment
Share on other sites

You are referring to classes, which SCAR Divi doesn't support yet(Titan does). But basically item.Move means call the Move procedure on an instance of the class called item(do i make sense?)

It means that item will be passed (in some way) to Move procedure, but the Move procedure is not global in that case, it's only callable through an instance of Item.

Link to comment
Share on other sites

It means that item will be passed (in some way) to Move procedure, but the Move procedure is not global in that case, it's only callable through an instance of Item.

 

I'm a little late to the show ... but something like this?

 

program New;
type foo = record
 bar: procedure(test: String);
end;

var oof: foo;

procedure rab(test: String);
begin
 WriteLn(test);
end;

begin
 oof.bar := @rab;
 oof.bar('Hello World');
end.

 

I don't think you're getting much closer than that though ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...