Jump to content
Sign in to follow this  
Champak

VB snippet conversion help

Recommended Posts

Champak

Need some help translating this. This is an object enumeration, but how does the "Each" translate into autoit?

For Each suppSpeedX In Speeds
            
            Call lstSpeeds.AddItem(Str(suppSpeedX.SpeedR) _
                                        + "x" _
                                        + " (" _
                                        + Str(suppSpeedX.Speed) _
                                        + " kbs)" _
                                        )
            
            If (objInfo.WSpeedX = suppSpeedX.Speed) Then
                lstSpeeds.ListIndex = lstSpeeds.ListCount - 1
            End If
        Next

Thanks.

Share this post


Link to post
Share on other sites
Zedna

For suppSpeedX In Speeds
  lstSpeeds.AddItem(suppSpeedX.SpeedR & "x" & " (" & suppSpeedX.Speed & " kbs)" )
      If objInfo.WSpeedX = suppSpeedX.Speed Then
        lstSpeeds.ListIndex = lstSpeeds.ListCount - 1
      End If
Next

Edited by Zedna

Share this post


Link to post
Share on other sites
Champak

What you have is what I've tried. So the "Each" and "Str" serve no purpose in the translation? Because I seem to only be getting the last thing/element, or whatever it's called, from the object array. I figured the "Each" would be the defining thing. What this is doing..the VB version..is adding things to a combobox. But it seems like AutoIts enumeration works differently from VBs enumeration. VBs Enumeration seems to work like AutoIts "For $x = 1" style loop. Or am I totally off base here?

Share this post


Link to post
Share on other sites
PsaltyDS

What you have is what I've tried. So the "Each" and "Str" serve no purpose in the translation? Because I seem to only be getting the last thing/element, or whatever it's called, from the object array. I figured the "Each" would be the defining thing. What this is doing..the VB version..is adding things to a combobox. But it seems like AutoIts enumeration works differently from VBs enumeration. VBs Enumeration seems to work like AutoIts "For $x = 1" style loop. Or am I totally off base here?

Do you have an object reference in $1stSpeeds that has an .AddItem method while in AutoIt? Zedna didn't show any conversion to AutoIt variable syntax. Maybe something like:
#include <GuiComboBox.au3>

Global $1stSpeed; Contains handle to combo control...
Global $1stSpeedCount; Contains count of items in combo
; ...

For $suppSpeedX In $Speeds
    _GUICtrlComboBox_AddString($1stSpeed, String($suppSpeedX.SpeedR * $suppSpeedX.Speed) & "kbs")
Next
$1stSpeedCount = _GUICtrlComboBox_GetCount($1stSpeed)

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Champak

Good thought, but I have actually been using consolewrite. I went ahead and tried _GUICtrlComboBox_AddString() anyway, but I get the same result.

EDIT: It is always the simple things. I went ahead and put a slight sleep in the loop, which I really shouldn't have to do, and that worked.

Thanks to both for the effort.

Edited by Champak

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.