Louis S.
White Plains, NY

Mar 30, 2011
13 Posts

For Each

Does anynone know if there is a way to use VB's For Each functionality within ATEasy?  LBound and UBound also look to be undefined which would be my usual backup.  The last ditch attempt would be to calculate array lengths via sizeof, but this gets messy when using for iterating over objects.

Thanks,
Louis

DrATEasy (Ron Y.)
Mission Viejo,

Mar 30, 2011
235 Posts

Re: For Each

There is no "for each" statement in ATEasy, however if you are looping on array or variant you can use the sizeof operator for array or the VarDimSize() internal function to figure out the number of elements for iteration.

If you are iterate around a COM or .NET object that are based on IEnumerable interface you can use the Count property. So instead of VB.NET:

For Each element as MyType in MyList
    ....
Next


Use:

For i = 0 to MyList.Count - 1
    element = MyList(i)
    ....
Next


Ron

Louis S.
White Plains, NY

Apr 6, 2011
13 Posts

Re: For Each

Is there any chance of for each support in an upcoming release?  It's not a make-or-break feature (we've been very successful in the past with ATEasy) but any little thing that makes the test code more readable helps make the test cases easier to maintain down the road.

DrATEasy (Ron Y.)
Mission Viejo,

Apr 6, 2011
235 Posts

Re: For Each

Will add to our suggestion list for version 9.0.

Louis S.
White Plains, NY

Apr 13, 2011
13 Posts

Re: For Each

Thanks!  If it's not to late to sneak "Me" (self-referencing) support on there that would also be much appreciated for developing forms.

DrATEasy (Ron Y.)
Mission Viejo,

Apr 13, 2011
235 Posts

Re: For Each

You can use the Form variable for Me. For example

Form.Controls(i).Visible=True

Louis S.
White Plains, NY

Apr 13, 2011
13 Posts

Re: For Each

Yes, but if I have a bunch of checkboxes (ex: chkBox1, chkBox2, chkBox3) all of which perform:

   set_output_driver(chkBox1.tag, chkBox1.value)

when I copy paste from the first to create the next two, it requires hand editing to ensure the names are correct.  If the code was instead:

  set_output_driver(Me.tag, me.value)

than there are less opportunities for mistakes.  This is especially true if the controls are renamed somewhere along the line.  I guess it's not very DRY code to copy and paste the controls and code in either example, but I'm not sure if there's a better way in ATEasy.  If anyone knows of anything that's worked well for them in the past, I'd be very interested.

Solution Available
DrATEasy (Ron Y.)
Mission Viejo,

Apr 13, 2011
235 Posts

Re: For Each

Use Control variable:

set_output_driver(Control.tag, Control.value)



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]