Re: [Gambas-user] Disable controls by Tag

2009-05-29 Thread Jorge Carrión
You are right, Ron_1st, always should comment the code. I'm afraid I'm too
lazy... or too optimist..
Regards
Jorge

2009/5/29 Ron_1st ron...@tiscali.nl

 On Thursday 28 May 2009, Jorge Carrión wrote:
  ¿Perhaps trying sonething like this?
 
  PUBLIC SUB btnQuick_Click() 'toggle button
 
DIM hCtl AS Control
 
IF btnQuick.Value = TRUE THEN
FOR EACH hCtl IN FMain.Controls
TRY hCtl.Enabled = (hCtl.Tag  exclude)
NEXT
 
  it Is not very elegant but it works, I guess.
  Regards
  Jorge
 


 I'n happy it works now at Jesus Guardon's box.

 The TRY is also a nice way. You can try it to get more
 speed in the loop and it gives a more nice text layout.

 Against that way is you forget why you use the trick
 and now it is good help to know a method to prevent
 the error.
 Any way if you start using the TRY method add a remark
 why it is used.



 Best regards,

 Ron_1st

 --



 --
 Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
 is a gathering of tech-side developers  brand creativity professionals.
 Meet
 the minds behind Google Creative Lab, Visual Complexity, Processing, 
 iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
 Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Disable controls by Tag

2009-05-29 Thread Jesus Guardon
Ron_1st escribió:
 On Thursday 28 May 2009, Jorge Carrión wrote:
 ¿Perhaps trying sonething like this?

 PUBLIC SUB btnQuick_Click() 'toggle button

   DIM hCtl AS Control

   IF btnQuick.Value = TRUE THEN
   FOR EACH hCtl IN FMain.Controls
   TRY hCtl.Enabled = (hCtl.Tag  exclude)
   NEXT

 it Is not very elegant but it works, I guess.
 Regards
 Jorge

 
 
 I'n happy it works now at Jesus Guardon's box.
 
 The TRY is also a nice way. You can try it to get more
 speed in the loop and it gives a more nice text layout.
 
 Against that way is you forget why you use the trick
 and now it is good help to know a method to prevent
 the error.
 Any way if you start using the TRY method add a remark 
 why it is used.
 
 
 
 Best regards,
 
 Ron_1st
 
I agree with Ron_1st. I don't like to use TRY if there's not a good 
reason to. Anyway, Jorge's code looks pretty and short. Here is another 
approach without 'TRY':

 FOR EACH hCtl IN FMain.Controls
 IF hCtl IS TextBox OR hCtl IS ComboBox THEN 'etc
 IF hCtl.Tag = exclude THEN
 IF btnQuick.Value = TRUE THEN
 hCtl.Enabled = FALSE
 ELSE
 hCtl.Enabled = TRUE
 ENDIF
 ENDIF
 ENDIF
 NEXT

But it could be slower because it checks button state in each loop.

Regards

Jesus

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Disable controls by Tag

2009-05-28 Thread Ron_1st
On Thursday 28 May 2009, Jesus Guardon wrote:
 Hi all
 
 It seems a basic question, but I'm unable to get it to work.
 I need to enable/disable a group of mixed controls in the Main Form, but 
 instead of doing individually, I'd prefer to do so by iterating.
 
 Following is the code I'm using and it gives an error Wanted string, 
 date or integer, got function instead
 
 What I'm doing wrong?
 
 PUBLIC SUB btnQuick_Click() 'toggle button
 
  DIM hCtl AS Control
 
  IF btnQuick.Value = TRUE THEN
  FOR EACH hCtl IN FMain.Controls
  IF hCtl.Tag = exclude THEN hCtl.Enabled = FALSE
  'DEBUG hCtl.Tag
  NEXT
  ELSE
  FOR EACH hCtl IN FMain.Controls
  IF hCtl.Tag = exclude THEN hCtl.Enabled = TRUE
  NEXT
  ENDIF
 
 END
 
 Regards
 
 Jesus
 

Not every control will have a .Tag property could be one of the problems.
Same can be for the .Enabled property
Also using Tag for other purpose could do something bad.
Best would be to print the object type and .ID property for the control under 
test
to see wich control has the problem.

Controls written in gambas could be suspected I think.
Basicly spoken the method used does not look strange to me
and I did long time ago something like this the same way.
I found also a problem and had the exclude a few object by type
checking. As far I remember I was also using the .Tag property.



Best regards,

Ron_1st

-- 
 A: Delete the text you reply on.
 Q: What to do to get my post on top?
---
 A: Because it messes up the order in which people normally read text. 
 Q: Why is top-posting such a bad thing? 
---
 A: Top-posting. 
 Q: What is the most annoying thing in e-mail? 
 

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Disable controls by Tag (Solved)

2009-05-28 Thread Jesus Guardon
Ron_1st escribió:
 On Thursday 28 May 2009, Jesus Guardon wrote:
 Hi all

 It seems a basic question, but I'm unable to get it to work.
 I need to enable/disable a group of mixed controls in the Main Form, but 
 instead of doing individually, I'd prefer to do so by iterating.

 Following is the code I'm using and it gives an error Wanted string, 
 date or integer, got function instead

 What I'm doing wrong?

 PUBLIC SUB btnQuick_Click() 'toggle button

  DIM hCtl AS Control

  IF btnQuick.Value = TRUE THEN
  FOR EACH hCtl IN FMain.Controls
  IF hCtl.Tag = exclude THEN hCtl.Enabled = FALSE
  'DEBUG hCtl.Tag
  NEXT
  ELSE
  FOR EACH hCtl IN FMain.Controls
  IF hCtl.Tag = exclude THEN hCtl.Enabled = TRUE
  NEXT
  ENDIF

 END

 Regards

 Jesus

 
 Not every control will have a .Tag property could be one of the problems.
 Same can be for the .Enabled property
 Also using Tag for other purpose could do something bad.
 Best would be to print the object type and .ID property for the control under 
 test
 to see wich control has the problem.
 
 Controls written in gambas could be suspected I think.
 Basicly spoken the method used does not look strange to me
 and I did long time ago something like this the same way.
 I found also a problem and had the exclude a few object by type
 checking. As far I remember I was also using the .Tag property.
 
 
 
 Best regards,
 
 Ron_1st
 
Thanks, Ron_1st

As you stated, checking the type of the controls is needed. Now, it 
works as expected.

PUBLIC SUB btnQuick_Click() 'toggle button

 DIM hCtl AS Control

 IF btnQuick.Value = TRUE THEN
 FOR EACH hCtl IN FMain.Controls
 IF hCtl IS TextBox OR hCtl IS ComboBox OR hCtl IS CheckBox 
OR hCtl IS ValueBox OR hCtl IS Button THEN
 IF hCtl.Tag = exclude THEN hCtl.Enabled = FALSE 

 'PRINT hCtl.Name, hCtl.Tag
 ENDIF
 NEXT
 ELSE
 FOR EACH hCtl IN FMain.Controls
 IF hCtl IS TextBox OR hCtl IS ComboBox OR hCtl IS CheckBox 
OR hCtl IS ValueBox OR hCtl IS Button THEN
 IF hCtl.Tag = exclude THEN hCtl.Enabled = TRUE 

 ENDIF
 NEXT
 ENDIF

END


Best regards
Jesus

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Disable controls by Tag

2009-05-28 Thread Jorge Carrión
¿Perhaps trying sonething like this?

PUBLIC SUB btnQuick_Click() 'toggle button

  DIM hCtl AS Control

  IF btnQuick.Value = TRUE THEN
  FOR EACH hCtl IN FMain.Controls
  TRY hCtl.Enabled = (hCtl.Tag  exclude)
  NEXT

it Is not very elegant but it works, I guess.
Regards
Jorge

2009/5/28 Ron_1st ron...@tiscali.nl

 On Thursday 28 May 2009, Jesus Guardon wrote:
  Hi all
 
  It seems a basic question, but I'm unable to get it to work.
  I need to enable/disable a group of mixed controls in the Main Form, but
  instead of doing individually, I'd prefer to do so by iterating.
 
  Following is the code I'm using and it gives an error Wanted string,
  date or integer, got function instead
 
  What I'm doing wrong?
 
  PUBLIC SUB btnQuick_Click() 'toggle button
 
   DIM hCtl AS Control
 
   IF btnQuick.Value = TRUE THEN
   FOR EACH hCtl IN FMain.Controls
   IF hCtl.Tag = exclude THEN hCtl.Enabled = FALSE
   'DEBUG hCtl.Tag
   NEXT
   ELSE
   FOR EACH hCtl IN FMain.Controls
   IF hCtl.Tag = exclude THEN hCtl.Enabled = TRUE
   NEXT
   ENDIF
 
  END
 
  Regards
 
  Jesus
 

 Not every control will have a .Tag property could be one of the problems.
 Same can be for the .Enabled property
 Also using Tag for other purpose could do something bad.
 Best would be to print the object type and .ID property for the control
 under test
 to see wich control has the problem.

 Controls written in gambas could be suspected I think.
 Basicly spoken the method used does not look strange to me
 and I did long time ago something like this the same way.
 I found also a problem and had the exclude a few object by type
 checking. As far I remember I was also using the .Tag property.



 Best regards,

 Ron_1st

 --
  A: Delete the text you reply on.
  Q: What to do to get my post on top?
 ---
  A: Because it messes up the order in which people normally read text.
  Q: Why is top-posting such a bad thing?
 ---
  A: Top-posting.
  Q: What is the most annoying thing in e-mail?



 --
 Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
 is a gathering of tech-side developers  brand creativity professionals.
 Meet
 the minds behind Google Creative Lab, Visual Complexity, Processing, 
 iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
 Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Disable controls by Tag

2009-05-28 Thread Ron_1st
On Thursday 28 May 2009, Jorge Carrión wrote:
 ¿Perhaps trying sonething like this?
 
 PUBLIC SUB btnQuick_Click() 'toggle button
 
   DIM hCtl AS Control
 
   IF btnQuick.Value = TRUE THEN
   FOR EACH hCtl IN FMain.Controls
   TRY hCtl.Enabled = (hCtl.Tag  exclude)
   NEXT
 
 it Is not very elegant but it works, I guess.
 Regards
 Jorge
 


I'n happy it works now at Jesus Guardon's box.

The TRY is also a nice way. You can try it to get more
speed in the loop and it gives a more nice text layout.

Against that way is you forget why you use the trick
and now it is good help to know a method to prevent
the error.
Any way if you start using the TRY method add a remark 
why it is used.



Best regards,

Ron_1st

-- 


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user