KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Control Arrays - Golfing etc

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jun 15, 2006 8:55 pm    Post subject: Control Arrays - Golfing etc Reply with quote

Okay I have the following piece of code, and would like some help in converting it to control arrays (if feasible) so that I can learn it better.

This code functions just fine, but looking to make it more effeccient (sp).

Code:

$top = 55
$left = 15
for $ = 1 to 55
 

   Execute("$LBL_Num_"+$+" = $System.Label()")
   Execute("$LBL_Num_"+$+".BorderStyle = 1")  ;FixedSingle
   Execute("$LBL_Num_"+$+".Left ="+$Left)
   Execute("$LBL_Num_"+$+".Text = "+$)
   Execute("$LBL_Num_"+$+".Top = "+$Top)
   Execute("$LBL_Num_"+$+".Width = 20")
   Execute("$nul = $Form1.Controls.Add($LBL_Num_"+$+")")
   
   Execute("$LBL_Text1_"+$+" = $System.Label()")
   Execute("$LBL_Text1_"+$+".BorderStyle = 1")  ;FixedSingle
   Execute("$LBL_Text1_"+$+".Left ="+($left+20))
   Execute("$LBL_Text1_"+$+".Text = 'Has been selected'")
   Execute("$LBL_Text1_"+$+".Top = "+$Top)
   Execute("$nul = $Form1.Controls.Add($LBL_Text1_"+$+")")
   
   Execute("$LBL_Perc_"+$+" = $System.Label()")
   Execute("$LBL_Perc_"+$+".BorderStyle = 1")  ;FixedSingle
   Execute("$LBL_Perc_"+$+".Left ="+($left+125))
   Execute("$LBL_Perc_"+$+".Top = "+$Top)
   Execute("$LBL_Perc_"+$+".Width = 20")
   Execute("$nul = $Form1.Controls.Add($LBL_Perc_"+$+")")
   
   Execute("$LBL_Text2_"+$+" = $System.Label()")
   Execute("$LBL_Text2_"+$+".BorderStyle = 1")  ;FixedSingle
   Execute("$LBL_Text2_"+$+".Left ="+($Left+155))
   Execute("$LBL_Text2_"+$+".Text = 'of the time'")
   Execute("$LBL_Text2_"+$+".Top = "+$Top)
   Execute("$LBL_Text2_"+$+".Width = 65")
   Execute("$nul = $Form1.Controls.Add($LBL_Text2_"+$+")")

   $Top = $Top + 25
If $ = 28
   $Top = 55
   $Left = 250
EndIf
Next


And of course if Jooel wants to show me how to golf this to the bare minimum I would be highly appreciative.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Jun 15, 2006 9:18 pm    Post subject: Reply with quote

well, if you really want to keep the var references (I would drop them), you can do something like:
Code:

dim $LBL_Num[54], $LBL_Text1[54], $LBL_Text2[54], $LBL_Perc[54]
$top = 55
$left = 15
for $ = 0 to 54

  $LBL_Num[$]=$Form1.Controls.Add($System.Label)
  $LBL_Num[$].BorderStyle = 1 ;FixedSingle
  $LBL_Num[$].Left = $Left
  $LBL_Num[$].Text = $
  $LBL_Num[$].Top = $top
  $LBL_Num[$].Width = 20

  $LBL_Text1[$] = $Form1.Controls.Add($System.Label)
  $LBL_Text1[$].BorderStyle = 1
  $LBL_Text1[$].Left = $left+20
  $LBL_Text1[$].Text = 'Has been selected'
  $LBL_Text1[$].Top = $Top
   
  $LBL_Perc[$] = $Form1.Controls.Add($System.Label)
  $LBL_Perc[$].BorderStyle = 1
  $LBL_Perc[$].Left = $left+125
  $LBL_Perc[$].Top = $Top
  $LBL_Perc[$].Width = 20 
   
  $LBL_Text2[$] = $Form1.Controls.Add($System.Label)
  $LBL_Text2[$].BorderStyle = 1
  $LBL_Text2[$].Left = $Left+155
  $LBL_Text2[$].Text = 'of the time'
  $LBL_Text2[$].Top =  $Top
  $LBL_Text2[$].Width = 65

  $Top = $Top + 25
  If $ = 28
   $Top = 55
   $Left = 250
  EndIf
Next

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jun 15, 2006 9:27 pm    Post subject: Reply with quote

Quote:
well, if you really want to keep the var references (I would drop them)


Not sure I understand what you are driving at here.

However thanks for the code, I knew it should be easy, but I could not find any of the other examples that are out there.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Jun 15, 2006 9:31 pm    Post subject: Reply with quote

and if you wanna golf it, here is a example written on the fly (that also means I haven't tested it at all)
Code:

dim $lbl_helper[54],$LBL[3]
 
$left = 15,35,140,170
$width = 20,,20,65

for $i=0 to 3
 $LBL[$i] = $lbl_helper
 $top = 55
 for $ = 0 to 54
  $text = $, 'Has been selected',,'of the time'
  $LBL[$i][$]=$Form1.Controls.Add($System.Label)
  $LBL[$i][$].BorderStyle = 1
  $LBL[$i][$].Left = $Left[$i]
  $LBL[$i][$].Text = $
  $LBL[$i][$].Top = $top
  $LBL[$i][$].Width = $width[$i]

  $Top = $Top + 25
  If $ = 28
   $Top = 55
   $Left = 250
  EndIf
 Next
next

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jun 15, 2006 9:37 pm    Post subject: Reply with quote

Damn,

My head hurts trying to understand that golf. But that is one hell of a golf from my original code.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Jun 15, 2006 9:50 pm    Post subject: Reply with quote

actually.
it does not work.
the left code is not working...

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Jun 15, 2006 9:51 pm    Post subject: Reply with quote

k, this one should work.
Code:

dim $lbl_helper[54],$LBL[3]
 
$left = 15,35,140,170
$width = 20,,20,65

for $i=0 to 3
 $LBL[$i] = $lbl_helper
 for $ = 0 to 54
  $text = $, 'Has been selected',,'of the time'
  $LBL[$i][$]=$Form1.Controls.Add($System.Label)
  $LBL[$i][$].BorderStyle = 1
  $LBL[$i][$].Left = $Left[$i] + ($>26)*235
  $LBL[$i][$].Text = $
  $LBL[$i][$].Top = 55 + 25*$*($<27) + 25*($-27)*($>27)
  $LBL[$i][$].Width = $width[$i]
 Next
next

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group