Jump to content
Sign in to follow this  
rcmaehl

Translating to Do Until

Recommended Posts

rcmaehl

Hey all I'm trying to convert this:

GUICtrlCreateLabel("Character"         , 028, 040, 068, 020, 0x00001201)
GUICtrlCreateInput("Character"         , 096, 040, 204, 020, 0x00001201)
GUICtrlCreateLabel("Player"           , 300, 040, 068, 020, 0x00001201)
GUICtrlCreateInput("Player"           , 368, 040, 204, 020, 0x00001201)
GUICtrlCreateLabel("Class"             , 028, 070, 068, 020, 0x00001201)
GUICtrlCreateInput("Class"             , 096, 070, 068, 020, 0x00001201)
GUICtrlCreateLabel("Race"               , 164, 070, 068, 020, 0x00001201)
GUICtrlCreateInput("Race"               , 232, 070, 068, 020, 0x00001201)
GUICtrlCreateLabel("Alignment"         , 300, 070, 068, 020, 0x00001201)
GUICtrlCreateInput("Alignment"         , 368, 070, 068, 020, 0x00001201)
GUICtrlCreateLabel("Gender"           , 436, 070, 068, 020, 0x00001201)
GUICtrlCreateInput("Gender"           , 504, 070, 068, 020, 0x00001201)
GUICtrlCreateLabel("Size"               , 028, 100, 068, 020, 0x00001201)
GUICtrlCreateInput("Size"               , 096, 100, 068, 020, 0x00001201)
GUICtrlCreateLabel("Height"           , 164, 100, 068, 020, 0x00001201)
GUICtrlCreateInput("Height"           , 232, 100, 068, 020, 0x00001201)
GUICtrlCreateLabel("Weight"           , 300, 100, 068, 020, 0x00001201)
GUICtrlCreateInput("Weight"           , 368, 100, 068, 020, 0x00001201)
GUICtrlCreateLabel("Age"                 , 436, 100, 068, 020, 0x00001201)
GUICtrlCreateInput("Age"                 , 504, 100, 068, 020, 0x00001201)
GUICtrlCreateLabel("Looks"             , 030, 130, 050, 020, 0x00001201)
GUICtrlCreateInput("Looks"             , 090, 130, 210, 020, 0x00001201)
GUICtrlCreateLabel("Religion"           , 310, 130, 050, 020, 0x00001201)
GUICtrlCreateInput("Religion"           , 370, 130, 200, 020, 0x00001201)

Into a Do Until Statement. Currently I have:

Global $Label[12] = ["Character", "Player", "Class", "Race", "Alignment", "Gender", "Size", "Height", "Weight", "Age", "Looks", "Religion"]

$Loop = 0
$X[0] = 28
$Y = 40
Do
  GUICtrlCreateLabel($Label[$Loop], $X[0]     , $Y,    68, 020, 0x00001201)
  If 4 > $Loop < 19 Then
   $X[1] = 68
  Else
   $X[1] = 204
  EndIf
  $Info[$Loop] = GUICtrlCreateInput(""         , $X[0]+$X[1], $Y, $X[2], 020, 0x00001201)
  If 4 > $Loop < 19 Then
   $X[0] = 300
  Else
   $X[0] += 164
  EndIf
  $Loop += 1
Until $Loop = 19

However, I'm stuck and keep screwing up. If you could correct me where I'm doing it wrong it'd be appreciated. Ignore the fact that somethings aren't declared in the snippets. I've declared them in my script.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites
rcmaehl

Why use a Do-loop to do a For-loops work?

I don't know, however I'm keeping it a Do-loop because I'm switching it to Do Until X[0] >= 564


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites
Spiff59

I don't really know your requirements, but there's enough variation in the values of those original statements to make it less attractive to try and swap in some simple loop replacement. Were it a necessity, and to allow for easier updates, I might try something like this:

Global $fields = 12, $col_offset = 28, $col_width = 68
Global $Label[$fields][4] = [["Character", 1, 0, 3], _ ; text, row, col, width
        ["Player"   , 1, 4, 3], _
        ["Class"    , 2, 0, 1], _
        ["Race"  , 2, 2, 1], _
        ["Alignment", 2, 4, 1], _
        ["Gender"   , 2, 6, 1], _
        ["Size"  , 3, 0, 1], _
        ["Height"   , 3, 2, 1], _
        ["Weight"   , 3, 4, 1], _
        ["Age"    , 3, 6, 1], _
        ["Looks"    , 4, 0, 3], _
        ["Religion" , 4, 4, 3]]
Global $Input[$fields]
;-------------------------------------------------------------------------------
GUICreate("", 600, 200)
For $x = 0 to $fields - 1
GUICtrlCreateLabel($Label[$x][0], $col_offset + $Label[$x][2] * $col_width, 10 + $Label[$x][1] * 30, $col_width, 020, 0x00001201)
$Input[$x] = GUICtrlCreateInput($Label[$x][0],  $col_offset + ($Label[$x][2] + 1) * $col_width, 10 + $Label[$x][1] * 30 , $Label[$x][3] * $col_width, 020, 0x00001201)
Next
GUISetState()
;-------------------------------------------------------------------------------
While 1
If GUIGetMsg() = -3 then ExitLoop
WEnd

Share this post


Link to post
Share on other sites
rcmaehl

Thanks Spiff59! I didn't think about including a array variable for a column width multiplier.

I modified the code you gave me b/c I prefer to have my math done outside of the GUICtrlCreate()s.

Global $X, $Y, $W
Global $Fields = 12
Global $Label[$Fields][4] = [["Character", 1, 0, 3], _ ; text, row, col, width
        ["Player"   , 1, 4, 3], _
        ["Class"    , 2, 0, 1], _
        ["Race"  , 2, 2, 1], _
        ["Alignment", 2, 4, 1], _
        ["Gender"   , 2, 6, 1], _
        ["Size"  , 3, 0, 1], _
        ["Height"   , 3, 2, 1], _
        ["Weight"   , 3, 4, 1], _
        ["Age"    , 3, 6, 1], _
        ["Looks"    , 4, 0, 3], _
        ["Religion" , 4, 4, 3]]
Global $Input[$Fields]
;-------------------------------------------------------------------------------
GUICreate("", 600, 200)
For $Loop = 0 to $Fields - 1
$X = 28 + $Label[$Loop][2] * 68
$Y = 10 + $Label[$Loop][1] * 30
$W = 00 + $Label[$Loop][3] * 68
GUICtrlCreateLabel($Label[$Loop][0], $X, $Y, 68, 020, 0x00001201)
$Input[$Loop] = GUICtrlCreateInput("",  $X + 68, $Y, $W, 020, 0x00001201)
Next
GUISetState()
;-------------------------------------------------------------------------------
While 1
If GUIGetMsg() = -3 Then ExitLoop
WEnd

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

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  

×