18. September 2023 16:30
recTextModuleLineDocument.INIT;
recTextModuleLineDocument."Line No." := 10000;
recTextModuleLineDocument.Text := 'TEST neuer Eintrag';
recTextModuleLineDocument."Print Mgt. Code" := 'S_ORDCONF';
recTextModuleLineDocument."Creation Date" := TODAY;
recTextModuleLineDocument."Created by" := USERID;
recTextModuleLineDocument."Text ID" := Rec."Text Set ID";
IF recTextModuleLineDocument.INSERT(TRUE) THEN BEGIN
dummy := recTextModuleLineDocument.GetTextSetID(recTextModuleLineDocument);
END;
GetTextSetID(VAR TextSet : Record "Text Module Line Document") TextID : Integer
// Search if there is already an ID with the same text as the TestSet from parameter.
// If yes, then give back the found Text ID
// If nothing found, create a new ID and give back.
IF TextSet.ISEMPTY THEN BEGIN
TextID := 0;
EXIT;
END;
// Search for already existing identical text.
Found := FALSE;
CurrHashValue := TMEngine.CalcHashValue(TextSet);
....
....
[b]CalcHashValue(VAR TempTextSet : TEMPORARY Record "Text Module Line Document") HashValue : Integer[/b]
// >> #TMW17.10.01:T100
// ATTENTION: If more fields get added here to calculate the hash code, pay attention to two issues:
// 1: The Hash Values of all existing text must be recalculated. Otherwise most text will be doubled
// 2: When a new field get added here, it must be also added at the function CompareText
MaxM := 2097133; // big prim to calculate hash filter
Base := 1024; // number of expected used different characters
HashValue := 0;
IF NOT TempTextSet.FINDSET THEN
EXIT;
REPEAT
CurrStringLength := STRLEN(TempTextSet.Text);
FOR Position := 1 TO CurrStringLength DO BEGIN
HashValue := (HashValue * Base + TempTextSet.Text[Position]) MOD MaxM;
END;
CurrStringLength := STRLEN(TempTextSet."Print Mgt. Code");
FOR Position := 1 TO CurrStringLength DO BEGIN
HashValue := (HashValue * Base + TempTextSet."Print Mgt. Code"[Position]) MOD MaxM;
END;
// >> CCFD,CCFTE
CurrStringLength := STRLEN(TempTextSet."FD SHA-256");
FOR Position := 1 TO CurrStringLength DO BEGIN
HashValue := (HashValue * Base + TempTextSet."FD SHA-256"[Position]) MOD MaxM;
END;
// << CCFD,CCFTE
IF TempTextSet.Italic THEN
HashValue := (HashValue * Base + TempTextSet.FIELDNO(Italic)) MOD MaxM;
IF TempTextSet.Bold THEN
HashValue := (HashValue * Base + TempTextSet.FIELDNO(Bold)) MOD MaxM;
IF TempTextSet.Underline THEN
HashValue := (HashValue * Base + TempTextSet.FIELDNO(Underline)) MOD MaxM;
HashValue := (HashValue * Base + TempTextSet.Color) MOD MaxM;
UNTIL TempTextSet.NEXT = 0
18. September 2023 20:24
19. September 2023 07:58
IF recTextModuleLineDocument.INSERT(TRUE) THEN BEGIN
recTextModuleLineDocument.SETRECFILTER(); // Neu
dummy := recTextModuleLineDocument.GetTextSetID(recTextModuleLineDocument);
END;
19. September 2023 09:16