Hi everyone,

I wrote this a long time ago and am wondering if it might be of any use to anyone.

Mind you, because it was written well before CodeJock came along, it's use may not be as great as it use to be.

Code:
//
//Function: Compare_Form_Values
//Purpose:  Compares two values irrespective of whether they are string, date or numeric
//           and returns true for failed to compare and false for ok. The function
//           assumes that the first value MUST be less than or equal to the second value.
//Usage:    Get Compare_Form_Values Integer iObj_1(object_id) Integer iObj_2(object_id) ;
//              Returns Integer
//
Function Compare_Form_Values Integer Obj1 Integer Obj2 Returns Integer
    Integer iData_Type iRetval
    Integer iTmp1 iTmp2
    //
    //Initialise variable.
    //
    Move 1 to iRetval
    //
    //ASSUMPTION: Whatever data type Obj1 is then Obj2 will be the same. If it's not
    //  then this function should not even be used, but we test to make sure they are
    //  the same type anyway.
    // Mask_Window          = 16384
    // Mask_Numeric_Window  = 32768
    // Mask_Date_Window     =  4096
    // Mask_Currency_Window =  2048
    // Ascii_Window         =   255
    // Date_Window          =   128
    //
    Get Form_Datatype of Obj1 to iTmp1
    Get Form_Datatype of Obj2 to iTmp2

    Get Form_DataType of Obj1 to iData_Type
    //
    //Compare the data types - if they are not the same then declare an error.
    If (iTmp1 <> iTmp2) Begin
        Send Stop_Box "Compare_Form_Values function: Data type of both forms must be the same."
    End
    Else If not ("128255204840961638432768" contains String(iData_Type) ) Begin
        Send Stop_Box "Compare_Form_Values function: Unknown data type used for window.\nComparison of values not possible."
    End
    //
    //Has the function received the correct values and number of parameters.
    //
    Else If (not(Obj1)) Begin
        Send Stop_Box "Compare_Form_Values function: Object one has no value.\nComparison of values not possible."
    End
    Else If (not(Obj2)) Begin
        Send Stop_Box "Compare_Form_Values function: Object two has no value.\nComparison of values not possible."
    End
    //
    //ASSUMPTION: When objects are created Obj1 should have an id less than Obj2.
    //
    Else If (not(Obj1 < Obj2)) Begin
        Send Stop_Box "Compare_Form_Values function: Object one has a higher object id than object two.\nComparison of values not possible."
    End
    //
    //If we have got to here we can start using the function for its intended purpose.
    //
    Else Begin
        Case Begin
            Case (  iData_Type =  255                        and Value(Obj1, 0)         > Value(Obj2, 0) ) Case Break
            Case ( (iData_Type =  128 or iData_Type =  4096) and Date(Value(Obj1, 0))   > Date(Value(Obj2, 0)) ) Case Break
            Case ( (iData_Type = 2048 or iData_Type = 32768) and Number(Value(Obj1, 0)) > Number(Value(Obj2, 0)) ) Case Break
            Case Else Move 0 to iRetval
        Case End
    End
    //
    //Once here everything must be ok or in error.
    //
    If iRetval Send Stop_Box "Start value is greater than Stop value."
    Function_Return iRetval
    //
End_Function
//