New Methods for Basic data types
Scope
Objects: All
Languages: All
DBMS: All
Introduction
New methods have been added to the basic data types.
Description
With the objective of coding in a more developer friendly way; new methods have been added to the basic data types (Numeric, Character, Varchar, LongVarchar, Date and Datetime ); so now it's easier to interact with the data types functions. Using the method notation (<attribute>.<method>) instead of the function one (<function>(<attribute>) the GeneXus Developer automatically gets the benefits of the tooltips in the Development Environment.
Syntax
<attribute> = <attribute>.<method>
Numeric Data types
New Method |
Available Function |
Integer |
Int |
Round |
Round |
|
|
Truncate |
Trunc |
Character, Varchar and LongVarchar Data types
New Method |
Available Function |
IndexOf |
StrSearch |
LastIndexOf |
StrSearchRev |
Length |
Len |
PadLeft |
PadL |
PadRight |
PadR |
Replace |
StrReplace |
Substring |
Substr |
ToLower |
Lower |
ToNumeric |
Val |
ToUpper |
Upper |
Trim |
Trim |
TrimEnd |
Rtrim |
TrimStart |
Ltrim |
Date and Datetime types
New Method |
Available Function |
Comment |
AddMonths |
AddMth |
|
AddYears |
AddYr |
|
Age |
Age |
|
Day |
Day |
|
DayOfWeek |
DOW |
|
EndOfMonth |
EOM |
|
Month |
Month |
|
Year |
Year |
|
Set |
YMDToD |
only date data type |
Hour |
Hour |
only datetime data type |
Minute |
Minute |
only datetime data type |
Second |
Second |
only datetime data type |
Set |
YMDHMSToT |
only datetime data type |
Considerations
The definition applies to attributes and variables.
Examples
// Old Code using Functions
&var1 = Val(Attribute)
&var2 = Round(Attribute, 0)
&var3 = trim(Attribute)
&var4 = upper(Attribute)
&var5 = Hour(Attribute)
&var6 = Age(Attribute, Attribute2)
&var7 = Ymdhmstot(2002,12,5,10,45,12)
// New Code using Data type methods
&var1 = Attribute.ToNumeric()
&var2 = Attribute.Round(0)
&var3 = Attribute.Trim()
&var4 = Attribute.ToUpper()
&var5 = Attribute.Hour()
&var6 = Attribute.Age(Attribute2)
&var7.Set(2002,12,5,10,45,12)
Related Information
Check the following Methods added to GeneXus 9.0
New Methods
RoundToEven Function and Method