//TH-Header //***************************************************************************************** // Copyright (c) 2001 Michael Kurz // All rights reserved. // If you want to use this source in your applications conatct: // // $FileName : D:\Entwicklung\Codemax\mEditorMacros.pkg // $ProjectName : Codemax // $Author : Michael Kurz // $Created : 17.05.2001 10:41 // // Contents: // Loading and saving Macros to Editor.Dat. // //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd Use vWin32fh.pkg Use cWorkSpaceHandlerEx.pkg Open Editor // // Returns the defined field length for the Editor.type column. // We need to know this length in order to create unique IDs in the editor table // and shortening workspacenames that don't fit in the table. // The default length is 20 characters which can cause issues with multiple workspaces // matching the same ID. // By making this dynamic you can now change your table definition if you // use long workspacenames that have their uniqueness at the end of the // workspacename. // Function EditorTableTypeColumnLength Returns Integer Integer hFile Integer iField Integer iLength Move Editor.File_Number To hFile Field_Map hFile "Type" To iField Get_Attribute DF_FIELD_LENGTH Of hFile iField To iLength Function_Return iLength End_Function // EditorTableTypeColumnLength Function EditorWorkspaceID global Returns String Integer iLength Number nVdfVersion String sWrkSpace Get EditorTableTypeColumnLength To iLength Get psCurWrkSpace Of ghoWorkSpaceHandlerEx To sWrkSpace Get fnCurrentVdfVersion Of ghoWorkSpaceHandlerEx To nVdfVersion If (nVdfVersion>=120) Begin // VDF versions over 12 have the path in their workspace name, remove it Get ParseFileName sWrkSpace To sWrkSpace End Move (Left(sWrkSpace,(iLength-8))) To sWrkSpace Function_Return sWrkSpace End_Function // EditorWorkspaceID Function EditorWorkspaceToolID global Returns String Integer iRec hoID iC Integer iLength Number nVdfVersion String sWrkSpace String sVal Get EditorTableTypeColumnLength To iLength Get psCurWrkSpace Of ghoWorkSpaceHandlerEx To sWrkSpace Get fnCurrentVdfVersion Of ghoWorkSpaceHandlerEx To nVdfVersion If (nVdfVersion>=120) Begin // VDF versions over 12 have the path in their workspace name, remove it Get ParseFileName sWrkSpace To sWrkSpace End Move (Left(sWrkSpace,(iLength-3))) To sWrkSpace // "FFS" is 3 characters long Function_Return sWrkSpace End_Function // EditorWorkspaceToolID // Deletes all Entries in Editor.Dat from a specific user an typ. Procedure Editor_DeleteAll String sUser String sTyp Clear Editor Move sUser To Editor.User Move sTyp To Editor.Type Repeat Find Gt Editor by Index.1 If Editor.User Ne sUser Indicate found False If Editor.Type Ne sTyp Indicate found False [found] Begin Lock Delete Editor Unlock End Until [Not found] End_Procedure // Saves one Macro to the editor DataBase. Procedure Editor_SaveMacro String sUser Integer iMacro Integer iSize Move (CMGetMacro(iMacro,0)) To iSize If iSize Eq 0 Procedure_Return Local_Buffer sBuff pBuff iSize Move (CMGetMacro(iMacro,pBuff)) To iSize Clear Editor Move sUser To Editor.User Move "MACRO" To Editor.Type Move iMacro To Editor.File Lock Find Eq Editor by Index.1 Move iSize To Editor.Count Move sBuff To Editor.Data Saverecord Editor Unlock End_Procedure // SAves all 10 possible macros with CodeMax. Procedure Editor_SaveAllMacros String sUser Integer iC Send Editor_DeleteAll sUser "MACRO" // Delete all old macros. For iC From 0 To 9 Send Editor_SaveMacro sUser iC End End_Procedure Procedure FloatDeleteAllMacros // Send Editor_DeleteAll gsBenutzerName "MACRO" End_Procedure // FloatDeleteAllMacros // Saves one Macro to the editor DataBase. Procedure Editor_LoadMacro String sUser Integer iMacro Integer iRet Local_Buffer sBuff pBuff Clear Editor Move sUser To Editor.User Move "MACRO" To Editor.Type Move iMacro To Editor.File Find Eq Editor by Index.1 [found] Begin Move (Left(Editor.Data,Editor.Count)) To sBuff GetAddress Of sBuff To pBuff Move (CMSetMacro(iMacro,pBuff)) To iRet End End_Procedure // Tries to load all 10 Macros possible in Codemax. Procedure Editor_LoadAllMacros String sUser Integer iC For iC From 0 To 9 Send Editor_LoadMacro sUser iC End End_Procedure