&RX "AS" LU "$0""$1""$2""$3""$4""$5""MATCH""IN""" #LUG .
#IF (!0<4)
#IFCLASS !3 "G"
#CHECK !4 "" // INDICATE IND1 AS IND2
#CHECK !3 _SNDI#LO
!A [] $4020 !3 |GB[0] !1 |3
#ELSE
// If here we've got either a single variable if
// If Var .... <or>
// If (Var)
//
// Not all data types are supported in this format and the compiler will create an error if
// you pick the wrong one.
//
// Those Allowed are: Real, Number, Date, String, Integer, Boolean, Short, UShort, Char, UChar, Address
//
// Those not Allowed are: Float, Decimal, Currency, Time, DateTime, TimeSpan, Variant, BigInt, UBigInt, UInteger
//
// This was changed for 8.3. Prior to 8.3 types which were not supported (e.g. float) compiled but did not work.
// Now you get an error message at compile time. Also, address types which did not work now are allowed and work properly.
//
// Struct and arrays can only be used if they are members (e.g. not MyIntArray, but MyIntArray[1]; not MyStruct, but MyStruct.bMem)
// and if the member is within an expression (e.g. not MyIntArray[1], but (MyIntArray[1]) ).
// In addition you cannot use deprecated "If X[1] EQ Y[1]" syntax with structs and arrays. You must use expressions "if (x[1]=y[1])"
// INDICATE IND AS X
#CHECK !3 _U
// compare real 0 against real
#IFTYPE !3 "R"
!A [] IN$5 !3 |CR0 !1 |3
#ELSE
// compar number 0 for date and number
#IFTYPE !3 "ND"
!A [] IN$5 !3 |CN0 !1 |1
#ELSE
// compare integer 0 for integer, Long(?), Boolean, UBigint, UInteger, UShort, BigInt, Short, Char, UChar, Address
// prior to 8.3 this was "ILZOQGVUWCYH". In 8.3 we removed currency (O) and decimal (Q), BigInt (H), UBigInt (G), UInteger (V), added address (X)
#IFTYPE !3 "ILZUWCYX"
!A [] IN$5 !3 |CI0 !1 |2
#ELSE
// compare string "" against string
#IFTYPE !3 "S"
!A [] IN$5 !3 |CS"" !1 |0
#ELSE
// if type is a struct or array, we cannot use this. One of two types of errors
#IFTYPE !3 "KA"
#IFCLASS !3 "E"
// if within an expression, it must be returning the entire struct or array which cannot be evaludated
#ERROR DFERR_COMP_INVALID_TYPE "The expression returns a struct or array. This cannot used for logical evaluation."
#ELSE
// if not an expression. This could be a non-member which is never allowed.
// or it might be a member which requires parenthesis. eg: "if Var.bMem" should be "if (Var.bMem)"
#ERROR DFERR_COMP_INVALID_TYPE "Structs and Arrays must be members and can only be evaluated within an expression. Use (bVars[x]) or (Var.bMem)"
#ENDIF
#ELSE
// types of BigInt, UBingInt, UInteger, time, timedate, float, currency, decimal, variant and timespan cannot be used directly in expression or as variables.
// They can be used inside of a boolean expression. So you can not do "If fFloatVar" or "If (fFloatVar)" but you can do
// "If (fFloatVar<>0)" instead. We don't support variant types because at compile time we just don't know what kind of data they
// will contain.
#IFTYPE !3 "TMFOPQJHGV"
#ERROR DFERR_COMP_INVALID_TYPE "The variable data-type is not valid for logical evaluation. Use (var<>0)"
#ELSE
#CHECK !3 _O
!A [] $4020 !3 |GB[0] !1 IN$GLALL |3
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ELSE
#CHECK !5 _R
#IFSAME !4 MATCH
!A [] $4031 !3 !5 !1 !6
#ELSE
#IFSAME !4 IN
!A [] $4030 !3 !5 !1 !6
#ELSE
#CHECK !3 _U
// If here we've got either a old style if statement
// If Var NE Xxxx <or>
// If Var EQ Var
//
// First of all note that this is a deprecated style and not all of the newer types are supported. If we
// find an invalid type in either side of the comparison, we will generate a compiler error
//
// Those Allowed are: Real, Number, Date, String, Integer, Boolean, Short, UShort, Char, UChar, Address
//
// Those not Allowed are: Float, Decimal, Currency, Time, DateTime, TimeSpan, Variant, BigInt, UBigInt, UInteger
// Struct or Arrays (even members of a valid data-type)
//
// This was changed for 8.3 and this may generate new compiler errors. That's good as it is catching errors.
// note that the order of these are important.
#IF2TYPE !3 !5 "TMFOPQJHGVAK" // bad guys are: time, datetime, timespan, float, currency, decimal, variant, BigInt, UBigInit, UInteger, Struct, Array
#ERROR DFERR_COMP_INVALID_TYPE "One or both comparision variable datatypes are not valid for logical evaluation. Use (var<>xx)"
#ELSE
#IF2TYPE !3 !5 "R" // real
!A [] IN!4 !3 !5 !1 !6 |3
#ELSE
#IF2TYPE !3 !5 "ND" // number, date
#IF2TYPE !3 !5 "X" // cannot compare address to number/date.
#ERROR DFERR_COMP_INVALID_TYPE "You cannot compare an address to a number or a date"
#ELSE
!A [] IN!4 !3 !5 !1 !6 |1
#ENDIF
#ELSE
// #IF2TYPE !3 !5 "IL" // pre-8.3 it was this (we let just about everything act as string, which did not work)
#IF2TYPE !3 !5 "ILZUWCYX" // integer, (long), boolean, Short, uShort, Char, UChar, Address
!A [] IN!4 !3 !5 !1 !6 |2
#ELSE
!A [] IN!4 !3 !5 !1 !6 |0 // if nothing else, string
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDIF