// Use Conv2000.utl // Make date fields y2000 //Use DfAllent Use Base.nui // Item_Property command, Various macros (FOR_EX...), cArray, cSet and cStack classes Use DBMS.utl // Basic DBMS functions Use Spec0008.utl // Small arrays with integer Codes (Dictionaries) Use OpenStat.nui // cTablesOpenStatus class (formely cFileAllFiles) Use SetTable.utl // cSetOfTables class Use Files.utl // Utilities for handling file related stuff Use Fdx_Attr.nui // FDX compatible attribute functions desktop_section object oConv2000StatusCodes is a cIntegerCodeToText IntegerCodeList Define_IntegerCode Y2K_UNINITIALISED "Not checked" Define_IntegerCode Y2K_COULD_NOT_OPEN "Could not open" Define_IntegerCode Y2K_CONVERTED "Converted" Define_IntegerCode Y2K_NO_DATE_FIELDS "No date fields" End_IntegerCodeList end_object end_desktop_section function Y2K_TableStatusText global integer iStatus returns string function_return (sText.i(oConv2000StatusCodes(self),iStatus)) end_function class cConv2000 is a cSetOfTables procedure construct_object forward send construct_object // 0: One transaction //-1: exclusive //-2: means reread when necessary property integer piUnlockRecordCount public -2 property integer piCallbackObj public self object oDateFields is a cArray no_image end_object object oDateFieldValues is a cArray no_image end_object end_procedure // Find all fields of type DF_DATE and store them in the oDateFields array. procedure priv.DoFindDateFields local integer hoDateFields iField iMax iType move (oDateFields(self)) to hoDateFields send delete_data to hoDateFields move (FDX_AttrValue_FILE(0,DF_FILE_NUMBER_FIELDS,20)) to iMax for iField from 1 to iMax move (FDX_AttrValue_FIELD(0,DF_FIELD_TYPE,20,iField)) to iType if iType eq DF_DATE set value of hoDateFields item (item_count(hoDateFields)) to iField loop end_procedure function iCancel returns integer end_function procedure UpdateWait1 string sStr end_procedure procedure UpdateWait2 string sStr end_procedure procedure priv.DoConvRow integer iRow local integer iOpen iFile iUnlockCount iNeedsConverting local integer hoDateFields iField iMax iItm iFound hoDateFieldValues local integer iDate iDateConvCount iRecordUpdateCount iRecordCount local integer iRecCount iMaxRec iLockReccount local integer iCallbackObj iMaxRecord lbDate4State local string sRootName GET_DATE_ATTRIBUTE Date4_State to lbDate4State SET_DATE_ATTRIBUTE Date4_State to DFFALSE move (oDateFields(self)) to hoDateFields move (oDateFieldValues(self)) to hoDateFieldValues get psRootName.i iRow to sRootName get piCallbackObj to iCallbackObj move 20 to iFile move 0 to iRecordCount move 0 to iDateConvCount move 0 to iRecordUpdateCount get piUnlockRecordCount to iUnlockCount if iUnlockCount eq -1 move (DBMS_OpenFileAs(sRootName,iFile,DF_EXCLUSIVE,0)) to iOpen else move (DBMS_OpenFileAs(sRootName,iFile,DF_SHARE,0)) to iOpen if iOpen ne DBMS_DRIVER_ERROR begin get FDX_AttrValue_FILE 0 DF_FILE_RECORDS_USED iFile to iMaxRec send priv.DoFindDateFields get item_count of hoDateFields to iMax if iMax begin // If there's any date fields at all send UpdateWait1 to iCallbackObj sRootName decrement iMax if iUnlockCount le 0 begin clear 20 if (iUnlockCount=0 or iUnlockCount=-1) lock // 'One transaction' or 'exclusive' repeat vfind 20 0 gt move (found) to iFound if iFound move (not(iCancel(self))) to iFound if iFound begin // Sample values move 0 to iNeedsConverting for iItm from 0 to iMax get value of hoDateFields item iItm to iField get_field_value iFile iField to iDate if (iDate and iDate