Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Jul 21, 2017 9:36 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: "With" or "Using" Statement?
PostPosted: Tue Jul 17, 2012 9:50 am 
Offline

Joined: Sun Jul 01, 2012 5:40 pm
Posts: 16
In VB, instead of typing:
MyControl.Left = 0
MyControl.Top = 100
MyControl. Etc

You can type:
With MyControl
.Left = 0
.Top = 100
.Etc
End With

Other languages have the "Using" key word for the same purpose.
Does Real Studio have anything like this?
Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: "With" or "Using" Statement?
PostPosted: Tue Jul 17, 2012 10:52 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
Not unless it made it into a very recent update and I missed it.

Personally, Im not a fan.
Although this saves a little typing, in the middle of a dense code block it is less than clear which object .left refers to.

If typing is an issue I prefer to create a local alias to the object.

So:

Dim c as control

c = MyControlWithAVeryLongName //almost the same as 'using MyControlWithAVeryLongName'
c.left = 100
c.top = 200
c.etc


The assignment of c to the control name takes one more character.
Each reference using c.left instead of .left uses one extra character
And there is no end with, saving 8 characters.


And the other beaty of this approach is that you can have 2 controls on the go at the same time without confusion


c = MyControlWithAVeryLongName
d = MyOtherControlWithAVeryLongName

c.left = 100
c.top = 200
d.left = c.left



.. you cant have two controls being 'used' in the same block of code as .left would be ambiguous.


Top
 Profile  
Reply with quote  
 Post subject: Re: "With" or "Using" Statement?
PostPosted: Tue Jul 17, 2012 11:00 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:48 am
Posts: 3554
Location: Lenexa, KS
No, Real Studio does not have With or Using. I missed it for about 3 months when I switched from VB6 but not much since then.

I too use a local alias if I am using an long name object a lot. Autocomplete is also generally good enough for me needs.

_________________
Bob K.

A blog about being a Real Studio/Xojo developer at http://www.bkeeneybriefs.com


Top
 Profile  
Reply with quote  
 Post subject: Re: "With" or "Using" Statement?
PostPosted: Tue Jul 17, 2012 4:33 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
"USING" I can do without.... but for me... the addition of "WITH" would be the iceing on the cake...... would make the code SO MUCH cleaner.... but that my opinion.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: "With" or "Using" Statement?
PostPosted: Thu Aug 16, 2012 3:22 pm 
Offline

Joined: Fri May 08, 2009 1:42 am
Posts: 71
I used to be in the "where's With statement" camp, but while the code may be cleaner looking, it is harder to read in bigger VB procedures that have the With and End With separateed by a lot of lines. Just my 2 cents as a long time VB6 programmer.


Top
 Profile  
Reply with quote  
 Post subject: Re: "With" or "Using" Statement?
PostPosted: Thu Aug 16, 2012 4:58 pm 
Offline

Joined: Thu Dec 16, 2010 1:22 pm
Posts: 188
Quote:
The assignment of c to the control name takes one more character.
Each reference using c.left instead of .left uses one extra character
And there is no end with, saving 8 characters.


LOL We had this exact same discussion almost a year ago to the day!!
http://forums.realsoftware.com/viewtopic.php?f=13&t=39881&p=222218&hilit=overhead#p222218

July 16, 2011 -> July 17, 2012!!!

and at the time I made the same point that you actually SAVE keystrokes in RS (you said 8, I said 10, I'll have to go back and count).

History really DOES repeat itself!! :lol: :lol:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group