Subversion Repositories oidplus

Rev

Rev 749 | Rev 965 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 749 Rev 758
Line 1... Line 1...
1
program OIDPLUS;
1
program OIDPLUS;
2
 
2
 
3
(************************************************)
3
(************************************************)
4
(* OIDPLUS.PAS                                  *)
4
(* OIDPLUS.PAS                                  *)
5
(* Author:   Daniel Marschall                   *)
5
(* Author:   Daniel Marschall                   *)
6
(* Revision: 2022-02-20                         *)
6
(* Revision: 2022-02-27                         *)
7
(* License:  Apache 2.0                         *)
7
(* License:  Apache 2.0                         *)
8
(* This file contains:                          *)
8
(* This file contains:                          *)
9
(* - "OIDplus for DOS" program                  *)
9
(* - "OIDplus for DOS" program                  *)
10
(************************************************)
10
(************************************************)
11
 
11
 
Line 20... Line 20...
20
uses
20
uses
21
  Dos, Crt, Drivers, StrList, VtsFuncs, VtsCui, OidFile, OidUtils,
21
  Dos, Crt, Drivers, StrList, VtsFuncs, VtsCui, OidFile, OidUtils,
22
  Weid;
22
  Weid;
23
 
23
 
24
const
24
const
25
  VERSIONINFO            = 'Revision: 2022-02-20';
25
  VERSIONINFO            = 'Revision: 2022-02-27';
26
  TITLEBAR_LEFT_TEXT     = 'OIDplus';
26
  TITLEBAR_LEFT_TEXT     = 'OIDplus';
27
  DISKIO_SOUND_DEBUGGING = false;
27
  DISKIO_SOUND_DEBUGGING = false;
28
  DISKIO_SOUND_DELAY     = 500;
28
  DISKIO_SOUND_DELAY     = 500;
29
  ASNEDIT_LINES          = 10;
29
  ASNEDIT_LINES          = 10;
30
  DESCEDIT_LINES         = 10;
30
  DESCEDIT_LINES         = 10;
Line 1097... Line 1097...
1097
 
1097
 
1098
  sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1098
  sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1099
  _GetTreeViewLine := sTmp;
1099
  _GetTreeViewLine := sTmp;
1100
end;
1100
end;
1101
 
1101
 
1102
procedure _RecTreeExport(oid: POID; var F: Text; indent: integer);
1102
procedure _RecTreeExport(oid: POID; visList, targetList: PStringList; indent: integer);
1103
var
1103
var
1104
  i: integer;
1104
  i: integer;
1105
  sTmp: string;
1105
  sTmp: string;
1106
  suboid: POID;
1106
  suboid: POID;
1107
  childFilename: string;
1107
  childFilename: string;
1108
begin
1108
begin
1109
  sTmp := _GetTreeViewLine(oid, indent);
1109
  sTmp := _GetTreeViewLine(oid, indent);
1110
  sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1110
  sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1111
  WriteLn(F, sTmp);
1111
  ListAppend(visList, sTmp);
-
 
1112
  ListAppend(targetList, oid^.FileID);
1112
 
1113
 
1113
  (* Recursively call children *)
1114
  (* Recursively call children *)
1114
  for i := 0 to ListCount(oid^.SubIds)-1 do
1115
  for i := 0 to ListCount(oid^.SubIds)-1 do
1115
  begin
1116
  begin
1116
    sTmp := ListGetElement(oid^.SubIds, i);
1117
    sTmp := ListGetElement(oid^.SubIds, i);
Line 1118... Line 1119...
1118
    childFilename := FileIdPart(sTmp) + OID_EXTENSION;
1119
    childFilename := FileIdPart(sTmp) + OID_EXTENSION;
1119
    if not FileExists(childFilename) then
1120
    if not FileExists(childFilename) then
1120
    begin
1121
    begin
1121
      sTmp := 'ERROR: MISSING ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!';
1122
      sTmp := 'ERROR: MISSING ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!';
1122
      sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1123
      sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1123
      WriteLn(F, sTmp);
1124
      ListAppend(visList, sTmp);
-
 
1125
      ListAppend(targetList, 'ERROR');
1124
    end
1126
    end
1125
    else if not _ReadOidFile(childFilename, suboid, false) then
1127
    else if not _ReadOidFile(childFilename, suboid, false) then
1126
    begin
1128
    begin
1127
      sTmp := 'ERROR: READ ERROR AT ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!';
1129
      sTmp := 'ERROR: READ ERROR AT ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!';
1128
      sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1130
      sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1129
      WriteLn(F, sTmp);
1131
      ListAppend(visList, sTmp);
-
 
1132
      ListAppend(targetList, 'ERROR');
1130
    end
1133
    end
1131
    else if (suboid^.ParentFileId <> oid^.FileId) or
1134
    else if (suboid^.ParentFileId <> oid^.FileId) or
1132
            (suboid^.ParentDotNotation <> oid^.DotNotation) then
1135
            (suboid^.ParentDotNotation <> oid^.DotNotation) then
1133
    begin
1136
    begin
1134
      (* This can happen if a file is missing, and then another OID gets this filename since the number seems to be free *)
1137
      (* This can happen if a file is missing, and then another OID gets this filename since the number seems to be free *)
1135
      sTmp := 'ERROR: BAD BACKREF AT ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!';
1138
      sTmp := 'ERROR: BAD BACKREF AT ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!';
1136
      sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1139
      sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
1137
      WriteLn(F, sTmp);
1140
      ListAppend(visList, sTmp);
-
 
1141
      ListAppend(targetList, 'ERROR');
1138
    end
1142
    end
1139
    else
1143
    else
1140
    begin
1144
    begin
1141
      _RecTreeExport(suboid, F, indent+1);
1145
      _RecTreeExport(suboid, visList, targetList, indent+1);
1142
      FreeOidDef(suboid);
1146
      FreeOidDef(suboid);
1143
    end
1147
    end
1144
  end;
1148
  end;
1145
end;
1149
end;
1146
 
1150
 
1147
procedure TreeViewPreview;
1151
procedure TreeViewPreview(visList, targetList: PStringList);
1148
var
1152
var
-
 
1153
  res: integer;
1149
  list: PStringList;
1154
  sTmp: string;
1150
begin
1155
begin
1151
  ClrScr;
1156
  ClrScr;
1152
  DrawTitleBar('TreeView Export', TITLEBAR_LEFT_TEXT, TREEVIEW_FILENAME);
1157
  DrawTitleBar('TreeView Export', TITLEBAR_LEFT_TEXT, TREEVIEW_FILENAME);
1153
  DrawStatusBar('Press ESC to return to the main menu');
1158
  DrawStatusBar('Press ESC to return to the main menu. Enter to jump to OID.');
1154
 
1159
 
1155
  CreateList(list);
1160
  while true do
1156
 
1161
  begin
1157
  ListLoadFromFile(list, TREEVIEW_FILENAME);
-
 
1158
  DrawSelectionList(2, 3, ScreenWidth-2, ScreenHeight-4,
1162
    res := DrawSelectionList(2, 3, ScreenWidth-2, ScreenHeight-4,
1159
                    list, true, 'PREVIEW OF '+TREEVIEW_FILENAME, 2);
1163
                             visList, true, 'PREVIEW OF '+TREEVIEW_FILENAME, 2);
-
 
1164
    if res > -1 then
-
 
1165
    begin
1160
  (* TODO: Jump to selected OID *)
1166
      (* Jump to selected OID or show error *)
-
 
1167
      sTmp := ListGetElement(targetList, res);
-
 
1168
      if sTmp = 'ERROR' then
-
 
1169
      begin
-
 
1170
        ShowMessage(ListGetElement(visList, res), 'ERROR', true);
-
 
1171
        _Pause;
-
 
1172
      end
-
 
1173
      else
-
 
1174
      begin
-
 
1175
        DisplayOidFile(sTmp + '.OID');
-
 
1176
      end;
-
 
1177
    end
-
 
1178
    else
-
 
1179
    begin
-
 
1180
      break;
-
 
1181
    end;
-
 
1182
  end;
1161
 
1183
 
1162
  DrawStatusBar('');
1184
  DrawStatusBar('');
1163
 
-
 
1164
  FreeList(list);
-
 
1165
end;
1185
end;
1166
 
1186
 
1167
procedure OP_TreeView;
1187
procedure OP_TreeView;
1168
var
1188
var
1169
  F: Text;
1189
  F: Text;
1170
  rootoid: POID;
1190
  rootoid: POID;
1171
  rootfile: string;
1191
  rootfile: string;
1172
  res: boolean;
1192
  res: boolean;
-
 
1193
  visList, targetList: PStringList;
1173
begin
1194
begin
1174
  ClrScr;
1195
  ClrScr;
1175
  DrawTitleBar('TreeView Export', TITLEBAR_LEFT_TEXT, '');
1196
  DrawTitleBar('TreeView Export', TITLEBAR_LEFT_TEXT, '');
1176
  DrawStatusBar('Exporting data... please wait...');
1197
  DrawStatusBar('Exporting data... please wait...');
1177
 
1198
 
Line 1181... Line 1202...
1181
  begin
1202
  begin
1182
    DrawStatusBar('');
1203
    DrawStatusBar('');
1183
    Exit;
1204
    Exit;
1184
  end;
1205
  end;
1185
 
1206
 
-
 
1207
  CreateList(visList);
-
 
1208
  CreateList(targetList);
-
 
1209
 
-
 
1210
  (* First check if the disk is read-only *)
1186
  Assign(F, TREEVIEW_FILENAME);
1211
  Assign(F, TREEVIEW_FILENAME);
1187
  {$I-}
1212
  {$I-}
1188
  Rewrite(F);
1213
  Rewrite(F);
1189
  {$I+}
1214
  {$I+}
1190
  if IoResult <> 0 then
1215
  if IoResult <> 0 then
Line 1193... Line 1218...
1193
    ShowMessage('Cannot open '+TREEVIEW_FILENAME+' for writing.', 'ERROR', true);
1218
    ShowMessage('Cannot open '+TREEVIEW_FILENAME+' for writing.', 'ERROR', true);
1194
    _Pause;
1219
    _Pause;
1195
    DrawStatusBar('');
1220
    DrawStatusBar('');
1196
    Exit;
1221
    Exit;
1197
  end;
1222
  end;
-
 
1223
  Close(F);
1198
 
1224
 
-
 
1225
  (* Now do the export *)
1199
  res := false;
1226
  res := false;
1200
  CreateOidDef(rootoid);
1227
  CreateOidDef(rootoid);
1201
  if _ReadOidFile(rootfile, rootoid, true) then
1228
  if _ReadOidFile(rootfile, rootoid, true) then
1202
  begin
1229
  begin
1203
    _RecTreeExport(rootoid, F, 0);
1230
    _RecTreeExport(rootoid, visList, targetList, 0);
1204
    res := true;
1231
    res := true;
1205
  end;
1232
  end;
1206
  FreeOidDef(rootoid);
1233
  FreeOidDef(rootoid);
1207
 
1234
 
-
 
1235
  (* Save the list (visual part only) *)
1208
  Close(F);
1236
  ListSaveToFile(visList, TREEVIEW_FILENAME);
1209
 
1237
 
1210
  DrawStatusBar('');
1238
  DrawStatusBar('');
1211
  if res then
1239
  if res then
1212
  begin
1240
  begin
1213
    ShowMessage('TreeView successfully exported as '+TREEVIEW_FILENAME, 'TREEVIEW EXPORT', true);
1241
    ShowMessage('TreeView successfully exported as '+TREEVIEW_FILENAME, 'TREEVIEW EXPORT', true);
1214
    _Pause;
1242
    _Pause;
1215
  end;
1243
  end;
1216
 
1244
 
-
 
1245
  TreeViewPreview(visList, targetList);
-
 
1246
 
1217
  TreeViewPreview;
1247
  FreeList(visList);
-
 
1248
  FreeList(targetList);
1218
end;
1249
end;
1219
 
1250
 
1220
procedure OP_MainMenu;
1251
procedure OP_MainMenu;
1221
var
1252
var
1222
  menu: PStringList;
1253
  menu: PStringList;