Type Conversion
BlitzMax Forums/BlitzMax Beginners Area/Type Conversion
| ||
In BlitzPlus, I can do implicit type conversion like this:Global current_year=Right$(CurrentDate$(),4) which, I suppose, is equivalent to: current_year=val(Right$(CurrentDate$(),4)) in older basic dialects. What do I do in Max, and are there other rules for similar type conversions - I am trying to convert a large Blitzplus application to Max, and it is hard work! |
| ||
Global current_year:String = Right$(CurrentDate$() , 4)no...really it is. <edit> or Global current_year:Int = Int(Right$(CurrentDate$() , 4)) |
| ||
Thank you, Tony, that helps enormously. I should know all this, but haven't been using MAX for over a year. The second one is what I was after. |
| ||
np <edit> start again... It's advisable to define every variable/object so run with SuperStrict defined. |
| ||
Or more generallyGlobal myString:String = CurrentDate$() Global current_year:Int = myString[myString.Length-4..].toInt()or since you know that CurrentDate is always going to be a certain size: Global current_year:Int = CurrentDate$()[7..].toInt() |