@@ -126,7 +126,7 @@ implementation
126126
127127{ $R *.lfm}
128128
129- uses MainUnit,ConsoleAppUnit ;
129+ uses MainUnit;
130130
131131{ THexDumpForm }
132132
@@ -334,49 +334,38 @@ procedure THexDumpForm.btnSaveTextClick(Sender: TObject);
334334 len : Byte=0 ;
335335 i : Integer=0 ;
336336 pos : Integer=0 ;
337- ok : Boolean=False;
338337begin
339- if MainForm.Fguiopen then
340- begin
341- // Adapt the filename
342- line:=Caption;
343- BBCToWin(line);
344- // Remove any dots
345- for i:=1 to Length(line) do if line[i]=' .' then line[i]:=' -' ;
346- SaveFile.Filename:=line+' -dump.txt' ;
347- // And open the dialogue box
348- ok:=SaveFile.Execute;
349- end else ok:=True;
350- if ok then
338+ // Adapt the filename
339+ line:=Caption;
340+ BBCToWin(line);
341+ // Remove any dots
342+ for i:=1 to Length(line) do if line[i]=' .' then line[i]:=' -' ;
343+ SaveFile.Filename:=line+' -dump.txt' ;
344+ // And open the dialogue box
345+ if SaveFile.Execute then
351346 begin
352- if MainForm.Fguiopen then
353- begin
354- // Show the progress bar
355- pbProgress.Visible:=True;
356- pbProgress.Position:=0 ;
357- // Create a new file (overwrite one if already exists)
358- F:=TFileStream.Create(SaveFile.Filename,fmCreate);
359- // Set to start of file
360- F.Position:=0 ;
361- // Write out the header
362- WriteLine(F,MainForm.ApplicationTitle+' V' +MainForm.ApplicationVersion);
363- WriteLine(F,' https://www.geraldholdsworth.co.uk https://github.com/geraldholdsworth/DiscImageManager' );
364- WriteLine(F,' ' );
365- WriteLine(F,' Filename : ' +Caption);
366- WriteLine(F,' Total Filesize: ' +IntToStr(Length(buffer))
367- +' (0x' +IntToHex(Length(buffer),10 )+' ) bytes' );
368- WriteLine(F,' ' );
369- end ;
347+ // Show the progress bar
348+ pbProgress.Visible:=True;
349+ pbProgress.Position:=0 ;
350+ // Create a new file (overwrite one if already exists)
351+ F:=TFileStream.Create(SaveFile.Filename,fmCreate);
352+ // Set to start of file
353+ F.Position:=0 ;
354+ // Write out the header
355+ WriteLine(F,MainForm.ApplicationTitle+' V' +MainForm.ApplicationVersion);
356+ WriteLine(F,' https://www.geraldholdsworth.co.uk https://github.com/geraldholdsworth/DiscImageManager' );
357+ WriteLine(F,' ' );
358+ WriteLine(F,' Filename : ' +Caption);
359+ WriteLine(F,' Total Filesize: ' +IntToStr(Length(buffer))
360+ +' (0x' +IntToHex(Length(buffer),10 )+' ) bytes' );
361+ WriteLine(F,' ' );
370362 line:=' Address 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ASCII' ;
371- if MainForm.Fguiopen then WriteLine(F,line)
372- else WriteLn(cmdBold+line+cmdNormal);
363+ WriteLine(F,line);
373364 // Now the data
374365 pos:=0 ;// Start of the data
375366 repeat
376367 // Start the line off with the address, in hex, 10 digits long
377368 line:=IntToHex((pos div $10 )*$10 ,10 )+' ' ;
378- if not MainForm.Fguiopen then
379- line:=cmdBold+line+cmdNormal;
380369 // Set the amount of data to read to 16 bytes
381370 len:=$10 ;
382371 // If this will take us over the total size, then adjust accordingly
@@ -392,35 +381,26 @@ procedure THexDumpForm.btnSaveTextClick(Sender: TObject);
392381 if p=$07 then line:=line+' ' ; // Split in the middle
393382 end ;
394383 // Extra space to separate from the characters
395- if MainForm.Fguiopen then
396- line:=PadRight(line,62 )
397- else
398- line:=PadRight(line,70 );
384+ line:=PadRight(line,62 );
399385 // Now the characters
400386 for p:=0 to len-1 do
401387 if (buffer[p+pos]>31 ) AND (buffer[p+pos]<127 ) then
402388 line:=line+chr(buffer[p+pos]) // Printable
403389 else
404390 line:=line+' .' ; // Not printable
405391 // Write out the complete line
406- if MainForm.Fguiopen then WriteLine(F,line) else WriteLn(line);
407- end ;
408- if MainForm.Fguiopen then
409- begin
410- // Update the progress bar
411- pbProgress.Position:=Round((pos/Length(buffer))*100 );
412- Application.ProcessMessages;
392+ WriteLine(F,line);
413393 end ;
394+ // Update the progress bar
395+ pbProgress.Position:=Round((pos/Length(buffer))*100 );
396+ Application.ProcessMessages;
414397 // Continue until no more data
415398 inc(pos,len);
416399 until pos=Length(buffer);
417- if MainForm.Fguiopen then
418- begin
419- // Close the file and exit
420- F.Free;
421- // Hide the progress bar
422- pbProgress.Visible:=False;
423- end ;
400+ // Close the file and exit
401+ F.Free;
402+ // Hide the progress bar
403+ pbProgress.Visible:=False;
424404 end ;
425405end ;
426406
@@ -872,8 +852,6 @@ procedure THexDumpForm.DecodeBasicFile;
872852 +StringReplace(PadLeft(IntToStr(linenum),5 ),' ' ,' ' ,[rfReplaceAll])
873853 +' </span> ' ;
874854 basictxt:=PadLeft(IntToStr(linenum),5 );
875- if not MainForm.Fguiopen then
876- basictxt:=cmdBlue+basictxt+cmdNormal;
877855 // Line length
878856 linelen:=buffer[ptr+3 ];
879857 // Move our line pointer one
@@ -917,8 +895,6 @@ procedure THexDumpForm.DecodeBasicFile;
917895 inc(lineptr,3 );
918896 end ;
919897 linetxt:=linetxt+' <span ' +keywordstyle+' >' +tmp+' </span>' ;
920- if not MainForm.Fguiopen then
921- tmp:=cmdBold+cmdMagenta+tmp+cmdNormal;
922898 basictxt:=basictxt+tmp;
923899 end
924900 else // Extended tokens (BASIC V)
@@ -938,8 +914,6 @@ procedure THexDumpForm.DecodeBasicFile;
938914 if c=$C8 then
939915 if t-$8E<=High(exttokens3)then tmp:=exttokens3[t-$8E];
940916 linetxt:=linetxt+' <span ' +keywordstyle+' >' +tmp+' </span>' ;
941- if not MainForm.Fguiopen then
942- tmp:=cmdBold+cmdMagenta+tmp+cmdNormal;
943917 basictxt:=basictxt+tmp;
944918 end ;
945919 end ;
@@ -950,10 +924,7 @@ procedure THexDumpForm.DecodeBasicFile;
950924 if c>31 then
951925 begin
952926 if not rem then if (c=34 )AND (detok)then
953- if MainForm.Fguiopen then
954- linetxt:=linetxt+' <span ' +quotestyle+' >'
955- else
956- basictxt:=basictxt+cmdRed+cmdItalic;
927+ linetxt:=linetxt+' <span ' +quotestyle+' >' ;
957928 if (c<>32 )and (c<>38 )and (c<>60 )and (c<>62 )then
958929 linetxt:=linetxt+Chr(c AND $7F );
959930 if c=32 then linetxt:=linetxt+' ' ;
@@ -962,8 +933,6 @@ procedure THexDumpForm.DecodeBasicFile;
962933 if c=62 then linetxt:=linetxt+' >' ;
963934 if not rem then if (c=34 )and (not detok)then linetxt:=linetxt+' </span>' ;
964935 basictxt:=basictxt+Chr(c AND $7F );
965- if not rem then if (c=34 )and (not detok)and (not MainForm.Fguiopen)then
966- basictxt:=basictxt+cmdNormal;
967936 // Do not detokenise within quotes
968937 if (c=34 )and (not rem)then detok:=not detok;
969938 end ;
@@ -975,43 +944,36 @@ procedure THexDumpForm.DecodeBasicFile;
975944 inc(ptr,linelen);
976945 end ;
977946 end ;
978- if MainForm.Fguiopen then
979- begin
980- // Display the minimum compatible BASIC version
981- linetxt:=' ' ;
982- case basicver of
983- 1 : linetxt:=' I' ;
984- 2 : linetxt:=' II' ;
985- 3 : linetxt:=' III' ;
986- 4 : linetxt:=' IV' ;
987- 5 : linetxt:=' V' ;
988- end ;
989- BasicViewer.Caption:=' BBC BASIC' +linetxt;
990- // Change the colour
991- BasicOutput.Color:=$FF0000;
992- BasicOutput.Font.Color:=$FFFFFF;
993- // Finish off the HTML
994- fs.WriteString(' </body></html>' );
995- // Now upload the document to the display
996- fs.Position:=0 ;
997- BasicOutput.SetHtmlFromStream(fs);
998- fs.Free;
999- // Make the tab visible
1000- BasicViewer.TabVisible:=True;
1001- // And switch to it
1002- PageControl.ActivePage:=BasicViewer;
1003- PageControlChange(nil );
1004- end
1005- else
1006- if BasicTxtOutput.Count>0 then
1007- for ptr:=0 to BasicTxtOutput.Count-1 do
1008- WriteLn(BasicTxtOutput[ptr]);
947+ // Display the minimum compatible BASIC version
948+ linetxt:=' ' ;
949+ case basicver of
950+ 1 : linetxt:=' I' ;
951+ 2 : linetxt:=' II' ;
952+ 3 : linetxt:=' III' ;
953+ 4 : linetxt:=' IV' ;
954+ 5 : linetxt:=' V' ;
955+ end ;
956+ BasicViewer.Caption:=' BBC BASIC' +linetxt;
957+ // Change the colour
958+ BasicOutput.Color:=$FF0000;
959+ BasicOutput.Font.Color:=$FFFFFF;
960+ // Finish off the HTML
961+ fs.WriteString(' </body></html>' );
962+ // Now upload the document to the display
963+ fs.Position:=0 ;
964+ BasicOutput.SetHtmlFromStream(fs);
965+ fs.Free;
966+ // Make the tab visible
967+ BasicViewer.TabVisible:=True;
968+ // And switch to it
969+ PageControl.ActivePage:=BasicViewer;
970+ PageControlChange(nil );
1009971 end
1010972 else // Display as text file, if it is a text file
1011973 if IsTextFile then
1012974 begin
1013975 // Clear the container
1014- if MainForm.Fguiopen then TextOutput.Clear;
976+ TextOutput.Clear;
1015977 linetxt:=' ' ;
1016978 while ptr<Length(buffer) do
1017979 begin
@@ -1027,26 +989,21 @@ procedure THexDumpForm.DecodeBasicFile;
1027989 if ((c=$0A)and (cn<>$0D))
1028990 or ((c=$0D)and (cn<>$0A))then
1029991 begin
1030- if MainForm.Fguiopen then TextOutput.Lines.Add(linetxt)
1031- else WriteLn(linetxt);
992+ TextOutput.Lines.Add(linetxt);
1032993 linetxt:=' ' ;
1033994 end ;
1034995 end ;
1035996 // At the end, anything left then push to the output container
1036997 if linetxt<>' ' then
1037- if MainForm.Fguiopen then TextOutput.Lines.Add(linetxt)
1038- else WriteLn(linetxt);
1039- if MainForm.Fguiopen then
1040- begin
1041- // Move the cursor to the beginning
1042- TextOutput.SelStart:=0 ;
1043- TextOutput.SelLength:=0 ;
1044- // Make the tab visible
1045- TextViewer.TabVisible:=True;
1046- // And switch to it
1047- PageControl.ActivePage:=TextViewer;
1048- PageControlChange(nil );
1049- end ;
998+ TextOutput.Lines.Add(linetxt);
999+ // Move the cursor to the beginning
1000+ TextOutput.SelStart:=0 ;
1001+ TextOutput.SelLength:=0 ;
1002+ // Make the tab visible
1003+ TextViewer.TabVisible:=True;
1004+ // And switch to it
1005+ PageControl.ActivePage:=TextViewer;
1006+ PageControlChange(nil );
10501007 end ;
10511008end ;
10521009
0 commit comments