SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Nov 2007
    Location
    Amsterdam, The Netherlands
    Posts
    86
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Get Procedure and Fuctions by a script

    Hello,

    Does anybody know how i can get functions en procedure form 1 specified unit.

    Let me explane what i ment.

    I have a form with a listbox.
    In the listbox i want do display all function and procedures that are created in one speciefied unit, so the user can select from the form witch test he want to run.

    anybody??
    ______________
    Regards,

    Raymond Wiertz
    Quality Assurance

    Furore.com

  2. #2
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get Procedure and Fuctions by a script

    Hi CrazyFrog,

    You can use the following function. It returns function names declared in a unit as an array:

    <font class="small">Code:</font><hr /><pre>// JScript
    //USEUNIT MyUnit
    function getMethodList(obj)
    {
    var methods = BuiltIn.EnumMethods(obj, true);
    var current, list = new Array();

    while(methods.HasNext())
    {
    current = methods.Next();
    list.push(current.Name);
    }

    return list;
    }
    ...
    Log.Message(getMethodList(MyUnit).join("\r\n"));
    ...</pre><hr />
    Jared - AQA Support

  3. #3
    Member
    Join Date
    Nov 2007
    Location
    Amsterdam, The Netherlands
    Posts
    86
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get Procedure and Fuctions by a script

    Jared,

    Thanks, that is exactly what i wanted.
    ______________
    Regards,

    Raymond Wiertz
    Quality Assurance

    Furore.com

  4. #4
    Member
    Join Date
    Nov 2007
    Location
    Amsterdam, The Netherlands
    Posts
    86
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get Procedure and Fuctions by a script

    How does this works with DelfiScript.
    I built is as below, but i got alwas a false form the HasNext method


    function getMethodList(obj): list;
    var
    methods ;
    current, list;
    begin
    methods := BuiltIn.EnumMethods(obj, True);
    while (methods.HasNext) do
    begin
    current := methods.Next();
    list.push(current.Name);
    end;
    result := list;
    end;



    The unit Testen is as below.
    What do i wrong




    uses
    UExcel_afhandeling,
    UAansturing_Excel,
    Constants;


    procedure test1; forward;
    procedure test2; forward;
    procedure StartMainForm;forward;


    procedure test1;
    begin
    StartTest('d:\TestComplete\Excel\AutoTest_Template .xls', 'DivX');
    end;



    procedure test2;
    begin
    StartTest('d:\TestComplete\Excel\AutoTest_Template .xls', 'DellWMgr');
    end;

    procedure StartMainForm;
    begin
    Log.Message(getMethodList(Testen));
    UserForms.MainForm.ShowModal;
    end;
    ______________
    Regards,

    Raymond Wiertz
    Quality Assurance

    Furore.com

  5. #5
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get Procedure and Fuctions by a script

    Hi CrazyFrog,

    Unfortunately, this is a DelphiScript limitation - it doesn't build type info for units, and we cannot modify this behavior (a third-party engine is used).
    In DelphiScript, you can store the list of functions in a global string variable located in the needed unit and update the string when a function is added to the unit or removed from it.
    Jared - AQA Support

  6. #6
    Member
    Join Date
    Nov 2007
    Location
    Amsterdam, The Netherlands
    Posts
    86
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get Procedure and Fuctions by a script

    Thanks Jared,

    But i don't like the solution.
    so i think that i build my own routine to get the functions.

    regards,
    CrazyFrog
    ______________
    Regards,

    Raymond Wiertz
    Quality Assurance

    Furore.com

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get Procedure and Fuctions by a script

    Hi CrazyFrog,

    There's another possible solution. You can read the target unit file in your script and retrieve routine names from it. This should be easy enough - you just need to find all values located between the 'function' or 'procedure' word and a semicolon.
    Please see the "Working With Files From Scripts" help topic for more information.
    Jared - AQA Support

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:41 PM.

Copyright BetaSoft Inc.