Subversion Repositories oidplus

Compare Revisions

No changes between revisions

Regard whitespace Rev 739 → Rev 740

/trunk_dos/OIDFILE.PAS
67,15 → 67,17
CreateOidDef(oid);
end;
 
procedure BubbleSortSubIds(oid: POid);
procedure ListBubbleSortSubIds(oid: POid);
var
n, i: integer;
a, b: string;
swapped: boolean;
begin
n := ListCount(oid^.SubIds);
while n>1 do
begin
i := 0;
swapped := false;
while i<n-1 do
begin
a := DotNotationPart(ListGetElement(oid^.SubIds, i));
83,9 → 85,11
if CompareOID(a, b) > 0 then
begin
ListSwapElement(oid^.SubIds, i, i+1);
swapped := true;
end;
Inc(i);
end;
if not swapped then break;
Dec(n);
end;
end;
108,7 → 112,8
WriteLn(f,'SUPR' + oid^.Parent);
 
(* Sort sub IDs *)
BubbleSortSubIds(oid);
ListBubbleSortSubIds(oid);
 
for i := 0 to ListCount(oid^.SubIds)-1 do
begin
sTmp := ListGetElement(oid^.SubIds, i);
188,7 → 193,7
end;
(* Sort sub IDs *)
BubbleSortSubIds(oid);
ListBubbleSortSubIds(oid);
 
(* Remove last CRLF *)
oid^.Description := Copy(oid^.Description, 1, Length(oid^.Description)-Length(#13#10));
/trunk_dos/OIDPLUS.PAS
15,6 → 15,7
const
VERSIONINFO = 'Revision: 2022-02-14';
DEFAULT_STATUSBAR = '(C)2020-2022 ViaThinkSoft. Licensed under the terms of the Apache 2.0 license.';
TITLEBAR_LEFT_TEXT = 'OIDplus';
DISKIO_SOUND_DEBUGGING = false;
DISKIO_SOUND_DELAY = 500;
ASNEDIT_LINES = 10;
24,7 → 25,9
MAINMENU_WIDTH = 15;
MAINMENU_HEIGHT = 3;
MAINMENU_ALLOW_ESC = false;
TITLEBAR_LEFT_TEXT = 'OIDplus';
TREEVIEW_INDENT = 0;
TREEVIEW_INCLUDE_DESC = true;
TREEVIEW_WIDTH = 80;
 
procedure _WriteOidFile(filename: string; oid: POid);
begin
70,15 → 73,12
DrawStatusBar(DEFAULT_STATUSBAR);
end;
 
function _ShowASNIds(subfile: string): string;
function _ShowASNIds(childOID: POID): string;
var
childOID: POID;
j, jmax: integer;
sTmp: string;
begin
sTmp := '';
CreateOidDef(childOID);
_ReadOidFile(subfile, childOID);
jmax := ListCount(childOID^.ASNIds)-1;
for j := 0 to jmax do
begin
89,7 → 89,6
else
sTmp := sTmp + ', ';
end;
FreeOidDef(childOID);
_ShowASNIds := sTmp;
end;
 
256,7 → 255,7
2) then
begin
oid^.description := sInput;
DescEditor := true; (* request caller to save @oid *)
DescEditor := true; (* request caller to save <oid> *)
end;
end;
 
353,7 → 352,7
oid^.DotNotation := sInput
else
oid^.DotNotation := parentOID^.DotNotation + '.' + sInput;
NumIdEditor := true; (* request caller to save @oid *)
NumIdEditor := true; (* request caller to save <oid> *)
Exit;
end;
end
383,7 → 382,7
 
(* Add link to original file and enable the saving of it *)
ListAppend(oid^.SubIds, newOID^.FileId + newOID^.DotNotation);
NewOidEditor := true; (* request caller to save @oid *)
NewOidEditor := true; (* request caller to save <oid> *)
end;
FreeOidDef(newOID);
end;
397,6 → 396,8
for i := 0 to ListCount(oid^.SubIds)-1 do
begin
filenameChild := FileIdPart(ListGetElement(oid^.SubIds, i)) + '.OID';
if FileExists(filenameChild) then
begin
CreateOidDef(childOID);
_ReadOidFile(filenameChild, childOID);
DeleteChildrenRecursive(childOID);
403,6 → 404,7
FreeOidDef(childOID);
DeleteFile(filenameChild);
end;
end;
ListClear(oid^.SubIds);
end;
 
417,6 → 419,8
 
(* Remove forward reference in parent OID *)
filenameParent := FileIdPart(selfOID^.Parent) + '.OID';
if FileExists(filenameParent) then
begin
CreateOidDef(parentOID);
_ReadOidFile(filenameParent, parentOID);
if ListDeleteElementByValue(parentOID^.SubIds, selfOID^.FileId + selfOID^.DotNotation) then
424,11 → 428,15
_WriteOidFile(filenameParent, parentOID);
end;
FreeOidDef(parentOID);
end;
 
(* Delete own file *)
filenameSelf := selfOID^.FileId + '.OID';
if FileExists(filenameSelf) then
begin
DeleteFile(filenameSelf);
end;
end;
 
function _DeleteConfirmation: boolean;
var
470,7 → 478,7
procedure DisplayOIDFile(filename: string);
var
isRoot: boolean;
oid: POID;
oid, tmpOID: POID;
i, menuX, menuY: integer;
linesLeft, linesRequired: integer;
sTmp, subfile: string;
481,6 → 489,13
begin
exitRequest := false;
repeat
if not FileExists(filename) then
begin
ShowMessage('File ' + filename + ' not found', 'ERROR', true);
_Pause;
exit;
end;
 
CreateOidDef(oid);
_ReadOidFile(filename, oid);
 
554,7 → 569,17
begin
sTmp := oid^.Parent;
subfile := FileIdPart(sTmp) + '.OID';
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(subfile));
if FileExists(subfile) then
begin
CreateOidDef(tmpOID);
_ReadOidFile(subfile, tmpOID);
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(tmpOID));
FreeOidDef(tmpOID);
end
else
begin
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + ' (FILE NOT FOUND)');
end;
ListAppend(subfiles, subfile);
end;
 
569,7 → 594,17
begin
sTmp := ListGetElement(oid^.SubIds, i);
subfile := FileIdPart(sTmp) + '.OID';
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + _ShowASNIds(subfile));
if FileExists(subfile) then
begin
CreateOidDef(tmpOID);
_ReadOidFile(subfile, tmpOID);
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + _ShowASNIds(tmpOID));
FreeOidDef(tmpOID);
end
else
begin
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + ' (FILE NOT FOUND)');
end;
ListAppend(subfiles, subfile);
end;
 
628,9 → 663,19
begin
if _DeleteConfirmation then
begin
filename := FileIdPart(oid^.Parent) + '.OID';
sTmp := FileIdPart(oid^.Parent) + '.OID';
DeleteOidRecursive(oid);
if FileExists(sTmp) then
begin
filename := sTmp;
end
else
begin
ShowMessage('Parent file ' + filename + ' not found', 'ERROR', true);
_Pause;
exitRequest := true;
end;
end;
end
else if subselres = menuIdExit then
begin
639,8 → 684,18
else
begin
(* Normal OID *)
filename := ListGetElement(subfiles, subselres);
sTmp := ListGetElement(subfiles, subselres);
if FileExists(sTmp) then
begin
filename := sTmp;
end
else
begin
ShowMessage('File ' + filename + ' not found', 'ERROR', true);
(* TODO: With PatchCRT, there will be an infinite loop here *)
_Pause;
end;
end;
FreeList(subsel);
FreeList(subfiles);
 
666,22 → 721,27
FreeOidDef(oid);
end;
 
procedure OP_ManageOIDs;
function _GetInitFile: string;
var
initFile: string;
begin
ClrScr;
DrawTitleBar('Manage Object Identifiers', TITLEBAR_LEFT_TEXT, '');
DrawStatusBar('Loading data... please wait...');
 
initFile := ZeroPad(0, 8) + '.OID';
if not FileExists(initFile) then
begin
CreateInitOIDFile(initFile);
end;
DisplayOIDFile(initFile);
_GetInitFile := initFile;
end;
 
procedure OP_ManageOIDs;
begin
ClrScr;
DrawTitleBar('Manage Object Identifiers', TITLEBAR_LEFT_TEXT, '');
DrawStatusBar('Loading data... please wait...');
 
DisplayOIDFile(_GetInitFile);
end;
 
procedure OP_ManageRAs;
begin
ClrScr;
696,11 → 756,97
ClrScr;
end;
 
function _GetExportLine(oid: POID; indent: integer): string;
var
i: integer;
sTmp: string;
begin
(* Build line *)
sTmp := RepeatStr(' ', indent*TREEVIEW_INDENT);
if oid^.DotNotation = '' then
sTmp := sTmp + 'Object Identifiers'
else
sTmp := sTmp + oid^.DotNotation;
sTmp := sTmp + _ShowAsnIds(oid);
if TREEVIEW_INCLUDE_DESC then
begin
if Trim(oid^.Description) <> '' then
begin
sTmp := sTmp + ': ' + oid^.Description;
end;
end;
for i := 1 to Length(sTmp) do
begin
if (sTmp[i]=#13) or (sTmp[i]=#10) then sTmp[i] := ' ';
end;
if Length(sTmp) > TREEVIEW_WIDTH then
begin
sTmp := Copy(sTmp, 1, TREEVIEW_WIDTH-3) + '...';
end;
_GetExportLine := sTmp;
end;
 
procedure _RecTreeExport(oid: POID; var F: Text; indent: integer);
var
i: integer;
sTmp: string;
suboid: POID;
childFilename: string;
begin
sTmp := _GetExportLine(oid, indent);
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
WriteLn(F, sTmp);
 
(* Recursively call children *)
for i := 0 to ListCount(oid^.SubIds)-1 do
begin
sTmp := ListGetElement(oid^.SubIds, i);
CreateOidDef(suboid);
childFilename := FileIdPart(sTmp) + '.OID';
if FileExists(childFilename) then
begin
_ReadOidFile(childFilename, suboid);
_RecTreeExport(suboid, F, indent+1);
FreeOidDef(suboid);
end
else
begin
sTmp := 'ERROR: FILE ' + childFilename + ' CONTAINING CHILD OID ' + DotNotationPart(sTmp) + ' WAS NOT FOUND!';
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
WriteLn(F, sTmp);
end;
end;
end;
 
procedure OP_TreeView;
var
F: Text;
rootoid: POID;
begin
ClrScr;
DrawTitleBar('TreeView Export', TITLEBAR_LEFT_TEXT, '');
DrawStatusBar('Exporting data... please wait...');
 
Assign(F, 'OIDTREE.TXT');
Rewrite(F);
 
CreateOidDef(rootoid);
_ReadOidFile(_GetInitFile, rootoid);
_RecTreeExport(rootoid, F, 0);
FreeOidDef(rootoid);
 
DrawStatusBar(DEFAULT_STATUSBAR);
ShowMessage('TreeView successfully exported as OIDTREE.TXT', 'TREEVIEW EXPORT', true);
_Pause;
 
Close(F);
end;
 
procedure OP_MainMenu;
var
menu: PStringList;
menuRes, menuLeft, menuTop: integer;
menuIdOID, menuIdRA, menuIdExit: integer;
menuIdOID, menuIdRA, menuIdTree, menuIdExit: integer;
begin
repeat
ClrScr;
714,6 → 860,7
 
menuIdOID := ListAppend(menu, 'Manage OIDs');
menuIdRA := -99; (*ListAppend(menu, 'Manage RAs');*)
menuIdTree := ListAppend(menu, 'Export TreeView');
menuIdExit := ListAppend(menu, 'Return to DOS');
 
menuLeft := round(ScreenWidth/2 -MAINMENU_WIDTH/2);
730,6 → 877,10
else if menuRes = menuIdRA then
begin
OP_ManageRAs;
end
else if menuRes = menuIdTree then
begin
OP_Treeview;
end;
until (menuRes = menuIdExit) or (MAINMENU_ALLOW_ESC and (menuRes = -1));
 
/trunk_dos/OIDUTILS.PAS
79,11 → 79,13
var
n, i: integer;
a, b: string;
swapped: boolean;
begin
n := ListCount(list);
while n>1 do
begin
i := 0;
swapped := false;
while i<n-1 do
begin
a := ListGetElement(list, i);
91,9 → 93,11
if CompareOID(a, b) > 0 then
begin
ListSwapElement(list, i, i+1);
swapped := true;
end;
Inc(i);
end;
if not swapped then break;
Dec(n);
end;
end;
/trunk_dos/STRLIST.PAS
51,7 → 51,7
procedure FreeList(list: PStringList);
begin
if list^.next <> nil then
FreeMem(list^.next, SizeOf(TStringList));
FreeList(list^.Next);
FreeMem(list, SizeOf(TStringList));
end;
 
282,11 → 282,13
var
n, i: integer;
a, b: string;
swapped: boolean;
begin
n := ListCount(list);
while n>1 do
begin
i := 0;
swapped := false;
while i<n-1 do
begin
a := ListGetElement(list, i);
294,9 → 296,11
if CompareNumericString(a, b) > 0 then
begin
ListSwapElement(list, i, i+1);
swapped := true;
end;
Inc(i);
end;
if not swapped then break;
Dec(n);
end;
end;
/trunk_dos/TODO.TXT
1,6 → 1,5
 
TODO:
* Export a tree diagram of all OIDs into a text file (can also be printed)
* Implement RAs
* Implement Create/Update timestamps? (people must be able to predate it)
* See "TODO" entries in the *.pas files
/trunk_dos/VTSCUI.PAS
319,11 → 319,7
else
begin
sTmp := ListGetElement(items, i);
if Length(sTmp) > ListWidth then
begin
(* Cut too long line *)
sTmp := Copy(sTmp, 1, ListWidth-3) + '...';
end;
sTmp := TrimLineToWidth(sTmp, ListWidth);
Write(FillRight(sTmp, ListWidth, ' '));
end;
TextColor(White);
350,11 → 346,15
else if sc = #$47(*POS1*) then
begin
itemIndex := 0;
iStartScope := 0;
iEndScope := iStartScope + ListHeight;
goto doAgain;
end
else if sc = #$4F(*END*) then
begin
itemIndex := ListCount(items);
itemIndex := ListCount(items)-1;
iStartScope := itemIndex - Min(ListHeight,ListCount(items));
iEndScope := itemIndex;
goto doAgain;
end;
end;
/trunk_dos/VTSFUNCS.PAS
20,9 → 20,11
procedure Beep;
 
function Trim(s: string): string;
function TrimLineToWidth(s: string; width: integer): string;
function ZeroPad(i: LongInt; n: integer): string;
function LeftPadStr(s: string; n: integer; ch: char): string;
function RightPadStr(s: string; n: integer; ch: char): string;
function RepeatStr(ch: char; n: integer): string;
 
function DeleteFile(filename: string): boolean;
function FileExists(filename: string): boolean;
110,6 → 112,16
Trim := s;
end;
 
function TrimLineToWidth(s: string; width: integer): string;
begin
(* TODO: Put into VTSUTILS, also use for VTSCUI menu *)
if Length(s) > width then
begin
s := Copy(s, 1, width-3) + '...';
end;
TrimLineToWidth := s;
end;
 
function ZeroPad(i: LongInt; n: integer): string;
var
s: string;
136,6 → 148,19
RightPadStr := s;
end;
 
function RepeatStr(ch: char; n: integer): string;
var
i: integer;
res: string;
begin
res := '';
for i := 1 to n do
begin
res := res + ch;
end;
RepeatStr := res;
end;
 
function DeleteFile(filename: string): boolean;
var
F: file;
167,8 → 192,16
{$I-}
Reset(F);
{$I+}
FileExists := IoResult = 0;
if IoResult = 0 then
begin
Close(F);
FileExists := true;
end
else
begin
FileExists := false;
end;
end;
 
function IsPositiveInteger(s: string): boolean;
var
/trunk_dos/.
Property changes:
Modified: svn:ignore
*.TPU
*.BAK
*.OID
+OIDTREE.TXT
PATCHCRT.EXE