Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Oct 17, 2017 4:52 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: So I can't output a string's length to a string?
PostPosted: Fri May 17, 2013 4:14 am 
Offline

Joined: Sat Apr 20, 2013 7:41 pm
Posts: 37
if textfield1.text.len = 0 then
MsgBox "no string detected"
else
dim a as string = textfield1.text
msgbox "length: " + a.len

In just about any other language you can:

if string.length = 0 then
alert here
else
string1.text = string.length.tostring
end if.

_________________
Xojo Countdown:
http://timehacker11.com/apps/countdowns/xojo/


Top
 Profile  
Reply with quote  
 Post subject: Re: So I can't output a string's length to a string?
PostPosted: Fri May 17, 2013 4:28 am 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
if textfield1.text.len = 0 then
MsgBox "no string detected"
else
dim a as string = textfield1.text
msgbox "length: " + str(a.len) ' you need the str()
end if

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: So I can't output a string's length to a string?
PostPosted: Fri May 17, 2013 12:16 pm 
Offline

Joined: Sat Apr 20, 2013 7:41 pm
Posts: 37
shaosean wrote:
if textfield1.text.len = 0 then
MsgBox "no string detected"
else
dim a as string = textfield1.text
msgbox "length: " + str(a.len) ' you need the str()
end if


Thanks.

This is my major complaint about the language; it isn't Englishifide as much as VB.NET or other languages for that matter.

I only wish the Xojo language was a carbon copy of VB.NET, at least English wise.

_________________
Xojo Countdown:
http://timehacker11.com/apps/countdowns/xojo/


Top
 Profile  
Reply with quote  
 Post subject: Re: So I can't output a string's length to a string?
PostPosted: Fri May 17, 2013 1:42 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
I use xtalk languages a lot and am used to the more verbose English-like syntax ;-)

put the number of characters in the text of field "textfield1"

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: So I can't output a string's length to a string?
PostPosted: Fri May 17, 2013 1:50 pm 
Offline
Site Admin
User avatar

Joined: Fri Sep 30, 2005 9:35 am
Posts: 987
Location: South Portland, Maine
If you want to use ToString on an Integer variable, you can just create your own extension method to do so.

On a module, add this global method:
Function ToString(Extends i As Integer) As String
Return Str(i)
End Function


Then you can write code like this anywhere in your project:

Dim i As Integer = 42
MsgBox(i.ToString)

_________________
Paul Lefebvre
Developer Evangelist
Xojo, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: So I can't output a string's length to a string?
PostPosted: Fri May 17, 2013 5:03 pm 
Offline

Joined: Wed Mar 22, 2006 11:15 am
Posts: 712
Location: Southern California
Personally I despise the "English like" syntax of languages like xtalk or AppleScript. Computers are not to the point of being able to understand the infinite variations humans use to construct the same message. "Natural language" systems usually end up being more demanding in terms of syntax because it's not clear, at a glance, which combinations will work and which will not or why. On top of that they are needlessly verbose.

The .NET languages are not "Englishified" in this manner. But they do automatically coerce types when and where they can. I have mixed feelings about this because in theory a strict language like RB catches more errors at compile time. And I can think of examples where automatic type coercion could lead to very subtle and painful bugs. But in practice I find that I prefer the language to do this work for me where it can, and I haven't run into those painful bugs (yet).

Types involve more work in RB. On the flip side, the .NET framework is often excessively complex and deep, with too many nested objects and long .Method call chains. The RB framework is nice and compact in comparison.

_________________
Daniel L. Taylor
Custom Controls for Real Studio WE!
Visit: http://www.webcustomcontrols.com/


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