Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


automatic typecasting of variables?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2008, 06:54 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default automatic typecasting of variables?

Hi,

I want to know whether Basic4ppc automatically typecasts variables. I know it does in certain cases.
The specific question I have is that I want to use a counter that counts up to 133784560. Does it change type when passing the integermaximum or do you have to typecast it from the start. If yes how do you typecast a variable at start?
Marc
Reply With Quote
  #2 (permalink)  
Old 02-04-2008, 09:32 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

B4PPC is a weakly typed language and normal (non-array) variables are not really typed at all. They are saved as strings and all numeric calculations are done by converting them to and from floating point doubles. Booleans are actually strings with the values "true" and "false".

Arrays ARE typed but ONLY IF you declare them as such, otherwise they are like non-array variables. Calculations done using typed arrays can be somewhat faster than with ordinary variables or arrays as, while they are still converted to and from doubles for calculation, this is a faster process than string conversion.

A note about libraries for completeness, their existence being the reason that B4PPC needs to know about types. B4PPC knows about certain types, such as Color, Boolean, Int16 etc, and converts its' non-array variables to and from these types when a library requires it. Arrrays, to save processing time, are not converted when passed to a library and so must be declared within B4PPC to be whatever type a library requires.
Reply With Quote
  #3 (permalink)  
Old 02-04-2008, 09:54 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

Agraham thanks,

But what about ordinary variables? The counter I use starts of as an integer (4 bytes) and moves up to 133784560 (Int64).
Reply With Quote
  #4 (permalink)  
Old 02-04-2008, 12:19 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by Stellaferox View Post
The counter I use starts of as an integer (4 bytes) and moves up to 133784560 (Int64).
What makes you think that? If it is a normal non-array B4PPC variable it is effectively a string as I've said above.
Reply With Quote
  #5 (permalink)  
Old 02-04-2008, 01:17 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

Ahh, I see your point now. OK, that is clear. No worries then to start the procedure....
Thnx
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Adjustable Label Width ceaser Questions & Help Needed 2 07-29-2008 03:54 PM
Environment Variables Zenerdiode Questions & Help Needed 1 05-22-2008 04:36 PM
B4PPC automatic loads net2 ? Put Claude Questions & Help Needed 4 11-28-2007 05:44 PM
Dim-ing variables colin9876 Questions & Help Needed 8 11-17-2007 06:47 PM
Structure variables Erel Code Samples & Tips 0 05-19-2007 11:36 AM


All times are GMT. The time now is 03:47 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0