Programming Guide : 4. Working with Classes : How You Can Manipulate Objects Generically: Casting : How You Can Work with Methods
 
Share this page                  
How You Can Work with Methods
Assume you send a StringObject as a MessageObject from FrameA to FrameB, and you want to use the WriteToFile method on the MessageObject in FrameB. Because WriteToFile is defined for the StringObject class, you must cast the message object to avoid a compile error when you use the WriteToFile method.
FrameA contains the following statement:
FrameB_exec.SendUserEvent(EventName = 'Send_String',
    MessageObject = string_file);
The following code fragment from FrameB declares a string variable to receive the MessageObject, casts the MessageObject to a StringObject, and uses the WriteToFile method:
initialize (...) =
declare
    stringobj = StringObject default null;
enddeclare
begin
...
on userevent 'Send_String' =
begin
    stringobj =
    StringObject(CurFrame.MessageObject);
    stringobj.WriteToFile(filename = msg_string);
...