New topic: 

basic question ref variables and textfields

<http://forums.realsoftware.com/viewtopic.php?t=38398>

         Page 1 of 1
   [ 8 posts ]                 Previous topic | Next topic          Author  
Message        achundee          Post subject: basic question ref variables and 
textfieldsPosted: Wed Mar 30, 2011 8:16 am                         
Joined: Wed Mar 30, 2011 7:57 am
Posts: 4                Hi all,

I have a very nooby question if you don't mind please:

I have created a texfield into which I am expecting a number to be typed in.  I 
know that to read the contents into a variable I can use the code myvariable = 
val(textfield.text).

I know to use "val" as I have seen an example, but I don't understand what type 
of command "val" is in this case and why I should use it.  So now I am trying 
something different, I don't know what to do.

The bit where i get stuck is that I want a label to show the contents of 
"myvariable"

If I use label.txt = myvariable I get a type mismatch.  Looks like I need to 
use something like "val" with myvariable, but I don't know what to use?

Can anyone help please, and if the answer is in some documentation somewhere, 
can you tell me where I should be looking?  I have tried the realbasic 
variables tutorial but it doesn't say anything about types, and using them in 
the way I want to.

Thanks in advance!   
                             Top                 DaveS          Post subject: 
Re: basic question ref variables and textfieldsPosted: Wed Mar 30, 2011 8:42 am 
                                
Joined: Sun Aug 05, 2007 10:46 am
Posts: 2888
Location: San Diego, CA                VAL is an intrinsic function (ie.. Built 
in to Real Studio)

Its purpose is to convert a STRING type variable to a NUMERIC type variable 
(integer or double)

There is another intrinsic function (one of a few) called STR that does the 
exact opposite... converts a NUMERIC type variable to a STRING variable

Code:dim mynumeric as integer
dim mystring as string
mynumeric=val("1234") // "1234" is a string because it is in quotes
mystring=str(mynumeric)


A "type mismatch" error means you are attempting to assign a STRING value to a 
NUMERIC variable or vice-versa

label1.text=mynumeric is a "type mismatch"..   label1.text is a STRING, but 
mynumeric is NOT

label1.text=str(mynumeric) does work      
_________________
Dave Sisemore
MacPro, OSX 10.6.4 RB2009r5.1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                achundee          Post subject: 
Re: basic question ref variables and textfieldsPosted: Wed Mar 30, 2011 9:03 am 
                        
Joined: Wed Mar 30, 2011 7:57 am
Posts: 4                Thank you so much for a comprehensive answer!  Was that 
something mega-obvious that I missed in some documentation somewhere?   
                             Top                 mjh          Post subject: Re: 
basic question ref variables and textfieldsPosted: Wed Mar 30, 2011 9:03 am     
                            
Joined: Sun Feb 19, 2006 3:10 pm
Posts: 1175
Location: Hamburg, Germany                achundee wrote:I know to use "val" as 
I have seen an example, but I don't understand what type of command "val" is in 
this case and why I should use it.
Answering this kind of question is what the built-in Language Reference is for. 
For example, see http://docs.realsoftware.com/index.php/Val. If you read the 
documentation you will also realize why you should use CDbl instead of Val in 
this case.      
_________________
Michael J. Hußmann 
http://digicam-experts.de  
                             Top                DaveS          Post subject: 
Re: basic question ref variables and textfieldsPosted: Wed Mar 30, 2011 9:09 am 
                                
Joined: Sun Aug 05, 2007 10:46 am
Posts: 2888
Location: San Diego, CA                achundee wrote:Thank you so much for a 
comprehensive answer!  Was that something mega-obvious that I missed in some 
documentation somewhere?

Very much so...... it is something you missed....      
_________________
Dave Sisemore
MacPro, OSX 10.6.4 RB2009r5.1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                achundee          Post subject: 
Re: basic question ref variables and textfieldsPosted: Wed Mar 30, 2011 9:15 am 
                        
Joined: Wed Mar 30, 2011 7:57 am
Posts: 4                DaveS wrote:achundee wrote:Thank you so much for a 
comprehensive answer!  Was that something mega-obvious that I missed in some 
documentation somewhere?

Very much so...... it is something you missed....

ok thanks for letting me know.  I am using a trial at the moment - would I have 
found the answer in the documentation that comes with the trial (or online), or 
is the full documentation bundled with the full version of the software?

Thanks!   
                             Top                 mjh          Post subject: Re: 
basic question ref variables and textfieldsPosted: Wed Mar 30, 2011 9:25 am     
                            
Joined: Sun Feb 19, 2006 3:10 pm
Posts: 1175
Location: Hamburg, Germany                achundee wrote:I am using a trial at 
the moment - would I have found the answer in the documentation that comes with 
the trial (or online)
Yep, you would have. The trial version is the full version minus a license.     
 
_________________
Michael J. Hußmann 
http://digicam-experts.de  
                             Top                achundee          Post subject: 
Re: basic question ref variables and textfieldsPosted: Wed Mar 30, 2011 9:35 am 
                        
Joined: Wed Mar 30, 2011 7:57 am
Posts: 4                Aah - sorry I see where I should have been looking now 
- sorry to waste everyone's time!   
                             Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 8 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to