Forum Discussion

Morgan's avatar
Morgan
Frequent Contributor
14 years ago

Script conversion from vb to delphi not working quite right

I am converting a section of successful vbscript code to delphi script and am having an issue with the following section of code.  The error received when I run the script is "Unknown name - GetTreeNode".  GetTreeNode is a function.  I don't think it is looking at that so I didn't include that code.  Tree, sNodeName, and sChildName are defined as strings in the beginning of the procedure.  Node is set as an OleVariant.  I feel like something isn't right with the conversion of the node:= line but I am not sure what.



tree:= w.VCLObject('Eltree1');

sNodeName := 'Node 123';

sChildNode := 'Child of Node';



node := GetTreeNode(tree,sNodeName);



-----



Any ideas?



Thanks!

Morgan


2 Replies

  • AlexKaras's avatar
    AlexKaras
    Community Hero
    Hi Morgan,



    The quick guess (as you did not provide us with the relevant amount of code) is that GetTreeNode() is defined in original VBScript below the point you are mentioning in your message.

    If my guess is correct, then you must either forward declare the GetTreeNode() function in the initial part of your DelphiScript unit or move the function, so that its body appears located before the first call to it.