SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6

Thread: dynamic array

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    dynamic array

    hi

    how to declare Dynaimc array in Testcomplete using delphi?

    in VBscripting i will declare as 'Dim Param_array()'
    caw can i do the same in Delphi?

    thanks and regards,

  2. #2
    Senior Member
    Join Date
    May 2004
    Posts
    1,196
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: dynamic array

    Hi,

    You can use the CreateVariantArray and VarArrayRedim methods described in the 'BuiltIn.CreateVariantArray' and 'BuiltIn.VarArrayRedim' help topics.

    Here is a sample script that demonstrates how to create a dynamic array and work with it:

    [DelphiScript]
    procedure Test;
    var a: OleVariant;
    begin
    a := CreateVariantArray(1, 10);
    a[1] := 'Test 1';
    a[10] := 'Test 10';
    Log.Message(BuiltIn.VarArrayHighBound(a, 1));
    VarArrayRedim(a, 20);
    a[15] := 'Test 15';
    Log.Message(BuiltIn.VarArrayHighBound(a, 1));
    Log.Message(a[10]);
    Log.Message(a[15]);
    end;
    Best regards,
    David - SmartBear Support

  3. #3
    Senior Member
    Join Date
    Aug 2001
    Location
    Manchester, NH
    Posts
    121
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: dynamic array

    That's good info. I have only been using TestComplete for a couple weeks, but I had been looking for a way create dynamic arrays in DelphiScript, and I hadn't been able to find a way to do that. The online help kept pointing me to the ArrayType Object, which was no help, so I had been grudgingly been working with MyArray : array[0..10] of string and writing my own function to count the actual items in the array (and had found no way to resize).

  4. #4
    Senior Member
    Join Date
    Oct 2004
    Location
    Las Vegas
    Posts
    473
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: dynamic array

    Hi,

    If you type 'array' in the Index tab of the TestComplete help system, you will find the 'Arrays, in DelphiScript' keyword right above the 'ArrayType object' keyword (exactly two lines above).

    Atanas

  5. #5
    Member
    Join Date
    Oct 2006
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: dynamic array

    can we use "elseIf" Statement in testcomplete using delphi scripting?

    if no, then how can we achive the same?

    can anyone tell me how to declare functions and Procedures using delphi scripting? how to call the same in some other function?with an example?

    thanks in advance.

  6. #6
    Senior Member
    Join Date
    May 2004
    Posts
    1,196
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: dynamic array

    Hi,

    The DelphiScript syntax is similar to Standard Pascal (not Object Pascal). You can find some useful information about DelphiScript in the 'DelphiScript Description' help topic. The following script demonstrates nested conditional statements and the syntax of functions and procedures:

    <font class="small">Code:</font><hr /><pre>// DelphiScript
    function Func1(a: OLEVariant): OLEVariant;
    begin
    if a &lt; 0 then
    begin
    Func1 := a + 1;
    end
    else
    begin
    if a = 0 then
    Func1 := 1
    else
    Func1 := a - 1;
    end;
    end;


    procedure Test;
    var ReturnedValue: OLEVariant;
    begin
    ReturnedValue := Func1(0) + 1;
    Log.Message(ReturnedValue);
    end;


    procedure Main;
    begin
    Test;
    end;</pre><hr />
    Best regards,
    David - SmartBear 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 10.00%
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 04:33 AM.

Copyright BetaSoft Inc.