Author Topic: Compile old QB4.5 code help  (Read 2806 times)

0 Members and 1 Guest are viewing this topic.

Offline AdyTT

  • Newbie
  • Posts: 3
Compile old QB4.5 code help
« on: September 25, 2020, 04:13:50 am »
Hi All,

New user here. Not experienced in QB at all so be gentle :-)

I  stumbled across this forum in hope I could find a solution to my problem. I have some very old quick basic 4.5 code that I need to be able to run on Windows 10 (64 bit) operating system. QB64 seems to do the trick and I can run it no problems on my windows 10 machine.

I have successfully opened the old .bas file and converted it to readable txt from binary but when I try to compile, it complains of a syntax error.

The error is relating to a sub function that is not included in the file but is actually included in another .bas file.

How can I tell QB64 to look in another file for Subs besides the one which is open?

Summary:

I have two files

file1.bas
file2.bas

File1 will not compile to exe because of syntax error. The error is due to a sub not being found. The sub actually resides in File2. File2 compiles no problems but doesn't actually do anything as its simply a utility piece of code to support file1.

Thank you for any help

Thanks

Andy

Offline mpgcan

  • Newbie
  • Posts: 26
Re: Compile old QB4.5 code help
« Reply #1 on: September 25, 2020, 05:52:27 am »
At the end of file1.bas add the following line:

'$INCLUDE: 'file2.bas'

Additional information check wiki page http://www.qb64.org/wiki/$INCLUDE


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Compile old QB4.5 code help
« Reply #2 on: September 25, 2020, 09:21:50 am »
Yes and if file2.bas has constants or user defined types that part of the file should be INCLUDEd at the top of file1.bas.

The top include is called a file2.BI and the bottom with the SUBs and FUNCTIONs is called file2.BM. The BI and BM extension names are not required but are conventional extension names.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • GitHub
Re: Compile old QB4.5 code help
« Reply #3 on: September 25, 2020, 10:55:50 am »
If the files don't contain personal information you can attach them to a post here and one of us would be glad to help you convert the syntax over to the modern usage.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Compile old QB4.5 code help
« Reply #4 on: September 25, 2020, 11:40:58 am »
What I do most of the time is just copy/paste the sub(s) or function(s) into the bas program that needs it.

I have a whole toolbox of such subs and functions = procedures. With the copy/paste method you only have one file to worry about AND you can modify the procedures to your hearts desire, worry free that modifying an include file wont mess up all the other bas programs using same include file.

bi and bm includes usually work best for a library set of procedures build around special types like formats for png and other image or sound files or API works, right @SpriggsySpriggs ? :)

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • GitHub
Re: Compile old QB4.5 code help
« Reply #5 on: September 25, 2020, 11:57:37 am »
bi and bm includes usually work best for a library set of procedures build around special types like formats for png and other image or sound files or API works, right @SpriggsySpriggs ? :)
@bplus Right.
I love using BI and BM files for my APIs and other specialized functions and find that most of the time if I'm using Windows DLLs then all I need is a BM because I can put my DECLARE DYNAMIC LIBRARY right before the function so I don't need to have a BI with just the DECLARE.
« Last Edit: September 25, 2020, 12:15:31 pm by SpriggsySpriggs »
Shuwatch!

Offline AdyTT

  • Newbie
  • Posts: 3
Re: Compile old QB4.5 code help
« Reply #6 on: September 28, 2020, 04:45:54 am »
If the files don't contain personal information you can attach them to a post here and one of us would be glad to help you convert the syntax over to the modern usage.

If anyone would be kind enough to convert the attached programs that would be amazing. It doesn't appear to be as straight forward as including the missing files as I originally first thought.

Attachment has 4 separate programs. The software is that old there is no concern over confidential/personal info being contained within.

Many Thanks

Andy

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • GitHub
Re: Compile old QB4.5 code help
« Reply #7 on: September 28, 2020, 10:11:21 am »
I've downloaded the files and I'm going through them right now. Some variable declarations are a little wonky but so far so good.
Shuwatch!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • GitHub
Re: Compile old QB4.5 code help
« Reply #8 on: September 28, 2020, 10:42:47 am »
Hmmmm.... Apparently it will take someone more versed in TYPEs than myself.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Compile old QB4.5 code help
« Reply #9 on: September 28, 2020, 12:46:54 pm »
I took a look at SPECEDIT added the UTIL stuff to code but all that unnecessary dot stuff drives me batty!

The first error flagged
Code: QB64: [Select]
  1. Type.number$ = "~~~~~~"    
  2.  


might be fixed by renaming TType.number$ = ...  , yeah that flag gone by replacing with new name (throughout the code).

Then we come to this (line 525 after I remove all redundant DECLAREs):
Code: QB64: [Select]
  1.             CASE 67 'F9
  2.                 Setst$ = LTRIM$(STR$(Edit.set%))
  3.                 IF Ask("Are you sure you want to MAKE INDICES = LINE NUMBERS in Set " + Setst$) = YES THEN
  4.                     FOR Line.number% = 1 TO Psf.numpars%(Edit.set%)
  5.         Psfset(Edit.set%, Line.number%).Index = Line.number%   ' <<<<<<<< flagged
  6.       NEXT Line.number%
  7.  

Really use this: "Line.number%" for a FOR loop index?
Line.number% not conflicting with LINE because:
Code: QB64: [Select]
  1. FOR line.number% = 1 TO 10
  2.     PRINT line.number%
  3.  
works!

Anyway looks like a ton of naming conflicts.

This might be conflict that line 525 is flagging:
Code: QB64: [Select]
  1. DIM Psfset(3, 1 TO 220) AS Psfparamtype ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  2 of same name
  2. '-----------------------------------------------------------------------------
  3. 'General
  4. COMMON SHARED Softiss AS STRING * 2, Softdate AS STRING * 13, Printerok%
  5. COMMON SHARED Type.number AS STRING * 6, Choose.done%
  6. 'File operations
  7. COMMON SHARED Drive$, Path$, Psf$, Psfoption$, Prev.issue AS STRING * 3
  8. COMMON SHARED Fileunfound%, Fileduplicate%
  9. 'File contents data
  10. COMMON SHARED Psf.typeno AS STRING * 6, Psf.progiss AS STRING * 3
  11. COMMON SHARED Psf.preceding AS STRING * 3, Psf.progdate AS STRING * 10
  12. COMMON SHARED Psf.sourcename AS STRING * 20, Psf.sourceiss AS STRING * 5
  13. COMMON SHARED Psf.sourcedate AS STRING * 10, Psf.amendrefs AS STRING * 80
  14. COMMON SHARED Psf.custype AS STRING * 20, Psf.hitemp AS INTEGER
  15. COMMON SHARED Psf.lotemp AS INTEGER, Psf.sermark AS INTEGER
  16. COMMON SHARED Psf.history AS STRING * 80, Psf.crn AS STRING * 6
  17. COMMON SHARED Psf.eng AS STRING * 10, Psf.comment1 AS STRING * 80
  18. COMMON SHARED Psf.comment2 AS STRING * 80, Psf.comment3 AS STRING * 80
  19. COMMON SHARED Psf.comment4 AS STRING * 80, Psf.comment5 AS STRING * 80
  20. COMMON SHARED Psf.numsets AS INTEGER, Psf.numpars AS INTEGER
  21. COMMON SHARED Psf.numspaces AS INTEGER, Psf.setlabel AS STRING * 20
  22. COMMON SHARED Psfset AS Psfparamtype, Host AS STRING * 20 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  2 of same name
  23. '-----------------------------------------------------------------------------
  24.  

good coding practice DIM variables for main code after COMMON SHARED or DIM SHARED

' whole monster!
Code: QB64: [Select]
  1. '-----------------------------------------------------------------------------
  2. '                           NAMING CONVENTIONS
  3. '  Category............................................  Format  Example
  4. 'PROCEDURES
  5. '  Main procedure relating to main menu function         NNNN    TASK
  6. '  Subsidiary procedure in main module                   Nn.nn   Do.task
  7. '  Utility procedure                                     Nnnn    Utility
  8. 'DATA
  9. '  Constant                                              NNNN    FRED
  10. '  General variable                                      Nnnn    Fredgen
  11. '  One of a set of variables related to a subject (Fred) Nn.nn   Fred.variable
  12. '  Element of variable (Fred) with user-defined type     Nn.Nn   Fred.Element
  13. '
  14. '      I/O PATHS
  15. '      #1    Printer LPT1
  16. '      #2    PSF file I/P
  17. '      #3    PSF file O/P
  18. '-----------------------------------------------------------------------------
  19. CONST TRUE = 1, YES = 1, SETFLAG = 1
  20. CONST FALSE = 0, NO = 0, RESETFLAG = 0
  21. '-----------------------------------------------------------------------------
  22. TYPE Psfparamtype
  23.     Index AS INTEGER
  24.     Label AS STRING * 24
  25.     Units AS STRING * 5
  26.     Lower AS SINGLE
  27.     Upper AS SINGLE
  28. TYPE Psfparamsttype ' String-only version for file reading
  29.     Index AS STRING * 4
  30.     Label AS STRING * 24
  31.     Units AS STRING * 5
  32.     Lower AS STRING * 9
  33.     Upper AS STRING * 9
  34. '-----------------------------------------------------------------------------
  35. DIM Psf.numpars(3) AS INTEGER, Psf.setlabel(3) AS STRING * 20
  36. DIM Psfset(3, 1 TO 220) AS Psfparamtype ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  2 of same name
  37. '-----------------------------------------------------------------------------
  38. 'General
  39. COMMON SHARED Softiss AS STRING * 2, Softdate AS STRING * 13, Printerok%
  40. COMMON SHARED Type.number AS STRING * 6, Choose.done%
  41. 'File operations
  42. COMMON SHARED Drive$, Path$, Psf$, Psfoption$, Prev.issue AS STRING * 3
  43. COMMON SHARED Fileunfound%, Fileduplicate%
  44. 'File contents data
  45. COMMON SHARED Psf.typeno AS STRING * 6, Psf.progiss AS STRING * 3
  46. COMMON SHARED Psf.preceding AS STRING * 3, Psf.progdate AS STRING * 10
  47. COMMON SHARED Psf.sourcename AS STRING * 20, Psf.sourceiss AS STRING * 5
  48. COMMON SHARED Psf.sourcedate AS STRING * 10, Psf.amendrefs AS STRING * 80
  49. COMMON SHARED Psf.custype AS STRING * 20, Psf.hitemp AS INTEGER
  50. COMMON SHARED Psf.lotemp AS INTEGER, Psf.sermark AS INTEGER
  51. COMMON SHARED Psf.history AS STRING * 80, Psf.crn AS STRING * 6
  52. COMMON SHARED Psf.eng AS STRING * 10, Psf.comment1 AS STRING * 80
  53. COMMON SHARED Psf.comment2 AS STRING * 80, Psf.comment3 AS STRING * 80
  54. COMMON SHARED Psf.comment4 AS STRING * 80, Psf.comment5 AS STRING * 80
  55. COMMON SHARED Psf.numsets AS INTEGER, Psf.numpars AS INTEGER
  56. COMMON SHARED Psf.numspaces AS INTEGER, Psf.setlabel AS STRING * 20
  57. COMMON SHARED Psfset AS Psfparamtype, Host AS STRING * 20 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  2 of same name
  58. '-----------------------------------------------------------------------------
  59. 'SPECIFICATION EDITOR PROGRAM - SPECEDIT.BAS    S J Oxley
  60. Softiss$ = "5 ": Softdate$ = "- 08/11/04"
  61. 'REVISION RECORD:
  62. '..DATE....ISSUE......................REVISION DETAILS..................
  63. '25/01/99   1     FIRST ISSUE - Archived as SPECED01.BAS + UTILS02.BAS
  64. '22/02/99  (1)    Added choice of Template File in CHOOSE, F9 & F10 functions
  65. '                 on editor P.2 (default indices & copy set)
  66. '13/10/99   2     Added clearance of unused parameter sets when loading a PSF
  67. '                 with fewer parameter sets than the previous PSF.
  68. '                 Cleared Print.tol format bug; Label/Units trailing spaces.
  69. '                 Archived as SPECED02.BAS
  70. '19/10/99  (2)    Added default drive selection using OPTIONH.PSF file.
  71. '14/01/00  (2)    Changed Filename$ to Psf$ when saving edited PSF at end of
  72. '                 EDIT. The global Psf$ is now updated when changing class.
  73. '28/02/00  (2)    Removal of F7 option.
  74. '04/06/03   3     Default drive and paths set to T and \TEST\SPECS.
  75. '02/09/03   4     Index as STRING * 3 changed to * 4.
  76. '                 Changed to allow for index>100 " 100" is 4 CHRs.
  77. '                 Changed default drive and paths back to C and \BLP\SPECS.
  78. '07/11/04   5     Changed DIM Psfset(3,1 TO 200) to 220 to get more parameters.
  79. '-----------------------------------------------------------------------------
  80. OPEN "LPT1" FOR OUTPUT AS #1
  81. ON ERROR GOTO Errhandler
  82. CALL Show.bars
  83. CLS 2
  84. CALL Init.vars
  85. Stay% = YES
  86. WHILE Stay% = YES
  87.     ON KEY(1) GOSUB Callchoose
  88.     ON KEY(2) GOSUB Calledit
  89.     ON KEY(3) GOSUB Calltolerance
  90.     ON KEY(4) GOSUB Callhistory
  91.     ON KEY(8) GOSUB Quit
  92.     LOCATE 2
  93.     CALL Show.bars
  94.     CLS 2
  95.     LOCATE 3, 28: PRINT "MAIN MENU"
  96.     LOCATE 4, 28: PRINT "========="
  97.     LOCATE 7, 28: PRINT "F1. CHOOSE    ";: COLOR 7: PRINT "  - Set directory, file & options": COLOR 6: IF Choose.done% = YES THEN COLOR 15
  98.     LOCATE 8, 28: PRINT "F2. EDIT      ";: COLOR 7: PRINT "  - Edit spec data": COLOR 6: IF Choose.done% = YES THEN COLOR 15
  99.     LOCATE 9, 28: PRINT "F3. TOLERANCE ";: COLOR 7: PRINT "  - View / print tolerances": COLOR 6: IF Choose.done% = YES AND Psfoption$ = "CURRENT" THEN COLOR 15
  100.     LOCATE 10, 28: PRINT "F4. HISTORY   ";: COLOR 7: PRINT "  - View / print history": COLOR 11
  101.     LOCATE 12, 28: PRINT "F8. QUIT      ";: COLOR 7: PRINT "  - Exit": COLOR 15
  102.     FOR S = 1 TO 4
  103.         KEY(S) ON
  104.     NEXT S
  105.     KEY(8) ON
  106.     Continue% = NO
  107.     DO
  108.         DO
  109.             IF Continue% = YES THEN EXIT DO
  110.         LOOP WHILE INKEY$ = ""
  111.         IF Continue% = YES THEN EXIT DO
  112.     LOOP
  113. VIEW PRINT 1 TO 25: COLOR 15, 0
  114. CLS 2
  115. '-----------------------------------------------------------------------------
  116. Keysoff: 'De-activate main menu softkeys
  117. FOR S = 1 TO 4
  118.     KEY(S) OFF
  119. KEY(8) OFF
  120. Callchoose: GOSUB Keysoff: CALL CHOOSE: Continue% = YES: RETURN
  121. Calledit: GOSUB Keysoff: CALL EDIT: Continue% = YES: RETURN
  122. Calltolerance: GOSUB Keysoff: CALL TOLERANCE: Continue% = YES: RETURN
  123. Callhistory: GOSUB Keysoff: CALL HISTORY: Continue% = YES: RETURN
  124. Quit: GOSUB Keysoff: Stay% = NO: Continue% = YES: RETURN
  125. Errhandler: '------------------------------------------------------------------
  126.     CASE 25, 27
  127.         SOUND 1000, 10
  128.         CALL State("PRINTER NOT READY - Check paper loaded & on-line, then press any key.")
  129.     CASE 53, 64, 76
  130.         Fileunfound% = TRUE
  131.         RESUME NEXT
  132.     CASE 58
  133.         Fileduplicate% = TRUE
  134.         RESUME NEXT
  135.     CASE 61, 72
  136.         SOUND 1500, 5
  137.         CALL State("DISK FULL OR BAD - Replace disk, then press any key.")
  138.     CASE 71
  139.         SOUND 1500, 5
  140.         CALL State("DISK WRITE-PROTECTED - Replace or unprotect disk, then press any key.")
  141.     CASE ELSE
  142.         'SOUND 800, 15
  143.         Message$ = "ERROR NUMBER " + STR$(ERR)
  144.         CALL State(Message$)
  145. CALL Waitkey
  146. CALL State(SPACE$(80))
  147. IF (ERR = 25 OR ERR = 27) THEN
  148.     IF Ask%("Do you want to ABANDON PRINT") = YES THEN
  149.         Printerok% = NO
  150.         RESUME NEXT
  151.     END IF
  152.  
  153. DEFSNG A-Z
  154. SUB CHOOSE
  155.     CALL Edit.setup
  156.     Pathname$ = Drive$ + ":" + Path$ + Psf$
  157.     Fileunfound% = RESETFLAG
  158.     OPEN Pathname$ FOR INPUT AS #2
  159.     IF Fileunfound% = NO THEN
  160.         CALL Read.psf
  161.         CLOSE #2
  162.         Choose.done% = YES
  163.     ELSE
  164.         IF Psfoption$ = "PREVIOUS" THEN
  165.             PRINT "FAILED TO FIND PREVIOUS PSF "; Pathname$; ". Press any key."
  166.             CALL Waitkey
  167.         ELSEIF Ask%("This PSF does not exist. Do you want to CREATE NEW PSF") = YES THEN
  168.             State ("Just press ENTER FOR DEFAULT - C:\BLP\SPECS\SPECEDIT.PSF")
  169.             LOCATE 23: LINE INPUT ; "Enter TEMPLATE FILE pathname - "; Entry$
  170.             IF Entry$ = "" THEN
  171.                 Pathname$ = "C:\BLP\SPECS\SPECEDIT.PSF"
  172.             ELSE
  173.                 Pathname$ = UCASE$(LTRIM$(RTRIM$(Entry$)))
  174.             END IF
  175.             Fileunfound% = RESETFLAG
  176.             OPEN Pathname$ FOR INPUT AS #2
  177.             IF Fileunfound% = NO THEN
  178.                 CALL Read.psf
  179.                 CLOSE #2
  180.                 Psf.typeno$ = "******"
  181.                 Psf.preceding$ = "*"
  182.                 Choose.done% = YES
  183.             ELSE
  184.                 State ("Could not find " + Pathname$ + " Press any key.")
  185.                 Waitkey
  186.             END IF
  187.         END IF
  188.     END IF
  189.  
  190. SUB EDIT
  191.     IF Choose.done% = NO THEN
  192.         SOUND 300, 4
  193.         CALL State("Working file not specified yet; select CHOOSE first. Press any key.")
  194.         CALL Waitkey
  195.         EXIT SUB
  196.     END IF
  197.     CLS 2
  198.     Issue.raised% = NO
  199.     IF Psfoption$ = "CURRENT" THEN
  200.         IF Psf.typeno$ = "******" THEN 'New PSF
  201.             Valid% = NO
  202.             WHILE Valid% = NO
  203.                 CALL State("The issue must be a valid DOS filename extension.")
  204.                 LOCATE 23, 1: PRINT SPACE$(80);
  205.                 LOCATE 23, 1: LINE INPUT "Enter the FIRST ISSUE (up to 3 characters), or ENTER for A - "; New.iss$
  206.                 IF New.iss$ = "" THEN New.iss$ = "A"
  207.                 New.iss$ = LEFT$(New.iss$, 3)
  208.                 IF Dosvalid%(New.iss$) = YES THEN
  209.                     Valid% = YES
  210.                 ELSE
  211.                     SOUND 300, 4
  212.                 END IF
  213.             WEND
  214.             Psf.progiss$ = New.iss$
  215.             Psf.preceding$ = "*"
  216.         ELSE
  217.             Stay% = YES
  218.             WHILE Stay% = YES
  219.                 CALL State("If you up-issue, the loaded CURRENT PSF is first archived as a PREVIOUS PSF.")
  220.                 IF Ask%("Are you CHANGING THE ISSUE of the test program & PSF") = YES THEN
  221.                     Valid% = NO
  222.                     WHILE Valid% = NO
  223.                         CALL State("Current issue is " + Psf.progiss$ + ". The issue must be a valid DOS filename extension.")
  224.                         LOCATE 23, 1: PRINT SPACE$(80);
  225.                         LOCATE 23, 1: LINE INPUT "Enter the NEW ISSUE (up to 3 characters): "; New.iss$
  226.                         New.iss$ = LEFT$(New.iss$, 3)
  227.                         IF Dosvalid%(New.iss$) = YES THEN
  228.                             Valid% = YES
  229.                         ELSE
  230.                             SOUND 300, 4
  231.                         END IF
  232.                     WEND
  233.                     CALL State("About to change issue from " + Psf.progiss$ + " to " + New.iss$)
  234.                     IF Ask%("Are you sure you want to CHANGE ISSUE NOW") = YES THEN
  235.                         Filename$ = TType.number$ + "P." + Psf.progiss$
  236.                         OPEN Drive$ + ":" + Path$ + Filename$ FOR OUTPUT AS #3
  237.                         CALL Write.psf
  238.                         CLOSE #3
  239.                         Issue.raised% = YES
  240.                         Psf.preceding$ = Psf.progiss$
  241.                         Psf.progiss$ = New.iss$
  242.                         Stay% = NO
  243.                     END IF
  244.                 ELSE
  245.                     Stay% = NO
  246.                 END IF
  247.             WEND
  248.         END IF
  249.     END IF
  250.     CALL Show.bars
  251.     COLOR , 4
  252.     Pageno% = 1
  253.     Stay% = YES
  254.     WHILE Stay% = YES
  255.         SELECT CASE Pageno%
  256.             CASE 0
  257.                 Stay% = NO
  258.             CASE 1
  259.                 CALL Edit.head1(Pageno%)
  260.                 Edit.set% = 0: Edit.line% = 1: Copy.set% = 1
  261.             CASE 2
  262.                 CALL Edit.head2(Pageno%, Edit.set%, Edit.line%, Copy.set%)
  263.             CASE 3
  264.                 CALL Edit.param(Pageno%, Edit.set%, Edit.line%)
  265.         END SELECT
  266.     WEND
  267.     CLS 2
  268.     Save.file% = YES
  269.     IF Issue.raised% = NO THEN
  270.         CALL State("You can either save the edited PSF or quit without saving & lose any edits.")
  271.         IF Psfoption$ = "PREVIOUS" THEN
  272.             Question$ = "Do you wish to SAVE THE EDITED PREVIOUS PSF AS HYPOTHETICAL"
  273.         ELSE
  274.             Question$ = "Do you wish to SAVE THE EDITED PSF"
  275.         END IF
  276.         IF Ask%(Question$) = NO THEN
  277.             Save.file% = NO
  278.         ELSE
  279.             IF Psfoption$ = "PREVIOUS" THEN Psfoption$ = "HYPOTHETICAL"
  280.             IF Psfoption$ = "CURRENT" THEN
  281.                 CALL State("You can either save as CURRENT PSF (same issue) or convert to HYPOTHETICAL.")
  282.                 IF Ask("Do you wish to SAVE AS CURRENT PSF") = NO THEN Psfoption$ = "HYPOTHETICAL"
  283.             END IF
  284.         END IF
  285.     END IF
  286.     IF Save.file% = YES THEN
  287.         Psf$ = TType.number$ + LEFT$(Psfoption$, 1) + ".PSF"
  288.         OPEN Drive$ + ":" + Path$ + Psf$ FOR OUTPUT AS #3
  289.         CALL Write.psf
  290.         CLOSE #3
  291.     END IF
  292.  
  293. SUB Edit.head1 (Pageno%)
  294.     'Move cursor around first header screen and edit data
  295.     STATIC Hitempst AS STRING * 3
  296.     STATIC Lotempst AS STRING * 3
  297.     STATIC Sermarkst AS STRING * 1
  298.     Lineno% = 4
  299.     Stay% = YES
  300.     WHILE Stay% = YES
  301.         CALL Show.head1
  302.         IF Lineno% = 12 OR Lineno% = 18 THEN
  303.             Colno% = 1
  304.         ELSE
  305.             Colno% = 30
  306.         END IF
  307.         LOCATE Lineno%, Colno%
  308.         SELECT CASE Lineno%
  309.             CASE 4
  310.                 CALL Line.edit(Psf.typeno$, 6, Exit.code%)
  311.             CASE 7
  312.                 CALL Line.edit(Psf.progdate$, 10, Exit.code%)
  313.             CASE 8
  314.                 CALL Line.edit(Psf.sourcename$, 20, Exit.code%)
  315.             CASE 9
  316.                 CALL Line.edit(Psf.sourceiss$, 5, Exit.code%)
  317.             CASE 10
  318.                 CALL Line.edit(Psf.sourcedate$, 10, Exit.code%)
  319.             CASE 12
  320.                 CALL Line.edit(Psf.amendrefs$, 80, Exit.code%)
  321.             CASE 13
  322.                 CALL Line.edit(Psf.custype$, 20, Exit.code%)
  323.             CASE 14
  324.                 Hitempst$ = LTRIM$(STR$(Psf.hitemp%))
  325.                 CALL Line.edit(Hitempst$, 3, Exit.code%)
  326.                 Entry% = VAL(Hitempst$)
  327.                 IF Entry% = 999 THEN
  328.                     Psf.hitemp% = Entry%
  329.                 ELSE
  330.                     IF Checkint%(Entry%, 23, 200) = YES THEN Psf.hitemp% = Entry%
  331.                 END IF
  332.             CASE 15
  333.                 Lotempst$ = LTRIM$(STR$(Psf.lotemp%))
  334.                 CALL Line.edit(Lotempst$, 3, Exit.code%)
  335.                 Entry% = VAL(Lotempst$)
  336.                 IF Entry% = 999 THEN
  337.                     Psf.lotemp% = Entry%
  338.                 ELSE
  339.                     IF Checkint%(Entry%, -99, 23) = YES THEN Psf.lotemp% = Entry%
  340.                 END IF
  341.             CASE 16
  342.                 Sermarkst$ = LTRIM$(STR$(Psf.sermark%))
  343.                 CALL Line.edit(Sermarkst$, 1, Exit.code%)
  344.                 Entry% = VAL(Sermarkst$)
  345.                 IF Checkint%(Entry%, 0, 1) = YES THEN Psf.sermark% = Entry%
  346.             CASE 18
  347.                 CALL Line.edit(Psf.history$, 80, Exit.code%)
  348.             CASE 19
  349.                 CALL Line.edit(Psf.crn$, 6, Exit.code%)
  350.             CASE 20
  351.                 CALL Line.edit(Psf.eng$, 10, Exit.code%)
  352.         END SELECT
  353.         SELECT CASE Exit.code%
  354.             CASE 9, 80, 13 'TAB, Down, ENTER
  355.                 SELECT CASE Lineno%
  356.                     CASE 4
  357.                         Lineno% = Lineno% + 3
  358.                     CASE 10, 16
  359.                         Lineno% = Lineno% + 2
  360.                     CASE 20
  361.                     CASE ELSE
  362.                         Lineno% = Lineno% + 1
  363.                 END SELECT
  364.             CASE 15, 72 'Shift TAB, Up
  365.                 SELECT CASE Lineno%
  366.                     CASE 4
  367.                     CASE 7
  368.                         Lineno% = Lineno% - 3
  369.                     CASE 12, 18
  370.                         Lineno% = Lineno% - 2
  371.                     CASE ELSE
  372.                         Lineno% = Lineno% - 1
  373.                 END SELECT
  374.             CASE 71 'Home
  375.                 Lineno% = 4
  376.             CASE 79 'End
  377.                 Lineno% = 20
  378.             CASE 81 'Pg Down
  379.                 Pageno% = 2
  380.                 Stay% = NO
  381.             CASE 73 'Pg Up
  382.             CASE 27 'ESC
  383.                 Pageno% = 0
  384.                 Stay% = NO
  385.         END SELECT
  386.     WEND
  387.  
  388. SUB Edit.head2 (Pageno%, Edit.set%, Edit.line%, Copy.set%)
  389.     'Move cursor around second header screen and edit data
  390.     STATIC Numparsst AS STRING * 3
  391.     STATIC Numspacesst AS STRING * 3
  392.     STATIC Setst AS STRING * 1
  393.     STATIC Linest AS STRING * 3
  394.     STATIC Copysetst AS STRING * 1
  395.     Lineno% = 5
  396.     Stay% = YES
  397.     WHILE Stay% = YES
  398.         CALL Show.head2(Edit.set%, Edit.line%, Copy.set%)
  399.         IF Lineno% < 10 THEN
  400.             Colno% = 1
  401.         ELSE
  402.             Colno% = 30
  403.         END IF
  404.         LOCATE Lineno%, Colno%
  405.         SELECT CASE Lineno%
  406.             CASE 5
  407.                 CALL Line.edit(Psf.comment1$, 80, Exit.code%)
  408.             CASE 6
  409.                 CALL Line.edit(Psf.comment2$, 80, Exit.code%)
  410.             CASE 7
  411.                 CALL Line.edit(Psf.comment3$, 80, Exit.code%)
  412.             CASE 8
  413.                 CALL Line.edit(Psf.comment4$, 80, Exit.code%)
  414.             CASE 9
  415.                 CALL Line.edit(Psf.comment5$, 80, Exit.code%)
  416.             CASE 11
  417.                 CALL Line.edit(Psf.setlabel$(0), 20, Exit.code%)
  418.             CASE 12
  419.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(0)))
  420.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  421.                 Entry% = VAL(Numparsst$)
  422.                 IF Checkint%(Entry%, 1, Psf.numspaces%) = YES THEN Psf.numpars%(0) = Entry%
  423.             CASE 13
  424.                 CALL Line.edit(Psf.setlabel$(1), 20, Exit.code%)
  425.             CASE 14
  426.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(1)))
  427.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  428.                 Entry% = VAL(Numparsst$)
  429.                 IF Checkint%(Entry%, 0, Psf.numspaces%) = YES THEN Psf.numpars%(1) = Entry%
  430.             CASE 15
  431.                 CALL Line.edit(Psf.setlabel$(2), 20, Exit.code%)
  432.             CASE 16
  433.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(2)))
  434.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  435.                 Entry% = VAL(Numparsst$)
  436.                 IF Checkint%(Entry%, 0, Psf.numspaces%) = YES THEN Psf.numpars%(2) = Entry%
  437.             CASE 17
  438.                 CALL Line.edit(Psf.setlabel$(3), 20, Exit.code%)
  439.             CASE 18
  440.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(3)))
  441.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  442.                 Entry% = VAL(Numparsst$)
  443.                 IF Checkint%(Entry%, 0, Psf.numspaces%) = YES THEN Psf.numpars%(3) = Entry%
  444.             CASE 19
  445.                 Numspacesst$ = LTRIM$(STR$(Psf.numspaces%))
  446.                 CALL Line.edit(Numspacesst$, 3, Exit.code%)
  447.                 Entry% = VAL(Numspacesst$)
  448.                 IF Checkint%(Entry%, 1, 220) = YES THEN Psf.numspaces% = Entry%
  449.             CASE 21
  450.                 Setst$ = LTRIM$(STR$(Edit.set%))
  451.                 CALL Line.edit(Setst$, 1, Exit.code%)
  452.                 Entry% = VAL(Setst$)
  453.                 IF Checkint%(Entry%, 0, Psf.numsets%) = YES THEN Edit.set% = Entry%
  454.             CASE 22
  455.                 Linest$ = LTRIM$(STR$(Edit.line%))
  456.                 CALL Line.edit(Linest$, 3, Exit.code%)
  457.                 Entry% = VAL(Linest$)
  458.                 IF Checkint%(Entry%, 1, 220) = YES THEN Edit.line% = Entry%
  459.             CASE 23
  460.                 Copysetst$ = LTRIM$(STR$(Copy.set%))
  461.                 CALL Line.edit(Copysetst$, 1, Exit.code%)
  462.                 Entry% = VAL(Copysetst$)
  463.                 IF Checkint%(Entry%, 0, Psf.numsets%) = YES THEN Copy.set% = Entry%
  464.         END SELECT
  465.         SELECT CASE Exit.code%
  466.             CASE 9, 80, 13 'TAB, Down, ENTER
  467.                 SELECT CASE Lineno%
  468.                     CASE 9, 19
  469.                         Lineno% = Lineno% + 2
  470.                     CASE 14
  471.                         Lineno% = 15: IF Psf.numpars%(1) = 0 THEN Lineno% = 19
  472.                     CASE 16
  473.                         Lineno% = 17: IF Psf.numpars%(2) = 0 THEN Lineno% = 19
  474.                     CASE 23
  475.                     CASE ELSE
  476.                         Lineno% = Lineno% + 1
  477.                 END SELECT
  478.             CASE 15, 72 'Shift TAB, Up
  479.                 SELECT CASE Lineno%
  480.                     CASE 5
  481.                     CASE 11, 21
  482.                         Lineno% = Lineno% - 2
  483.                     CASE 19
  484.                         IF Psf.numpars%(1) = 0 THEN
  485.                             Lineno% = 14
  486.                         ELSEIF Psf.numpars%(2) = 0 THEN
  487.                             Lineno% = 16
  488.                         ELSE
  489.                             Lineno% = 18
  490.                         END IF
  491.                     CASE ELSE
  492.                         Lineno% = Lineno% - 1
  493.                 END SELECT
  494.             CASE 71 'Home
  495.                 Lineno% = 5
  496.             CASE 79 'End
  497.                 Lineno% = 23
  498.             CASE 73 'Pg Up
  499.                 Pageno% = 1
  500.                 Stay% = NO
  501.             CASE 81 'Pg Down
  502.                 Pageno% = 3
  503.                 Stay% = NO
  504.             CASE 27 'ESC
  505.                 Pageno% = 0
  506.                 Stay% = NO
  507.             CASE 67 'F9
  508.                 Setst$ = LTRIM$(STR$(Edit.set%))
  509.                 IF Ask("Are you sure you want to MAKE INDICES = LINE NUMBERS in Set " + Setst$) = YES THEN
  510.                     FOR Line.number% = 1 TO Psf.numpars%(Edit.set%)
  511.         Psfset(Edit.set%, Line.number%).Index = Line.number%
  512.       NEXT Line.number%
  513.     END IF
  514.     COLOR , 4
  515.   CASE 68  'F10
  516.     IF Copy.set% <> Edit.set% THEN
  517.       Setst$ = LTRIM$(STR$(Edit.set%))
  518.       Copysetst$ = LTRIM$(STR$(Copy.set%))
  519.       IF Ask("Are you sure you want to COPY SET " + Setst$ + " TO SET " + Copysetst$) = YES THEN
  520.         Psf.numpars%(Copy.set%) = Psf.numpars%(Edit.set%)
  521.         FOR Line.number% = 1 TO Psf.numpars%(Edit.set%)
  522.           Psfset(Copy.set%, Line.number%).Index = Psfset(Edit.set%, Line.number%).Index
  523.           Psfset(Copy.set%, Line.number%).Label = Psfset(Edit.set%, Line.number%).Label
  524.           Psfset(Copy.set%, Line.number%).Units = Psfset(Edit.set%, Line.number%).Units
  525.           Psfset(Copy.set%, Line.number%).Lower = Psfset(Edit.set%, Line.number%).Lower
  526.           Psfset(Copy.set%, Line.number%).Upper = Psfset(Edit.set%, Line.number%).Upper
  527.         NEXT Line.number%
  528.       END IF
  529.     END IF
  530.     COLOR , 4
  531.   IF Psf.numpars%(1) = 0 THEN
  532.     Psf.numpars%(2) = 0
  533.     Psf.numpars%(3) = 0
  534.     Psf.numsets% = 1
  535.   ELSEIF Psf.numpars%(2) = 0 THEN
  536.     Psf.numpars%(3) = 0
  537.     Psf.numsets% = 2
  538.   ELSEIF Psf.numpars%(3) = 0 THEN
  539.     Psf.numsets% = 3
  540.   ELSE
  541.     Psf.numsets% = 4
  542.   END IF
  543.   IF Edit.set% > Psf.numsets% THEN Edit.set% = Psf.numsets%
  544.   IF Copy.set% > Psf.numsets% THEN Copy.set% = Psf.numsets%
  545. IF Edit.set% > Psf.numsets% - 1 THEN Edit.set% = Psf.numsets% - 1
  546.  
  547. SUB Edit.param (Pageno%, Edit.set%, Edit.line%)
  548. 'Scroll and edit parameter data
  549. STATIC Indexst AS STRING * 3
  550. STATIC Lowerst AS STRING * 10
  551. STATIC Upperst AS STRING * 10
  552. Colno% = 7
  553. Stay% = YES
  554. IF Psf.numpars%(Edit.set%) = 0 THEN
  555.   Pageno% = 2
  556.   Stay% = NO
  557. WHILE Stay% = YES
  558.   CALL Show.param(Edit.set%, Edit.line%)
  559.   LOCATE 14, Colno%
  560.   SELECT CASE Colno%
  561.   CASE 7
  562.     Indexst$ = LTRIM$(STR$(Psfset(Edit.set%, Edit.line%).Index))
  563.     CALL Line.edit(Indexst$, 3, Exit.code%)
  564.     Entry% = VAL(Indexst$)
  565.     Unique% = YES
  566.     FOR Line.number% = 1 TO Psf.numpars%(Edit.set%)
  567.       IF Line.number% <> Edit.line% THEN
  568.         IF Psfset(Edit.set%, Line.number%).Index = Entry% THEN Unique% = NO
  569.       END IF
  570.     NEXT Line.number%
  571.     IF Unique% = YES THEN
  572.       Psfset(Edit.set%, Edit.line%).Index = Entry%
  573.     ELSE
  574.       SOUND 300, 4: COLOR , 4: LOCATE 23, 1: PRINT "INDEX"; Entry%; "ALREADY USED! Indices must be unique within each set. Press any key.";
  575.       CALL Waitkey
  576.       Exit.code% = 0
  577.     END IF
  578.   CASE 13
  579.     CALL Line.edit(Psfset(Edit.set%, Edit.line%).Label, 24, Exit.code%)
  580.   CASE 40
  581.     CALL Line.edit(Psfset(Edit.set%, Edit.line%).Units, 5, Exit.code%)
  582.   CASE 48
  583.     Lowerst$ = LTRIM$(STR$(Psfset(Edit.set%, Edit.line%).Lower))
  584.     CALL Line.edit(Lowerst$, 10, Exit.code%)
  585.     Entry.real! = VAL(Lowerst$)
  586.     IF Entry.real! < -9999.999 THEN Entry.real! = -9999.999
  587.     IF Entry.real! > 9999.999 THEN Entry.real! = 9999.999
  588.     Hilim! = Psfset(Edit.set%, Edit.line%).Upper
  589.     IF Checkreal%(Entry.real!, -9999.999, Hilim!) = YES THEN
  590.       Psfset(Edit.set%, Edit.line%).Lower = Entry.real!
  591.     ELSE
  592.       IF Exit.code% = 9 OR Exit.code% = 13 THEN
  593.         Psfset(Edit.set%, Edit.line%).Lower = Entry.real!
  594.       ELSE
  595.         SOUND 300, 4: COLOR , 4: LOCATE 23, 1: PRINT "LIMITS OUT OF RANGE! (-/+9999.999 and LOWER < UPPER). Press any key.";
  596.         CALL Waitkey
  597.         Exit.code% = 0
  598.       END IF
  599.     END IF
  600.   CASE 61
  601.     Upperst$ = LTRIM$(STR$(Psfset(Edit.set%, Edit.line%).Upper))
  602.     CALL Line.edit(Upperst$, 10, Exit.code%)
  603.     Entry.real! = VAL(Upperst$)
  604.     IF Entry.real! < -9999.999 THEN Entry.real! = -9999.999
  605.     IF Entry.real! > 9999.999 THEN Entry.real! = 9999.999
  606.     Lolim! = Psfset(Edit.set%, Edit.line%).Lower
  607.     IF Checkreal%(Entry.real!, Lolim!, 9999.999) = YES THEN
  608.       Psfset(Edit.set%, Edit.line%).Upper = Entry.real!
  609.     ELSE
  610.       IF Exit.code% = 15 THEN
  611.         Psfset(Edit.set%, Edit.line%).Upper = Entry.real!
  612.       ELSE
  613.         SOUND 300, 4: COLOR , 4: LOCATE 23, 1: PRINT "LIMITS OUT OF RANGE! (-/+9999.999 and LOWER < UPPER). Press any key.";
  614.         CALL Waitkey
  615.         Exit.code% = 0
  616.       END IF
  617.     END IF
  618.   SELECT CASE Exit.code%
  619.   CASE 0
  620.   CASE 9, 13  'TAB, ENTER
  621.     IF Colno% < 13 THEN
  622.       Colno% = 13
  623.     ELSEIF Colno% < 40 THEN
  624.       Colno% = 40
  625.     ELSEIF Colno% < 48 THEN
  626.       Colno% = 48
  627.     ELSEIF Colno% < 61 THEN
  628.       Colno% = 61
  629.     END IF
  630.   CASE 15  'Shift TAB
  631.     IF Colno% >= 61 THEN
  632.       Colno% = 48
  633.     ELSEIF Colno% >= 48 THEN
  634.       Colno% = 40
  635.     ELSEIF Colno% >= 40 THEN
  636.       Colno% = 13
  637.     ELSEIF Colno% >= 13 THEN
  638.       Colno% = 7
  639.     END IF
  640.   CASE 80  'Down
  641.     IF Edit.line% < Psf.numpars%(Edit.set%) THEN Edit.line% = Edit.line% + 1
  642.   CASE 72  'Up
  643.     IF Edit.line% > 1 THEN Edit.line% = Edit.line% - 1
  644.   CASE 71  'Home
  645.     Edit.line% = 1
  646.   CASE 79  'End
  647.     Edit.line% = Psf.numpars%(Edit.set%)
  648.   CASE 67  'F9
  649.     IF Psf.numpars%(Edit.set%) < Psf.numspaces% THEN
  650.       FOR Line.number% = Psf.numpars%(Edit.set%) TO Edit.line% STEP -1
  651.         Psfset(Edit.set%, (Line.number% + 1)).Index = Psfset(Edit.set%, Line.number%).Index
  652.         Psfset(Edit.set%, (Line.number% + 1)).Label = Psfset(Edit.set%, Line.number%).Label
  653.         Psfset(Edit.set%, (Line.number% + 1)).Units = Psfset(Edit.set%, Line.number%).Units
  654.         Psfset(Edit.set%, (Line.number% + 1)).Lower = Psfset(Edit.set%, Line.number%).Lower
  655.         Psfset(Edit.set%, (Line.number% + 1)).Upper = Psfset(Edit.set%, Line.number%).Upper
  656.       NEXT Line.number%
  657.       Psfset(Edit.set%, Edit.line%).Index = 0
  658.       Psfset(Edit.set%, Edit.line%).Label = ""
  659.       Psfset(Edit.set%, Edit.line%).Units = ""
  660.       Psfset(Edit.set%, Edit.line%).Lower = 0
  661.       Psfset(Edit.set%, Edit.line%).Upper = 0
  662.       Psf.numpars%(Edit.set%) = Psf.numpars%(Edit.set%) + 1
  663.     ELSE
  664.       SOUND 300, 4: COLOR , 4: LOCATE 23: PRINT "NO SPACE to insert new parameter! Increase TRF record size first. Press any key.";
  665.       CALL Waitkey
  666.     END IF
  667.   CASE 68  'F10
  668.     IF Ask("Are you sure you want to DELETE THIS LINE") = YES THEN
  669.       IF Edit.line% < Psf.numpars%(Edit.set%) THEN
  670.         FOR Line.number% = Edit.line% + 1 TO Psf.numpars%(Edit.set%)
  671.           Psfset(Edit.set%, (Line.number% - 1)).Index = Psfset(Edit.set%, Line.number%).Index
  672.           Psfset(Edit.set%, (Line.number% - 1)).Label = Psfset(Edit.set%, Line.number%).Label
  673.           Psfset(Edit.set%, (Line.number% - 1)).Units = Psfset(Edit.set%, Line.number%).Units
  674.           Psfset(Edit.set%, (Line.number% - 1)).Lower = Psfset(Edit.set%, Line.number%).Lower
  675.           Psfset(Edit.set%, (Line.number% - 1)).Upper = Psfset(Edit.set%, Line.number%).Upper
  676.         NEXT Line.number%
  677.       END IF
  678.       Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Index = 0
  679.       Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Label = ""
  680.       Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Units = ""
  681.       Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Lower = 0
  682.       Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Upper = 0
  683.       Psf.numpars%(Edit.set%) = Psf.numpars%(Edit.set%) - 1
  684.       IF Psf.numpars%(Edit.set%) = 0 THEN
  685.         Pageno% = 2
  686.         Stay% = NO
  687.       END IF
  688.     END IF
  689.     COLOR , 4
  690.   CASE 73  'Pg Up
  691.     Pageno% = 2
  692.     Stay% = NO
  693.   CASE 81  'Pg Down
  694.   CASE 27  'ESC
  695.     Pageno% = 0
  696.     Stay% = NO
  697.  
  698. SUB Edit.setup
  699. 'Move cursor around setup screen and edit data
  700. Prev.issue$ = "1  "
  701. Lineno% = 9
  702. Stay% = YES
  703. WHILE Stay% = YES
  704.   CALL Show.bars
  705.   CALL Show.setup
  706.   LOCATE Lineno%, 20
  707.   SELECT CASE Lineno%
  708.   CASE 7
  709.     CALL Line.edit(Drive$, 1, Exit.code%)
  710.     Drive$ = UCASE$(LEFT$(Drive$, 1))
  711.   CASE 8
  712.     CALL Line.edit(Path$, 40, Exit.code%)
  713.     Path$ = UCASE$(LTRIM$(RTRIM$(Path$)))
  714.     IF LEFT$(Path$, 1) <> "\" THEN Path$ = "\" + Path$
  715.     IF RIGHT$(Path$, 1) <> "\" THEN Path$ = Path$ + "\"
  716.   CASE 9
  717.     CALL Line.edit(TType.number$, 6, Exit.code%)
  718.   CASE 10
  719.     Option$ = LEFT$(Psfoption$, 1)
  720.     CALL Line.edit(Option$, 1, Exit.code%)
  721.     Option$ = UCASE$(Option$)
  722.     CASE "C"
  723.       Psfoption$ = "CURRENT"
  724.     CASE "P"
  725.       Psfoption$ = "PREVIOUS"
  726.     CASE "H"
  727.       Psfoption$ = "HYPOTHETICAL"
  728.     END SELECT
  729.   CASE 11
  730.     Edit.prev.issue$ = Prev.issue$
  731.     CALL Line.edit(Edit.prev.issue$, 3, Exit.code%)
  732.     IF Dosvalid%(Edit.prev.issue$) = YES THEN Prev.issue$ = Edit.prev.issue$
  733.   SELECT CASE Exit.code%
  734.   CASE 80, 13  'Down, ENTER
  735.     IF Lineno% < 10 THEN Lineno% = Lineno% + 1
  736.     IF Lineno% = 10 AND Psfoption$ = "PREVIOUS" THEN Lineno% = 11
  737.   CASE 72  'Up
  738.     IF Lineno% > 7 THEN Lineno% = Lineno% - 1
  739.   CASE 71  'Home
  740.     Lineno% = 7
  741.   CASE 79  'End
  742.     IF Psfoption$ = "PREVIOUS" THEN
  743.       Lineno% = 11
  744.     ELSE
  745.       Lineno% = 10
  746.     END IF
  747.   CASE 81, 73 'Pg Down, Pg Up
  748.   CASE 27  'ESC
  749.     Stay% = NO
  750. CALL Show.setup
  751.  
  752. SUB Hist.print
  753. 'Print out the History Report entry for the PSF now loaded
  754. IF Plain$(Psf.crn$) <> "NONE" THEN
  755.   Issued$ = ") issued under Change Note No. " + Psf.crn$
  756.   Issued$ = ") not issued."
  757. PRINT #1, Psfoption$; " ("; Psf$; Issued$
  758. PRINT #1, "PROG Iss. "; Psf.progiss$; " - "; Psf.progdate$; "  SPEC "; Psf.sourcename$; " Iss. "; Psf.sourceiss$; " - "; Psf.sourcedate$
  759. IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT #1, Psf.amendrefs$
  760. PRINT #1, Psf.history$
  761.  
  762. SUB Hist.show
  763. 'Display the History Report entry for the PSF now loaded
  764. COLOR 14, 4: PRINT
  765. IF Plain$(Psf.crn$) <> "NONE" THEN
  766.   Issued$ = " issued under Change Note No. " + Psf.crn$
  767.   Issued$ = " not issued."
  768. COLOR 14: PRINT Psfoption$; " ("; Psf$; ")";: COLOR 15: PRINT Issued$
  769. PRINT "PROG Iss. "; Psf.progiss$; " - "; Psf.progdate$; "  SPEC "; Psf.sourcename$; " Iss. "; Psf.sourceiss$; " - "; Psf.sourcedate$
  770. IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT Psf.amendrefs$
  771. PRINT Psf.history$
  772.  
  773. SUB HISTORY
  774. STATIC Lotempst AS STRING * 8
  775. STATIC Hitempst AS STRING * 8
  776. IF Choose.done% = NO THEN
  777.   SOUND 300, 4
  778.   CALL State("Working file not specified yet; select CHOOSE first. Press any key.")
  779.   CALL Waitkey
  780. IF Psfoption$ <> "CURRENT" THEN
  781.   SOUND 300, 4
  782.   CALL State("You can produce a History Report only from a CURRENT PSF . Press any key.")
  783.   CALL Waitkey
  784. Pathname$ = Drive$ + ":" + Path$ + Psf$
  785. Fileunfound% = RESETFLAG
  786. OPEN Pathname$ FOR INPUT AS #2
  787. IF Fileunfound% = NO THEN
  788.   CALL Read.psf
  789.   CLOSE #2
  790. History.complete% = YES
  791. CLS 2
  792. PRINT "HISTORY REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  793. COLOR 15: PRINT STRING$(78, "-")
  794. PRINT "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; "               Dated:"; Psf.progdate$
  795. PRINT "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  796. IF Psf.sermark% = YES THEN
  797.   Sermarked$ = "              Serial Marked"
  798.   Sermarked$ = "              Not Serial Marked"
  799. PRINT "Customer Reference:"; Psf.custype$; Sermarked$
  800. IF Psf.lotemp% = 999 THEN
  801.   Lotempst$ = " N/A    "
  802.   Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  803. IF Psf.hitemp% = 999 THEN
  804.   Hitempst$ = " N/A    "
  805.   Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  806. PRINT "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  807. PRINT STRING$(78, "-")
  808. Line.counter% = 7
  809. CALL Hist.show
  810. Line.counter% = Line.counter% + 5
  811. Psfoption$ = "PREVIOUS"
  812. Preceding.issue% = Dosvalid%(Psf.preceding$)
  813. WHILE Preceding.issue% = YES
  814.   Psf$ = TType.number$ + "P." + Noblanks$(Psf.preceding$)
  815.   Pathname$ = Drive$ + ":" + Path$ + Psf$
  816.   Fileunfound% = RESETFLAG
  817.   OPEN Pathname$ FOR INPUT AS #2
  818.   IF Fileunfound% = NO THEN
  819.     CALL Read.psf
  820.     CLOSE #2
  821.     CALL Hist.show
  822.     Line.counter% = Line.counter% + 5
  823.     Preceding.issue% = Dosvalid%(Psf.preceding$)
  824.     IF Line.counter% > 14 THEN
  825.       CALL State("Press any key to continue."): COLOR 15, 4
  826.       CALL Waitkey
  827.       Line.counter% = 0
  828.       CLS 2: LOCATE 3
  829.     END IF
  830.   ELSE
  831.     PRINT: COLOR 14
  832.     PRINT "HISTORY REPORT MAY BE INCOMPLETE: "; Psf$; " was referenced but not found."
  833.     COLOR 15
  834.     Preceding.issue% = NO
  835.     History.complete% = NO
  836.   END IF
  837. IF History.complete% = YES THEN
  838.   PRINT: COLOR 14
  839.   PRINT "HISTORY REPORT COMPLETE."
  840.   COLOR 15
  841. Psfoption$ = "CURRENT"
  842. Psf$ = TType.number$ + "C.PSF"
  843. Pathname$ = Drive$ + ":" + Path$ + Psf$
  844. OPEN Pathname$ FOR INPUT AS #2
  845. IF Ask%("Do you want to PRINT THIS REPORT") = YES THEN
  846.   History.complete% = YES
  847.   PRINT #1, "HISTORY REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  848.   PRINT #1, STRING$(78, "-")
  849.   PRINT #1, "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; "               Dated:"; Psf.progdate$
  850.   PRINT #1, "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  851.   IF Psf.sermark% = YES THEN
  852.     Sermarked$ = "              Serial Marked"
  853.   ELSE
  854.     Sermarked$ = "              Not Serial Marked"
  855.   END IF
  856.   PRINT #1, "Customer Reference:"; Psf.custype$; Sermarked$
  857.   IF Psf.lotemp% = 999 THEN
  858.     Lotempst$ = " N/A    "
  859.   ELSE
  860.     Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  861.   END IF
  862.   IF Psf.hitemp% = 999 THEN
  863.     Hitempst$ = " N/A    "
  864.   ELSE
  865.     Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  866.   END IF
  867.   PRINT #1, "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  868.   PRINT #1, STRING$(78, "-")
  869.   CALL Hist.print
  870.   Line.counter% = 1
  871.   Psfoption$ = "PREVIOUS"
  872.   Preceding.issue% = Dosvalid%(Psf.preceding$)
  873.   WHILE Preceding.issue% = YES
  874.     Psf$ = TType.number$ + "P." + Noblanks$(Psf.preceding$)
  875.     Pathname$ = Drive$ + ":" + Path$ + Psf$
  876.     Fileunfound% = RESETFLAG
  877.     OPEN Pathname$ FOR INPUT AS #2
  878.     IF Fileunfound% = NO THEN
  879.       CALL Read.psf
  880.       CLOSE #2
  881.       CALL Hist.print
  882.       Line.counter% = Line.counter% + 1
  883.       Preceding.issue% = Dosvalid%(Psf.preceding$)
  884.     ELSE
  885.       PRINT #1,PRINT
  886.       PRINT #1, "HISTORY REPORT MAY BE INCOMPLETE: "; Psf$; " was referenced but not found."
  887.       Preceding.issue% = NO
  888.       History.complete% = NO
  889.     END IF
  890.   WEND
  891.   IF History.complete% = YES THEN
  892.     PRINT #1,PRINT
  893.     PRINT #1, "HISTORY REPORT COMPLETE."
  894.   END IF
  895.   PRINT #1, CHR$(12)
  896.   Psfoption$ = "CURRENT"          ' Restore current file
  897.   Psf$ = TType.number$ + "C.PSF"
  898.   Pathname$ = Drive$ + ":" + Path$ + Psf$
  899.   OPEN Pathname$ FOR INPUT AS #2
  900.   CALL Read.psf
  901.   CLOSE #2
  902.  
  903. SUB Init.vars
  904. 'Initialise all shared variables
  905.  
  906. Fileunfound% = RESETFLAG
  907. OPEN "C:\BLP\SPECS\OPTIONH.PSF" FOR INPUT AS #2
  908. IF Fileunfound% = NO THEN
  909.   CALL Read.psf
  910.   CLOSE #2
  911.   Host$ = Psf.custype$
  912.   Drive$ = UCASE$(LEFT$(Psf.progdate$, 1))
  913.   Host$ = ""
  914.   Drive$ = "C"
  915.  
  916. Printerok% = YES
  917. TType.number$ = "~~~~~~"
  918. Choose.done% = NO
  919. Path$ = "\BLP\SPECS\"
  920. Psf$ = "SPECEDIT.PSF"
  921. Psfoption$ = "CURRENT"
  922. Fileunfound% = FALSE
  923. Fileduplicate% = FALSE
  924.  
  925.  
  926. SUB Line.edit (Edit.string$, Field.size%, Exit.code%)
  927. 'Line editor - processes left & right arrow, delete and insert keys to edit
  928. 'Edit.string$, which is padded if necessary to a length of Field.size%.
  929. 'Exit.code% is ASCII code of key used to quit line edit:- TAB, Shift+TAB, Up,
  930. 'Down, ENTER, Pg Up, Pg Down, ESC, Home, End, F9, F10
  931. COLOR , 0
  932. IF Field.size% < LEN(Edit.string$) THEN
  933.   PRINT "Line.edit: Edit string exceeds field size": STOP
  934. Start.char% = POS(0)
  935. End.char% = Start.char% + Field.size% - 1
  936. Char% = Start.char%
  937. Insert.mode% = NO: LOCATE , , , 0, 7
  938. Stay% = YES
  939. WHILE Stay% = YES
  940.   Spaces% = Field.size% - LEN(Edit.string$)
  941.   Edit.string$ = Edit.string$ + STRING$(Spaces%, " ")
  942.   LOCATE , Start.char%: PRINT Edit.string$;: LOCATE , Char%, 1
  943.   Chars.left% = Char% - Start.char%
  944.   Chars.right% = Start.char% + LEN(Edit.string$) - Char% - 1: IF Chars.right% < 0 THEN Chars.right% = 0
  945.   Left.part$ = LEFT$(Edit.string$, Chars.left%)
  946.   Right.part$ = RIGHT$(Edit.string$, Chars.right%)
  947.   Incl.right.part$ = RIGHT$(Edit.string$, Chars.right% + 1)
  948.   DO
  949.     K$ = INKEY$
  950.   LOOP WHILE K$ <> ""  'Empty keyboard buffer
  951.   DO
  952.     K$ = INKEY$
  953.   LOOP WHILE K$ = ""
  954.   Keycode$ = RIGHT$(K$, 1)
  955.   Ascii% = ASC(Keycode$)
  956.   IF LEN(K$) = 2 THEN Ascii% = Ascii% * 100' EXTENDED CODE
  957.   SELECT CASE Ascii%
  958.   CASE 8, 7500 'LEFT
  959.     IF Char% > Start.char% THEN Char% = Char% - 1: LOCATE , Char%
  960.   CASE 7700  'RIGHT
  961.     IF Char% < End.char% THEN Char% = Char% + 1: LOCATE , Char%
  962.   CASE 8200  'INSERT
  963.     IF Insert.mode% = NO THEN
  964.       Insert.mode% = YES: LOCATE , , , 7, 7
  965.     ELSE
  966.       Insert.mode% = NO: LOCATE , , , 0, 7
  967.     END IF
  968.   CASE 8300  'DELETE
  969.     Edit.string$ = Left.part$ + Right.part$
  970.   CASE 9, 1500, 7200, 8000, 13, 7300, 8100, 27, 7100, 7900, 6700, 6800 'EXIT CODES
  971.     Exit.code% = Ascii%: IF Exit.code% > 255 THEN Exit.code% = Exit.code% / 100
  972.     LOCATE , , 0, 7, 7
  973.     Stay% = NO
  974.   CASE ELSE  'CHARACTER
  975.     IF Ascii% > 31 AND Ascii% < 128 THEN
  976.       IF Insert.mode% = YES THEN
  977.         Edit.string$ = Left.part$ + CHR$(Ascii%) + LEFT$(Incl.right.part$, Chars.right%)
  978.       ELSE  'Overwrite
  979.         Edit.string$ = Left.part$ + CHR$(Ascii%) + Right.part$
  980.       END IF
  981.     IF Char% < End.char% THEN Char% = Char% + 1: LOCATE , Char%
  982.     END IF
  983. COLOR , 4
  984.  
  985. SUB Read.psf
  986. 'Enter all data from PSF file, which has already been opened as #2
  987. DIM Psfparamst AS Psfparamsttype
  988. LINE INPUT #2, Psf.typeno$: LINE INPUT #2, Psf.progiss$
  989. LINE INPUT #2, Psf.preceding$: LINE INPUT #2, Psf.progdate$
  990. LINE INPUT #2, Psf.sourcename$: LINE INPUT #2, Psf.sourceiss$
  991. LINE INPUT #2, Psf.sourcedate$: LINE INPUT #2, Psf.amendrefs$
  992. LINE INPUT #2, Psf.custype$: LINE INPUT #2, Psf.hitempst$
  993. LINE INPUT #2, Psf.lotempst$: LINE INPUT #2, Psf.sermarkst$
  994. LINE INPUT #2, Psf.history$: LINE INPUT #2, Psf.crn$
  995. LINE INPUT #2, Psf.eng$: LINE INPUT #2, Psf.comment1$
  996. LINE INPUT #2, Psf.comment2$: LINE INPUT #2, Psf.comment3$
  997. LINE INPUT #2, Psf.comment4$: LINE INPUT #2, Psf.comment5$
  998. LINE INPUT #2, Psf.numsetsst$
  999. Psf.numsets% = VAL(Psf.numsetsst$)
  1000. FOR Setno% = 0 TO Psf.numsets% - 1
  1001.   LINE INPUT #2, Psf.numparsst$
  1002.   Psf.numpars%(Setno%) = VAL(Psf.numparsst$)
  1003. NEXT Setno%
  1004. FOR Setno% = Psf.numsets% TO 3  'Clear unused parameter sets
  1005.   Psf.numpars%(Setno%) = 0
  1006. NEXT Setno%
  1007. LINE INPUT #2, Psf.numspacesst$
  1008. FOR Setno% = 0 TO Psf.numsets% - 1
  1009.   LINE INPUT #2, Psf.setlabel$(Setno%)
  1010. NEXT Setno%
  1011. FOR Setno% = Psf.numsets% TO 3  'Clear unused parameter sets
  1012.   Psf.setlabel$(Setno%) = ""
  1013. NEXT Setno%
  1014. FOR Setno% = 0 TO Psf.numsets% - 1
  1015.   FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1016.     LINE INPUT #2, Psfparamst.Index
  1017.     LINE INPUT #2, Psfparamst.Label
  1018.     LINE INPUT #2, Psfparamst.Units
  1019.     LINE INPUT #2, Psfparamst.Lower
  1020.     LINE INPUT #2, Psfparamst.Upper
  1021.     Psfset(Setno%, Paramno%).Index = VAL(Psfparamst.Index)
  1022.     Psfset(Setno%, Paramno%).Label = Psfparamst.Label
  1023.     Psfset(Setno%, Paramno%).Units = Psfparamst.Units
  1024.     Psfset(Setno%, Paramno%).Lower = VAL(Psfparamst.Lower) / 10000
  1025.     Psfset(Setno%, Paramno%).Upper = VAL(Psfparamst.Upper) / 10000
  1026.   NEXT Paramno%
  1027. NEXT Setno%
  1028. Psf.hitemp% = VAL(Psf.hitempst$)
  1029. Psf.lotemp% = VAL(Psf.lotempst$)
  1030. Psf.sermark% = VAL(Psf.sermarkst$)
  1031. Psf.numspaces% = VAL(Psf.numspacesst$)
  1032.  
  1033. SUB Show.bars
  1034. 'Display / refresh status bars at top & bottom of screen
  1035. Linenum% = CSRLIN
  1036. Colnum% = POS(0)
  1037. VIEW PRINT 1 TO 25: COLOR 4, 7
  1038. LOCATE 1, 1: PRINT SPACE$(80);
  1039. LOCATE 1, 1: PRINT "***  SPECification EDITor   SOFTWARE ISSUE "; Softiss$; Softdate$;: LOCATE 1, 66: PRINT "S J OXLEY   ***";
  1040. LOCATE 25, 1: PRINT "***"; SPACE$(74); "***";
  1041. IF Choose.done% = YES THEN
  1042.   Specpath$ = Drive$ + ":" + Path$
  1043.   IF LEN(Specpath$) > 22 THEN Specpath$ = LEFT$(Specpath$, 19) + "..."
  1044.   LOCATE 25, 5: PRINT "Directory "; Specpath$; "  File "; TType.number$; " - "; Psfoption$;
  1045.   IF Psfoption$ <> "HYPOTHETICAL" THEN PRINT "  Issue: "; Psf.progiss$;
  1046.   LOCATE 25, 5: PRINT "Working File not chosen.  ";
  1047.   LOCATE 25, 40: COLOR 0: PRINT "Running on "; Host$;
  1048. VIEW PRINT 2 TO 24: COLOR 15, 4
  1049. LOCATE Linenum%, Colnum%
  1050.  
  1051. SUB Show.head1
  1052. 'Display first header edit screen
  1053. STATIC Hitempst AS STRING * 3
  1054. STATIC Lotempst AS STRING * 3
  1055. STATIC Sermarkst AS STRING * 1
  1056. CLS 2
  1057. LOCATE 2: PRINT "Page 1";
  1058. LOCATE , 30:  COLOR 15: PRINT "Main Header Data";: COLOR 14: PRINT "      (Yellow fields are optional.)"
  1059. COLOR 15, 4: PRINT "Type Number";: LOCATE , 30: COLOR , 1: PRINT Psf.typeno$
  1060. COLOR 15, 4: PRINT "Program Issue";: LOCATE , 30: PRINT Psf.progiss$
  1061. COLOR 15, 4: PRINT "Preceding Program Issue";: LOCATE , 30: PRINT Psf.preceding$
  1062. COLOR 15, 4: PRINT "Program Date";: LOCATE , 30: COLOR , 1: PRINT Psf.progdate$
  1063. COLOR 15, 4: PRINT "Source Spec Name";: LOCATE , 30: COLOR , 1: PRINT Psf.sourcename$
  1064. COLOR 15, 4: PRINT "Source Spec Issue";: LOCATE , 30: COLOR , 1: PRINT Psf.sourceiss$
  1065. COLOR 14, 4: PRINT "Source Spec Date";: LOCATE , 30: COLOR 15, 1: PRINT Psf.sourcedate$
  1066. COLOR 14, 4: PRINT "Source Spec Amendments..."
  1067. COLOR 15, 1: PRINT Psf.amendrefs$
  1068. COLOR 14, 4: PRINT "Customer Type";: LOCATE , 30: COLOR 15, 1: PRINT Psf.custype$
  1069. Hitempst$ = LTRIM$(STR$(Psf.hitemp%))
  1070. COLOR 15, 4: PRINT "High Temperature [23 to 200]";: LOCATE , 30: COLOR , 1: PRINT Hitempst$;: COLOR , 4: PRINT "    (Enter 999 if not applicable.)"
  1071. Lotempst$ = LTRIM$(STR$(Psf.lotemp%))
  1072. COLOR 15, 4: PRINT "Low Temperature [-99 to 23]";: LOCATE , 30: COLOR , 1: PRINT Lotempst$;: COLOR , 4: PRINT "    (Enter 999 if not applicable.)"
  1073. Sermarkst$ = LTRIM$(STR$(Psf.sermark%))
  1074. COLOR 15, 4: PRINT "Serial Marked";: LOCATE , 30: COLOR , 1: PRINT Sermarkst$;: COLOR , 4: PRINT "      (Enter [0]/1 for [not] serial marked.)"
  1075. COLOR 15, 4: PRINT "Change History..."
  1076. COLOR , 1: PRINT Psf.history$
  1077. COLOR 15, 4: PRINT "Change Note Number";: LOCATE , 30: COLOR , 1: PRINT Psf.crn$;: COLOR , 4: PRINT " (Enter NONE for pre-issue program.)"
  1078. COLOR 14, 4: PRINT "Engineer Responsible";: LOCATE , 30: COLOR 15, 1: PRINT Psf.eng$
  1079. COLOR 15, 2: PRINT "Up/Dn, Home/End, TAB keys to move; Ins/Del as normal; Pg Dn for P.2; ESC to quit";: COLOR 15, 4
  1080.  
  1081.  
  1082. SUB Show.head2 (Edit.set%, Edit.line%, Copy.set%)
  1083. 'Display second header edit screen
  1084. STATIC Numparsst AS STRING * 3
  1085. STATIC Numspacesst AS STRING * 3
  1086. STATIC Setst AS STRING * 1
  1087. STATIC Linest AS STRING * 3
  1088. STATIC Copysetst AS STRING * 1
  1089. CLS 2
  1090. LOCATE 2: PRINT "Page 2";
  1091. LOCATE , 30: PRINT "Comments & Parameter Set Data"
  1092. COLOR 14, 4: PRINT "Comments...": COLOR 15, 1
  1093. PRINT Psf.comment1$
  1094. PRINT Psf.comment2$
  1095. PRINT Psf.comment3$
  1096. PRINT Psf.comment4$
  1097. PRINT Psf.comment5$
  1098. COLOR 15, 4: PRINT "Parameter Set 0 Label";: LOCATE , 30: COLOR , 1: PRINT Psf.setlabel$(0)
  1099. Numparsst$ = LTRIM$(STR$(Psf.numpars%(0)))
  1100. COLOR 15, 4: PRINT "                Size";: LOCATE , 30: COLOR , 1: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size.)"
  1101. COLOR 14, 4: PRINT "Parameter Set 1 Label";: LOCATE , 30: COLOR 15, 1: PRINT Psf.setlabel$(1)
  1102. Numparsst$ = LTRIM$(STR$(Psf.numpars%(1)))
  1103. COLOR 14, 4: PRINT "                Size";: LOCATE , 30: COLOR 15, 1: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size, 0 if unused.)"
  1104. Col% = 1: IF Psf.numpars(1) = 0 THEN Col% = 4
  1105. COLOR 14, 4: PRINT "Parameter Set 2 Label";: LOCATE , 30: COLOR 15, Col%: PRINT Psf.setlabel$(2)
  1106. Numparsst$ = LTRIM$(STR$(Psf.numpars%(2)))
  1107. COLOR 14, 4: PRINT "                Size";: LOCATE , 30: COLOR 15, Col%: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size, 0 if unused.)"
  1108. Col% = 1: IF Psf.numpars(2) = 0 THEN Col% = 4
  1109. COLOR 14, 4: PRINT "Parameter Set 3 Label";: LOCATE , 30: COLOR 15, Col%: PRINT Psf.setlabel$(3)
  1110. Numparsst$ = LTRIM$(STR$(Psf.numpars%(3)))
  1111. COLOR 14, 4: PRINT "                Size";: LOCATE , 30: COLOR 15, Col%: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size, 0 if unused.)"
  1112. Numspacesst$ = LTRIM$(STR$(Psf.numspaces%))
  1113. COLOR 15, 4: PRINT "TRF Record Size";: LOCATE , 30: COLOR , 1: PRINT Numspacesst$;: COLOR , 4: PRINT "  (1 to 220 parameter spaces in TRF record.)"
  1114. COLOR 15, 2: PRINT SPACE$(80): PRINT SPACE$(80): PRINT SPACE$(80);: LOCATE 20
  1115. Setst$ = LTRIM$(STR$(Edit.set%))
  1116. COLOR 15, 2: PRINT "             Current Set";: LOCATE , 30: COLOR , 0: PRINT Setst$;
  1117. COLOR , 2: LOCATE , 35: PRINT "Pg Dn to Edit Current Line in Current Set"
  1118. Linest$ = LTRIM$(STR$(Edit.line%))
  1119. COLOR 15, 2: PRINT "             Current Line";: LOCATE , 30: COLOR , 0: PRINT Linest$;
  1120. Copysetst$ = LTRIM$(STR$(Copy.set%))
  1121. COLOR , 2: LOCATE , 35: PRINT "F9 for Default Indices in Current Set";
  1122. COLOR 15, 2: PRINT "             Destination Set";: LOCATE , 30: COLOR , 0: PRINT Copysetst$;
  1123. COLOR , 2: LOCATE , 35: PRINT "F10 to Copy Current Set to Destination Set";
  1124. COLOR 15, 2: PRINT "Up/Dn, Home/End or TAB keys to move; Ins; Del; Pg Up/Dn for P.1/P.3; ESC to quit";: COLOR 15, 4
  1125.  
  1126. SUB Show.param (Edit.set%, Edit.line%)
  1127. 'Display parameter edit screen
  1128. STATIC Indexst AS STRING * 3
  1129. STATIC Lowerst AS STRING * 10
  1130. STATIC Upperst AS STRING * 10
  1131. CLS 2
  1132. Setlabelst$ = "- " + Psf.setlabel$(Edit.set%)
  1133. LOCATE 2: PRINT "Page 3";: LOCATE , 30: PRINT "Parameter Data for Set"; Edit.set%; Setlabelst$
  1134. COLOR 15, 4: LOCATE 4, 1: PRINT "Line  IND.  LABEL                      UNITS   LOWER        UPPER        Line"
  1135. IF Edit.line% > Psf.numpars%(Edit.set%) THEN Edit.line% = Psf.numpars%(Edit.set%)
  1136. IF Edit.line% < 1 THEN Edit.line% = 1
  1137. FOR Line.number% = Edit.line% - 9 TO Edit.line% + 8
  1138.   IF Line.number% > 0 AND Line.number% <= Psf.numpars%(Edit.set%) THEN
  1139.     COLOR 15, 4: PRINT Line.number%;
  1140.     IF Line.number% = Edit.line% THEN
  1141.       COLOR 15, 1
  1142.     ELSE
  1143.       COLOR 14
  1144.     END IF
  1145.     Indexst$ = LTRIM$(STR$(Psfset(Edit.set%, Line.number%).Index))
  1146.     LOCATE , 7: PRINT Indexst$;
  1147.     LOCATE , 13: PRINT Psfset(Edit.set%, Line.number%).Label;
  1148.     LOCATE , 40: PRINT Psfset(Edit.set%, Line.number%).Units;
  1149.     Lowerst$ = LTRIM$(STR$(Psfset(Edit.set%, Line.number%).Lower))
  1150.     LOCATE , 48: PRINT Lowerst$;
  1151.     Upperst$ = LTRIM$(STR$(Psfset(Edit.set%, Line.number%).Upper))
  1152.     LOCATE , 61: PRINT Upperst$;
  1153.     LOCATE , 74: COLOR 15, 4: PRINT Line.number%
  1154.   ELSE
  1155.     PRINT
  1156.   END IF
  1157. NEXT Line.number%
  1158. Lowval! = Psfset(Edit.set%, Edit.line%).Lower
  1159. Upval! = Psfset(Edit.set%, Edit.line%).Upper
  1160. IF Lowval! > Upval! THEN
  1161.   LOCATE 23, 15: COLOR 10, 1: PRINT " Lower limit is greater than upper limit.      "
  1162.   Unit$ = LTRIM$(RTRIM$(Psfset(Edit.set%, Edit.line%).Units))
  1163.   Nominal! = (Round!(((Lowval! + Upval!) / 2), 3))
  1164.   Nomval$ = LTRIM$(RTRIM$(STR$(Nominal!)))
  1165.   IF LEFT$(Nomval$, 1) = "." THEN Nomval$ = "0" + Nomval$
  1166.   Rangeval$ = LTRIM$(RTRIM$(STR$(Round!(((Upval! - Lowval!) / 2), 3))))
  1167.   IF LEFT$(Rangeval$, 1) = "." THEN Rangeval$ = "0" + Rangeval$
  1168.   IF Lowval! * Upval! <= 0 OR INSTR(Unit$, "dB") > 0 OR INSTR(Unit$, "%") > 0 THEN
  1169.     LOCATE 23, 15: COLOR 10, 1: PRINT " Specified Value: "; Nomval$; Unit$; " "; CHR$(241); " "; Rangeval$; Unit$; " "
  1170.   ELSE
  1171.     Tolval$ = LTRIM$(RTRIM$(STR$(Round!((ABS(100 * (Upval! - Lowval!) / 2 / Nominal!)), 2))))
  1172.     IF LEFT$(Tolval$, 1) = "." THEN Tolval$ = "0" + Tolval$
  1173.     LOCATE 23, 15: COLOR 10, 1: PRINT " Specified Value: "; Nomval$; Unit$; " "; CHR$(241); " "; Rangeval$; Unit$; " ("; Tolval$; "%) "
  1174.   END IF
  1175. COLOR 15, 2: PRINT "Arrow & TAB keys to move; F9/F10 Insert/Delete line; Pg Up for P.2; ESC to quit ";: COLOR 15, 4
  1176.  
  1177. SUB Show.setup
  1178. 'Display current CHOOSE options
  1179. CLS 2
  1180. LOCATE 5, 20:  COLOR 15: PRINT "Working Directory & PSF Selection"
  1181. COLOR 15, 4: PRINT "Drive";: LOCATE , 20: COLOR , 1: PRINT Drive$
  1182. COLOR 15, 4: PRINT "Path";: LOCATE , 20: COLOR , 1: PRINT Path$
  1183. COLOR 15, 4: PRINT "Product type";: LOCATE , 20: COLOR , 1: PRINT TType.number$
  1184. Option$ = LEFT$(Psfoption$, 1)
  1185. COLOR 15, 4: PRINT "PSF Class";: LOCATE , 20: COLOR , 1: PRINT Option$;: COLOR , 4: PRINT "   C=CURRENT, P=PREVIOUS, H=HYPOTHETICAL"
  1186.   COLOR 15, 4: PRINT "Issue";: LOCATE , 20: COLOR , 1: PRINT Prev.issue$;: COLOR , 4: PRINT " The issue must be a valid DOS filename extension."
  1187.   Psf$ = TType.number$ + "P." + Noblanks$(Prev.issue$)
  1188.   Psf$ = TType.number$ + Option$ + ".PSF"
  1189. LOCATE 13: COLOR 15, 4
  1190. CASE "C"
  1191.   PRINT "If you load a CURRENT PSF you can edit it, produce a Tolerance Report or"
  1192.   PRINT "produce a History Report."
  1193.   PRINT "If you choose to edit it, you must decide whether you are going to raise the"
  1194.   PRINT "software issue of the test program. If so, the PSF will be archived as a"
  1195.   PRINT "PREVIOUS PSF before editing commences, and then the edited version will be"
  1196.   PRINT "saved as the new CURRENT PSF. If you choose not to change the issue, you will"
  1197.   PRINT "be able to save the edited version as either CURRENT or HYPOTHETICAL, or to"
  1198.   PRINT "quit the editor without saving the changes."
  1199. CASE "H"
  1200.   PRINT "If you load a HYPOTHETICAL PSF you can edit it or produce a Tolerance Report,"
  1201.   PRINT "but not a History Report."
  1202.   PRINT "If you choose to edit it, you will be able to save the edited version as"
  1203.   PRINT "HYPOTHETICAL, or quit the editor without saving the changes. You cannot"
  1204.   PRINT "convert a HYPOTHETICAL PSF to CURRENT class. This preserves the integrity of"
  1205.   PRINT "the issue history."
  1206. CASE "P"
  1207.   PRINT "If you load a PREVIOUS PSF you can edit it or produce a Tolerance Report, but"
  1208.   PRINT "not a History Report."
  1209.   PRINT "If you choose to edit it, you will be able to save the edited version as"
  1210.   PRINT "HYPOTHETICAL, or quit the editor without saving the changes. You cannot"
  1211.   PRINT "convert a PREVIOUS PSF to CURRENT class, nor can you over-write a PREVIOUS"
  1212.   PRINT "class file. This preserves the integrity of the issue history and of the"
  1213.   PRINT "archived PSF data."
  1214. LOCATE 24: COLOR 15, 2: PRINT "Up/Dn, Home/End keys to move; Edit entry or TAB to select option; ESC to finish ";: COLOR , 4
  1215.  
  1216. 'Print out a tolerance report for the loaded PSF
  1217. STATIC Lotempst AS STRING * 8
  1218. STATIC Hitempst AS STRING * 8
  1219. STATIC Indexst AS STRING * 3
  1220. ' STATIC Labelst AS STRING * 24
  1221. STATIC Unitsst AS STRING * 5
  1222. STATIC Lowerst AS STRING * 10
  1223. STATIC Upperst AS STRING * 10
  1224. STATIC Nomst AS STRING * 10
  1225. STATIC Tolst AS STRING * 7
  1226. PRINT #1, "TOLERANCE REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  1227. PRINT #1, STRING$(78, "-")
  1228. IF Psfoption$ = "HYPOTHETICAL" THEN
  1229.   PRINT #1, "HYPOTHETICAL PSF - Generated for results analysis, not applied in testing."
  1230.   IF Psfoption$ = "PREVIOUS" THEN
  1231.     Prev.psf$ = " (PREVIOUS)    Dated:"
  1232.   ELSE
  1233.     Prev.psf$ = "               Dated:"
  1234.   END IF
  1235.   PRINT #1, "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; Prev.psf$; Psf.progdate$
  1236. PRINT #1, "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  1237. IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT #1, Psf.amendrefs$
  1238. IF Psf.sermark% = YES THEN
  1239.   Sermarked$ = "              Serial Marked"
  1240.   Sermarked$ = "              Not Serial Marked"
  1241. PRINT #1, "Customer Reference:"; Psf.custype$; Sermarked$
  1242. IF Psf.lotemp% = 999 THEN
  1243.   Lotempst$ = " N/A    "
  1244.   Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  1245. IF Psf.hitemp% = 999 THEN
  1246.   Hitempst$ = " N/A    "
  1247.   Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  1248. PRINT #1, "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  1249. PRINT #1, STRING$(78, "-")
  1250. FOR Setno% = 0 TO Psf.numsets% - 1
  1251.   PRINT #1, "PARAMETER SET NUMBER"; Setno%; "      "; Psf.setlabel$(Setno%); "   "; Psf.numpars%(Setno%); "Parameters:-"
  1252.   PRINT #1, " ============================================================================"
  1253.   PRINT #1, "[IND|        PARAMETER        |  LOWER   |  UPPER   |  Nominal & Tol. | UNITS]"
  1254.   PRINT #1, "[---+-------------------------+----------+----------+-----------------+------]"
  1255.   FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1256.     Indexst$ = RTRIM$(LTRIM$(STR$(Psfset(Setno%, Paramno%).Index)))
  1257.     Labelst$ = Psfset(Setno%, Paramno%).Label
  1258.     Unitsst$ = Psfset(Setno%, Paramno%).Units
  1259.     Lowerst$ = STR$(Psfset(Setno%, Paramno%).Lower)
  1260.     Upperst$ = STR$(Psfset(Setno%, Paramno%).Upper)
  1261.     Lowval! = Psfset(Setno%, Paramno%).Lower
  1262.     Upval! = Psfset(Setno%, Paramno%).Upper
  1263.     Nominal! = (Round!(((Lowval! + Upval!) / 2), 4))
  1264.     Nomst$ = STR$(Nominal!)
  1265.     IF Lowval! * Upval! <= 0 OR INSTR(Unitsst$, "dB") > 0 OR INSTR(Unitsst$, "%") > 0 THEN
  1266.       Toleranceval! = (Upval! - Lowval!) / 2
  1267.       IF Toleranceval! > 999 THEN
  1268.         Tolst$ = "+->999"
  1269.       ELSEIF Toleranceval! > 100 THEN
  1270.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 0))))
  1271.       ELSEIF Toleranceval! > 10 THEN
  1272.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1))))
  1273.       ELSEIF Toleranceval! > 1 THEN
  1274.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2))))
  1275.       ELSE
  1276.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3))))
  1277.       END IF
  1278.     ELSE
  1279.       Toleranceval! = 100 * (Upval! - Lowval!) / 2 / ABS(Nominal!)
  1280.       IF Toleranceval! > 99.9 THEN
  1281.         Tolst$ = "+-99.9%"
  1282.       ELSEIF Toleranceval! > 10 THEN
  1283.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1)))) + "%"
  1284.       ELSEIF Toleranceval! > 1 THEN
  1285.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2)))) + "%"
  1286.       ELSE
  1287.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3)))) + "%"
  1288.       END IF
  1289.     END IF
  1290.     PRINT #1, "["; Indexst$; "| ";
  1291.     FOR Charpos = 1 TO 24
  1292.       Char$ = MID$(Labelst$, Charpos, 1)
  1293.       IF ASC(Char$) = 0 THEN
  1294.         Char$ = " "
  1295.       END IF
  1296.       PRINT #1, Char$;
  1297.     NEXT Charpos
  1298.     PRINT #1, "|"; Lowerst$; "|"; Upperst$; "|"; Nomst$; Tolst$; "| ";
  1299.     FOR Charpos = 1 TO 5
  1300.       Char$ = MID$(Unitsst$, Charpos, 1)
  1301.       IF ASC(Char$) = 0 THEN
  1302.         Char$ = " "
  1303.       END IF
  1304.       PRINT #1, Char$;
  1305.     NEXT Charpos
  1306.     PRINT #1, "]"
  1307.   NEXT Paramno%
  1308.   PRINT #1, " ============================================================================"
  1309. NEXT Setno%
  1310. PRINT #1, CHR$(12)
  1311.  
  1312. SUB Tol.show
  1313. 'Display a tolerance report for the loaded PSF
  1314. STATIC Lotempst AS STRING * 8
  1315. STATIC Hitempst AS STRING * 8
  1316. STATIC Indexst AS STRING * 3
  1317. STATIC Labelst AS STRING * 24
  1318. STATIC Unitsst AS STRING * 5
  1319. STATIC Lowerst AS STRING * 10
  1320. STATIC Upperst AS STRING * 10
  1321. STATIC Nomst AS STRING * 10
  1322. STATIC Tolst AS STRING * 7
  1323. PRINT "TOLERANCE REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  1324. COLOR 15: PRINT STRING$(78, "-")
  1325. IF Psfoption$ = "HYPOTHETICAL" THEN
  1326.   PRINT "HYPOTHETICAL PSF - Generated for results analysis, not applied in testing."
  1327.   IF Psfoption$ = "PREVIOUS" THEN
  1328.     Prev.psf$ = " (PREVIOUS)    Dated:"
  1329.   ELSE
  1330.     Prev.psf$ = "               Dated:"
  1331.   END IF
  1332.   PRINT "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; Prev.psf$; Psf.progdate$
  1333. PRINT "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  1334. IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT Psf.amendrefs$
  1335. IF Psf.sermark% = YES THEN
  1336.   Sermarked$ = "              Serial Marked"
  1337.   Sermarked$ = "              Not Serial Marked"
  1338. PRINT "Customer Reference:"; Psf.custype$; Sermarked$
  1339. IF Psf.lotemp% = 999 THEN
  1340.   Lotempst$ = " N/A    "
  1341.   Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  1342. IF Psf.hitemp% = 999 THEN
  1343.   Hitempst$ = " N/A    "
  1344.   Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  1345. PRINT "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  1346. PRINT STRING$(78, "-")
  1347. Line.counter% = 7
  1348. FOR Setno% = 0 TO Psf.numsets% - 1
  1349.   COLOR 14: PRINT "PARAMETER SET NUMBER"; Setno%;: COLOR 15: PRINT "      "; Psf.setlabel$(Setno%); "   "; Psf.numpars%(Setno%); "Parameters:-"
  1350.   PRINT " ============================================================================"
  1351.   PRINT "[IND|        PARAMETER        |  LOWER   |  UPPER   |  Nominal & Tol. | UNITS]"
  1352.   PRINT "[---+-------------------------+----------+----------+-----------------+------]"
  1353.   Line.counter% = Line.counter% + 4
  1354.   FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1355.     Indexst$ = RTRIM$(LTRIM$(STR$(Psfset(Setno%, Paramno%).Index)))
  1356.     Labelst$ = Psfset(Setno%, Paramno%).Label
  1357.     Unitsst$ = Psfset(Setno%, Paramno%).Units
  1358.     Lowerst$ = STR$(Psfset(Setno%, Paramno%).Lower)
  1359.     Upperst$ = STR$(Psfset(Setno%, Paramno%).Upper)
  1360.     Lowval! = Psfset(Setno%, Paramno%).Lower
  1361.     Upval! = Psfset(Setno%, Paramno%).Upper
  1362.     Nominal! = (Round!(((Lowval! + Upval!) / 2), 4))
  1363.     Nomst$ = STR$(Nominal!)
  1364.     IF Lowval! * Upval! <= 0 OR INSTR(Unitsst$, "dB") > 0 OR INSTR(Unitsst$, "%") > 0 THEN
  1365.       Toleranceval! = (Upval! - Lowval!) / 2
  1366.       IF Toleranceval! > 999 THEN
  1367.         Tolst$ = "+->999"
  1368.       ELSEIF Toleranceval! > 100 THEN
  1369.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 0))))
  1370.       ELSEIF Toleranceval! > 10 THEN
  1371.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1))))
  1372.       ELSEIF Toleranceval! > 1 THEN
  1373.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2))))
  1374.       ELSE
  1375.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3))))
  1376.       END IF
  1377.     ELSE
  1378.       Toleranceval! = 100 * (Upval! - Lowval!) / 2 / ABS(Nominal!)
  1379.       IF Toleranceval! > 99.9 THEN
  1380.         Tolst$ = "+-99.9%"
  1381.       ELSEIF Toleranceval! > 10 THEN
  1382.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1)))) + "%"
  1383.       ELSEIF Toleranceval! > 1 THEN
  1384.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2)))) + "%"
  1385.       ELSE
  1386.         Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3)))) + "%"
  1387.       END IF
  1388.     END IF
  1389.     PRINT "["; Indexst$; "| ";
  1390.     FOR Charpos = 1 TO 24
  1391.       Char$ = MID$(Labelst$, Charpos, 1)
  1392.       IF ASC(Char$) = 0 THEN
  1393.         Char$ = " "
  1394.       END IF
  1395.       PRINT Char$;
  1396.     NEXT Charpos
  1397.     PRINT "|"; Lowerst$; "|"; Upperst$; "|"; Nomst$; Tolst$; "| ";
  1398.     FOR Charpos = 1 TO 5
  1399.       Char$ = MID$(Unitsst$, Charpos, 1)
  1400.       IF ASC(Char$) = 0 THEN
  1401.         Char$ = " "
  1402.       END IF
  1403.       PRINT Char$;
  1404.     NEXT Charpos
  1405.     PRINT "]"
  1406.     Line.counter% = Line.counter% + 1
  1407.     IF Line.counter% > 19 THEN
  1408.       CALL State("Press any key to continue."): COLOR 15, 4
  1409.       CALL Waitkey
  1410.       CLS 2: LOCATE 3
  1411.       Line.counter% = 0
  1412.     END IF
  1413.   NEXT Paramno%
  1414.   PRINT " ============================================================================"
  1415.   Line.counter% = Line.counter% + 1
  1416.   IF Line.counter% > 15 THEN
  1417.     CALL State("Press any key to continue."): COLOR 15, 4
  1418.     CALL Waitkey
  1419.     CLS 2: LOCATE 3
  1420.     Line.counter% = 0
  1421.   END IF
  1422. NEXT Setno%
  1423.  
  1424. SUB TOLERANCE
  1425. IF Choose.done% = NO THEN
  1426.   SOUND 300, 4
  1427.   CALL State("Working file not specified yet; select CHOOSE first. Press any key.")
  1428.   CALL Waitkey
  1429. CLS 2
  1430. Pathname$ = Drive$ + ":" + Path$ + Psf$
  1431. Fileunfound% = RESETFLAG
  1432. OPEN Pathname$ FOR INPUT AS #2
  1433. IF Fileunfound% = NO THEN
  1434.   CALL Read.psf
  1435.   CLOSE #2
  1436. CALL Tol.show
  1437. IF Ask%("Do you want to PRINT THIS REPORT") = YES THEN
  1438.   State ("Printing Tolerance Report...")
  1439.   CALL Tol.print
  1440.   State ("")
  1441.  
  1442. ' Output all data to PSF file, which has already been opened as #3
  1443.   DIM Psfparamst AS Psfparamsttype
  1444.   Psf.hitempst$ = STR$(Psf.hitemp%)
  1445.   Psf.lotempst$ = STR$(Psf.lotemp%)
  1446.   Psf.sermarkst$ = STR$(Psf.sermark%)
  1447.   Psf.numspacesst$ = STR$(Psf.numspaces%)
  1448.   PRINT #3, Psf.typeno$: PRINT #3, Psf.progiss$
  1449.   PRINT #3, Psf.preceding$: PRINT #3, Psf.progdate$
  1450.   PRINT #3, Psf.sourcename$: PRINT #3, Psf.sourceiss$
  1451.   PRINT #3, Psf.sourcedate$: PRINT #3, Psf.amendrefs$
  1452.   PRINT #3, Psf.custype$: PRINT #3, Psf.hitempst$
  1453.   PRINT #3, Psf.lotempst$: PRINT #3, Psf.sermarkst$
  1454.   PRINT #3, Psf.history$: PRINT #3, Psf.crn$
  1455.   PRINT #3, Psf.eng$: PRINT #3, Psf.comment1$
  1456.   PRINT #3, Psf.comment2$: PRINT #3, Psf.comment3$
  1457.   PRINT #3, Psf.comment4$: PRINT #3, Psf.comment5$
  1458.   Psf.numsetsst$ = STR$(Psf.numsets%)
  1459.   PRINT #3, Psf.numsetsst$
  1460.   FOR Setno% = 0 TO Psf.numsets% - 1
  1461.     Psf.numparsst$ = STR$(Psf.numpars%(Setno%))
  1462.     PRINT #3, Psf.numparsst$
  1463.   NEXT Setno%
  1464.   PRINT #3, Psf.numspacesst$
  1465.   FOR Setno% = 0 TO Psf.numsets% - 1
  1466.     PRINT #3, Psf.setlabel$(Setno%)
  1467.   NEXT Setno%
  1468.   FOR Setno% = 0 TO Psf.numsets% - 1
  1469.     FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1470.       Psfparamst.Index = STR$(Psfset(Setno%, Paramno%).Index)
  1471.       Psfparamst.Label = Psfset(Setno%, Paramno%).Label
  1472.       Psfparamst.Units = Psfset(Setno%, Paramno%).Units
  1473.       Lower.val! = (Psfset(Setno%, Paramno%).Lower * 10000)
  1474.       Lower.val! = Lower.val! + .1 * SGN(Lower.val!) 'Eliminate rounding errors
  1475.       Lower.int& = FIX(Lower.val!)
  1476.       Psfparamst.Lower = STR$(Lower.int&)
  1477.       Upper.val! = (Psfset(Setno%, Paramno%).Upper * 10000)
  1478.       Upper.val! = Upper.val! + .1 * SGN(Upper.val!) 'Eliminate rounding errors
  1479.       Upper.int& = FIX(Upper.val!)
  1480.       Psfparamst.Upper = STR$(Upper.int&)
  1481.       PRINT #3, Psfparamst.Index
  1482.       PRINT #3, Psfparamst.Label
  1483.       PRINT #3, Psfparamst.Units
  1484.       PRINT #3, Psfparamst.Lower
  1485.       PRINT #3, Psfparamst.Upper
  1486.     NEXT Paramno%
  1487.   NEXT Setno%
  1488.  
  1489. ' UTILs _____________________________________________________________________________________
  1490.  
  1491. FUNCTION Ask% (Question$)
  1492.     'Prompt for Y / N response
  1493.     DO
  1494.         Dummy$ = INKEY$
  1495.     LOOP UNTIL Dummy$ = ""
  1496.     COLOR 10, 1
  1497.     Valid% = NO
  1498.     WHILE Valid% = NO
  1499.         LOCATE 23, 1
  1500.         PRINT SPACE$(80);
  1501.         LOCATE 23, 1
  1502.         PRINT Question$; "? (Y/N) ";
  1503.         DO
  1504.             K$ = INKEY$
  1505.         LOOP WHILE K$ = ""
  1506.         Valid% = YES
  1507.         SELECT CASE K$
  1508.             CASE "Y", "y"
  1509.                 Ask% = YES
  1510.             CASE "N", "n"
  1511.                 Ask% = NO
  1512.             CASE ELSE
  1513.                 Valid% = NO
  1514.         END SELECT
  1515.     WEND
  1516.     COLOR 15, 1
  1517.     LOCATE 23, 1
  1518.     PRINT SPACE$(80);
  1519.  
  1520. FUNCTION British$ (Indate$)
  1521.     'Converts "m[m]{-./}d[d]{-./}yy[yy]" to "dd/mm/yy[yy]"
  1522.  
  1523.     Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1524.     IF Delim > 0 THEN
  1525.         Month% = VAL(LEFT$(Indate$, (Delim - 1)))
  1526.         Indate$ = RIGHT$(Indate$, (LEN(Indate$) - Delim))
  1527.         Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1528.         IF Delim > 0 THEN Day% = VAL(LEFT$(Indate$, (Delim - 1)))
  1529.         IF Delim > 0 THEN Year% = VAL(RIGHT$(Indate$, (LEN(Indate$) - Delim)))
  1530.     END IF
  1531.     d$ = STR$(Day%)
  1532.     d$ = RIGHT$(d$, (LEN(d$) - 1))
  1533.     IF LEN(d$) = 1 THEN d$ = "0" + d$
  1534.     m$ = STR$(Month%)
  1535.     m$ = RIGHT$(m$, (LEN(m$) - 1))
  1536.     IF LEN(m$) = 1 THEN m$ = "0" + m$
  1537.     y$ = STR$(Year%)
  1538.     y$ = RIGHT$(y$, (LEN(y$) - 1))
  1539.     British$ = d$ + "/" + m$ + "/" + y$
  1540.  
  1541.  
  1542. FUNCTION Checkint% (Value%, Lolim%, Hilim%)
  1543.     IF Value% < Lolim% OR Value% > Hilim% THEN
  1544.         SOUND 400, 1
  1545.         Checkint% = NO
  1546.     ELSE
  1547.         Checkint% = YES
  1548.     END IF
  1549.  
  1550. FUNCTION Checkreal% (Value!, Lolim!, Hilim!)
  1551.     IF Value! < Lolim! OR Value! > Hilim! THEN
  1552.         SOUND 400, 1
  1553.         Checkreal% = NO
  1554.     ELSE
  1555.         Checkreal% = YES
  1556.     END IF
  1557.  
  1558. FUNCTION Datestr$ (Inputdate&)
  1559.     'Converts a number of days since 30/12/1899 (Quattro pro ref) into a date
  1560.     'string. Output date string is DD/MM/YYYY
  1561.  
  1562.     Indate& = Inputdate& + 364
  1563.     DIM Numdays(12) AS INTEGER
  1564.     Numdays(1) = 31
  1565.     Numdays(2) = 28
  1566.     Numdays(3) = 31
  1567.     Numdays(4) = 30
  1568.     Numdays(5) = 31
  1569.     Numdays(6) = 30
  1570.     Numdays(7) = 31
  1571.     Numdays(8) = 31
  1572.     Numdays(9) = 30
  1573.     Numdays(10) = 31
  1574.     Numdays(11) = 30
  1575.     Numdays(12) = 31
  1576.  
  1577.     'Derive date from input number of days past reference
  1578.     Year% = 1899
  1579.     WHILE Indate& > 366
  1580.         IF Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0) THEN
  1581.             Indate& = Indate& - 366
  1582.         ELSE
  1583.             Indate& = Indate& - 365
  1584.         END IF
  1585.         Year% = Year% + 1
  1586.     WEND
  1587.     IF Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0) THEN
  1588.         Numdays(2) = 29
  1589.     ELSE
  1590.         IF Indate& = 366 THEN
  1591.             Indate& = 1
  1592.             Year% = Year% + 1
  1593.         END IF
  1594.     END IF
  1595.     Month% = 1
  1596.     WHILE Indate& > Numdays(Month%)
  1597.         Indate& = Indate& - Numdays(Month%)
  1598.         Month% = Month% + 1
  1599.     WEND
  1600.     Day% = Indate&
  1601.  
  1602.     'Construct date$
  1603.     d$ = STR$(Day%)
  1604.     d$ = RIGHT$(d$, (LEN(d$) - 1))
  1605.     IF LEN(d$) = 1 THEN d$ = "0" + d$
  1606.     m$ = STR$(Month%)
  1607.     m$ = RIGHT$(m$, (LEN(m$) - 1))
  1608.     IF LEN(m$) = 1 THEN m$ = "0" + m$
  1609.     y$ = STR$(Year%)
  1610.     y$ = RIGHT$(y$, (LEN(y$) - 1))
  1611.  
  1612.     Datestr$ = d$ + "/" + m$ + "/" + y$
  1613.  
  1614.  
  1615. FUNCTION Dateval& (Inputdate$)
  1616.     'Converts a date string into number of days since 30/12/1899 (Quattro-Pro ref)  1/1/1899
  1617.     'Input date string is DAY/MONTH/YEAR, DAY.MONTH.YEAR or DAY-MONTH-YEAR
  1618.     'where DAY and MONTH are 1 or 2 digits and YEAR is 2 or 4 digits
  1619.     'A 2-digit year is interpreted as being between 1951 and 2050. Dates outside
  1620.     'this range and invalid dates return error code (-1).
  1621.  
  1622.     Indate$ = Inputdate$
  1623.     DIM Numdays(12) AS INTEGER
  1624.     Numdays(1) = 31
  1625.     Numdays(2) = 28
  1626.     Numdays(3) = 31
  1627.     Numdays(4) = 30
  1628.     Numdays(5) = 31
  1629.     Numdays(6) = 30
  1630.     Numdays(7) = 31
  1631.     Numdays(8) = 31
  1632.     Numdays(9) = 30
  1633.     Numdays(10) = 31
  1634.     Numdays(11) = 30
  1635.     Numdays(12) = 31
  1636.  
  1637.     'Extract days, months and years from Indate$
  1638.     Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1639.     IF Delim > 0 THEN
  1640.         Day% = VAL(LEFT$(Indate$, (Delim - 1)))
  1641.         Indate$ = RIGHT$(Indate$, (LEN(Indate$) - Delim))
  1642.         Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1643.         IF Delim > 0 THEN Month% = VAL(LEFT$(Indate$, (Delim - 1)))
  1644.         IF Delim > 0 THEN Year% = VAL(RIGHT$(Indate$, (LEN(Indate$) - Delim)))
  1645.         IF Year% < 100 THEN
  1646.             IF Year% < 51 THEN
  1647.                 Year% = Year% + 2000
  1648.             ELSE
  1649.                 Year% = Year% + 1900
  1650.             END IF
  1651.         END IF
  1652.     END IF
  1653.  
  1654.     'Convert date to number of days since reference
  1655.     Daycount& = 0
  1656.     IF Year% < 1951 OR Year% > 2050 OR Month% < 1 OR Month% > 12 THEN
  1657.         Daycount& = -1
  1658.     ELSE
  1659.         IF (Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0)) AND Month% = 2 THEN
  1660.             IF Day% > 29 THEN Daycount& = -1
  1661.         ELSE
  1662.             IF Day% > Numdays(Month%) THEN Daycount& = -1
  1663.         END IF
  1664.         IF Day% < 1 THEN Daycount& = -1
  1665.     END IF
  1666.     IF Daycount& = 0 THEN
  1667.         FOR I = 1899 TO Year% - 1
  1668.             Daycount& = Daycount& + 365
  1669.             IF I MOD 400 = 0 OR (I MOD 4 = 0 AND I MOD 100 <> 0) THEN
  1670.                 Daycount& = Daycount& + 1
  1671.             END IF
  1672.         NEXT I
  1673.         FOR I = 1 TO Month% - 1
  1674.             Daycount& = Daycount& + Numdays(I)
  1675.         NEXT I
  1676.         IF Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0) THEN
  1677.             IF Month% > 2 THEN Daycount& = Daycount& + 1
  1678.         END IF
  1679.         Daycount& = Daycount& + Day%
  1680.     END IF
  1681.     IF Daycount& > 0 THEN
  1682.         Dateval& = Daycount& - 364
  1683.     ELSE
  1684.         Dateval& = -1
  1685.     END IF
  1686.  
  1687. FUNCTION Dosvalid% (Extension$)
  1688.     'Check whether (first 3 chars of) Extension$ is a valid DOS filename extension
  1689.     DIM C%(3)
  1690.     Check.ext$ = Extension$
  1691.     IF LEN(Extension$) < 3 THEN
  1692.         Check.ext$ = Check.ext$ + SPACE$(3 - LEN(Extension$))
  1693.     END IF
  1694.     Check.ext$ = LEFT$(Check.ext$, 3)
  1695.     C%(1) = ASC(Check.ext$)
  1696.     C%(2) = ASC(RIGHT$(Check.ext$, 2))
  1697.     C%(3) = ASC(RIGHT$(Check.ext$, 1))
  1698.     Valid% = YES
  1699.     FOR n% = 1 TO 3
  1700.         Validchar% = NO
  1701.         X% = C%(n%)
  1702.         IF X% = 33 OR (X% > 34 AND X% < 42) OR X% = 45 OR (X% > 47 AND X% < 58) THEN Validchar% = YES
  1703.         IF (X% > 63 AND X% < 91) OR (X% > 93 AND X% < 124) OR X% = 125 OR X% = 126 THEN Validchar% = YES
  1704.         IF n% > 1 AND X% = 32 THEN Validchar% = YES 'Allow trailing spaces
  1705.         IF Validchar% = NO THEN Valid% = NO
  1706.     NEXT n%
  1707.     'IF Valid% = NO THEN SOUND 400, 1
  1708.     Dosvalid% = Valid%
  1709.  
  1710. FUNCTION Noblanks$ (Instring$)
  1711.     ' Strip leading, trailing and all contained spaces and convert to upper case
  1712.     ' (see Plain$)
  1713.     Temp$ = LTRIM$(RTRIM$(UCASE$(Instring$)))
  1714.     Blanksin% = YES
  1715.     WHILE Blanksin% = YES
  1716.         Spacepos% = INSTR(Temp$, " ")
  1717.         IF Spacepos% THEN
  1718.             Leftbit$ = LEFT$(Temp$, Spacepos% - 1)
  1719.             Rightbit$ = RIGHT$(Temp$, LEN(Temp$) - Spacepos%)
  1720.             Temp$ = Leftbit$ + Rightbit$
  1721.         ELSE
  1722.             Blanksin% = NO
  1723.         END IF
  1724.     WEND
  1725.     Noblanks$ = Temp$
  1726.  
  1727. SUB Pause (T!)
  1728.     Start.time = TIMER
  1729.     WHILE TIMER < Start.time + T!
  1730.         IF TIMER < Start.time THEN Start.time = Start.time - 24 * 3600 'IF MIDNIGHT HAPPENS
  1731.     WEND
  1732.  
  1733. FUNCTION Plain$ (Instring$)
  1734.     ' Strip leading & trailing spaces and convert to upper case (see Noblanks$)
  1735.     Plain$ = LTRIM$(RTRIM$(UCASE$(Instring$)))
  1736.  
  1737. FUNCTION Qpwdate& (Intimedate!)
  1738.     'Derives a Quattro-pro date value from an HP Basic TIMEDATE value.
  1739.     Qpwdate& = INT(Intimedate! / 86400 - 2415019)
  1740.  
  1741.  
  1742. FUNCTION Qpwtime# (Intimedate#)
  1743.     'Derives a Quattro-pro time value from an HP Basic TIMEDATE value.
  1744.     Qpwtime# = (Intimedate# / 86400) - INT(Intimedate# / 86400)
  1745.  
  1746.  
  1747. FUNCTION Round! (Value!, Dec%)
  1748.     'Round Value! to Dec% DP, max 4 DP
  1749.     IF Dec% > 4 THEN Dec% = 4
  1750.     Power.ten! = 10 ^ Dec%
  1751.     Integer.part! = FIX(Value!)
  1752.     Decimal.part! = Value! - FIX(Value!)
  1753.     IF Power.ten! <> 0 THEN Decimal.part! = CINT(Decimal.part! * Power.ten!) / Power.ten!
  1754.     Round! = Integer.part! + Decimal.part!
  1755.  
  1756. SUB State (Prompt$)
  1757.     'Display single line prompt
  1758.     Linenum% = CSRLIN
  1759.     Colnum% = POS(0)
  1760.     COLOR 14, 1
  1761.     LOCATE 24, 1
  1762.     PRINT SPACE$(80);
  1763.     LOCATE 24, 1
  1764.     PRINT Prompt$;
  1765.     LOCATE Linenum%, Colnum%
  1766.     COLOR 15, 1
  1767.  
  1768. FUNCTION Timedate! (Inqpwdate&, Inqpwtime!)
  1769.     'Converts a Quattro-pro date and time value to the corresponding HP Basic
  1770.     'TIMEDATE value.
  1771.     Timedate! = (Inqpwdate& + 2415019 + Inqpwtime!) * 86400
  1772.  
  1773. FUNCTION Timestr$ (Inputtime#)
  1774.     'Converts a fraction of a day (Quattro pro format) into a time string.
  1775.     'Output time string is HH:MM:SS. Conversion accuracy +/- 1 Sec.
  1776.  
  1777.     Inputhours! = (Inputtime# - INT(Inputtime#)) * 24
  1778.     Hour% = INT(Inputhours!)
  1779.     Min% = INT((Inputhours! - Hour%) * 60)
  1780.     Sec% = INT(((Inputhours! - Hour%) * 60 - Min%) * 60)
  1781.  
  1782.     'Construct time$
  1783.     h$ = STR$(Hour%)
  1784.     h$ = RIGHT$(h$, (LEN(h$) - 1))
  1785.     IF LEN(h$) = 1 THEN h$ = "0" + h$
  1786.     m$ = STR$(Min%)
  1787.     m$ = RIGHT$(m$, (LEN(m$) - 1))
  1788.     IF LEN(m$) = 1 THEN m$ = "0" + m$
  1789.     s$ = STR$(Sec%)
  1790.     s$ = RIGHT$(s$, (LEN(s$) - 1))
  1791.     IF LEN(s$) = 1 THEN s$ = "0" + s$
  1792.  
  1793.     Timestr$ = h$ + ":" + m$ + ":" + s$
  1794.  
  1795. FUNCTION Toggle% (Inflag%)
  1796.     ' If inflag is logic (1 / 0) then its complement is returned.
  1797.  
  1798.     SELECT CASE Inflag%
  1799.         CASE 0
  1800.             Toggle% = 1
  1801.         CASE 1
  1802.             Toggle% = 0
  1803.         CASE ELSE
  1804.             Toggle% = Inflag%
  1805.     END SELECT
  1806.  
  1807.  
  1808. SUB Waitkey
  1809.     'Wait for keypress then continue
  1810.     Pause (.1) ' Delay to avoid keybounce
  1811.     DO
  1812.         K$ = INKEY$
  1813.     LOOP UNTIL K$ = "" ' Clear buffer
  1814.     DO
  1815.         K$ = INKEY$
  1816.     LOOP WHILE K$ = ""
  1817.     Pause (.1) ' Delay to avoid keybounce
  1818.  
  1819. SUB Warn (Prompt$)
  1820.     'Display single line prompt
  1821.     Linenum% = CSRLIN
  1822.     Colnum% = POS(0)
  1823.     LOCATE 24, 1
  1824.     PRINT SPACE$(80);
  1825.     LOCATE 24, 1
  1826.     COLOR 28, 1
  1827.     PRINT "WARNING - ";
  1828.     COLOR 12, 1
  1829.     PRINT Prompt$;
  1830.     SOUND 400, 1
  1831.     LOCATE Linenum%, Colnum%
  1832.     COLOR 15, 1
  1833.  
  1834.  
« Last Edit: September 28, 2020, 02:17:32 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Compile old QB4.5 code help
« Reply #10 on: September 28, 2020, 01:19:08 pm »
Yeah, did this:
Code: QB64: [Select]
  1. '-----------------------------------------------------------------------------
  2. DIM Psf.numpars(3) AS INTEGER, Psf.setlabel(3) AS STRING * 20
  3. DIM SHARED Psfset(3, 1 TO 220) AS Psfparamtype '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< changed SHARED
  4. '-----------------------------------------------------------------------------
  5. 'General
  6. COMMON SHARED Softiss AS STRING * 2, Softdate AS STRING * 13, Printerok%
  7. COMMON SHARED Type.number AS STRING * 6, Choose.done%
  8. 'File operations
  9. COMMON SHARED Drive$, Path$, Psf$, Psfoption$, Prev.issue AS STRING * 3
  10. COMMON SHARED Fileunfound%, Fileduplicate%
  11. 'File contents data
  12. COMMON SHARED Psf.typeno AS STRING * 6, Psf.progiss AS STRING * 3
  13. COMMON SHARED Psf.preceding AS STRING * 3, Psf.progdate AS STRING * 10
  14. COMMON SHARED Psf.sourcename AS STRING * 20, Psf.sourceiss AS STRING * 5
  15. COMMON SHARED Psf.sourcedate AS STRING * 10, Psf.amendrefs AS STRING * 80
  16. COMMON SHARED Psf.custype AS STRING * 20, Psf.hitemp AS INTEGER
  17. COMMON SHARED Psf.lotemp AS INTEGER, Psf.sermark AS INTEGER
  18. COMMON SHARED Psf.history AS STRING * 80, Psf.crn AS STRING * 6
  19. COMMON SHARED Psf.eng AS STRING * 10, Psf.comment1 AS STRING * 80
  20. COMMON SHARED Psf.comment2 AS STRING * 80, Psf.comment3 AS STRING * 80
  21. COMMON SHARED Psf.comment4 AS STRING * 80, Psf.comment5 AS STRING * 80
  22. COMMON SHARED Psf.numsets AS INTEGER, Psf.numpars AS INTEGER
  23. COMMON SHARED Psf.numspaces AS INTEGER, Psf.setlabel AS STRING * 20
  24. 'COMMON SHARED Psfset AS Psfparamtype, Host AS STRING * 20  '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< changed
  25. DIM SHARED Host AS STRING * 20
  26. '-----------------------------------------------------------------------------
  27.  

and the problem with the array goes away.

Then this is flagged!
Code: QB64: [Select]
  1. SUB Hist.print
  2.     'Print out the History Report entry for the PSF now loaded
  3. PRINT #1,PRINT  '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< WTH?
  4. IF Plain$(Psf.crn$) <> "NONE" THEN
  5.   Issued$ = ") issued under Change Note No. " + Psf.crn$
  6.   Issued$ = ") not issued."
  7. PRINT #1, Psfoption$; " ("; Psf$; Issued$
  8. PRINT #1, "PROG Iss. "; Psf.progiss$; " - "; Psf.progdate$; "  SPEC "; Psf.sourcename$; " Iss. "; Psf.sourceiss$; " - "; Psf.sourcedate$
  9. IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT #1, Psf.amendrefs$
  10. PRINT #1, Psf.history$
  11.  

Say did this code even work?
« Last Edit: September 28, 2020, 01:27:49 pm by bplus »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • GitHub
Re: Compile old QB4.5 code help
« Reply #11 on: September 28, 2020, 01:39:19 pm »
Yeah there were so many naming conflicts. I would fix one and then another line is screwed lol
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Compile old QB4.5 code help
« Reply #12 on: September 28, 2020, 01:43:20 pm »
Actually I just assumed
Code: QB64: [Select]
meant print a blank line so I replaced them all with
Code: QB64: [Select]
  1. PRINT #1, " "

and then I got the OK to compile! wow
Code: QB64: [Select]
  1. '-----------------------------------------------------------------------------
  2. '                           NAMING CONVENTIONS
  3. '  Category............................................  Format  Example
  4. 'PROCEDURES
  5. '  Main procedure relating to main menu function         NNNN    TASK
  6. '  Subsidiary procedure in main module                   Nn.nn   Do.task
  7. '  Utility procedure                                     Nnnn    Utility
  8. 'DATA
  9. '  Constant                                              NNNN    FRED
  10. '  General variable                                      Nnnn    Fredgen
  11. '  One of a set of variables related to a subject (Fred) Nn.nn   Fred.variable
  12. '  Element of variable (Fred) with user-defined type     Nn.Nn   Fred.Element
  13. '
  14. '      I/O PATHS
  15. '      #1    Printer LPT1
  16. '      #2    PSF file I/P
  17. '      #3    PSF file O/P
  18. '-----------------------------------------------------------------------------
  19. CONST TRUE = 1, YES = 1, SETFLAG = 1
  20. CONST FALSE = 0, NO = 0, RESETFLAG = 0
  21. '-----------------------------------------------------------------------------
  22. TYPE Psfparamtype
  23.     Index AS INTEGER
  24.     Label AS STRING * 24
  25.     Units AS STRING * 5
  26.     Lower AS SINGLE
  27.     Upper AS SINGLE
  28. TYPE Psfparamsttype ' String-only version for file reading
  29.     Index AS STRING * 4
  30.     Label AS STRING * 24
  31.     Units AS STRING * 5
  32.     Lower AS STRING * 9
  33.     Upper AS STRING * 9
  34. '-----------------------------------------------------------------------------
  35. DIM Psf.numpars(3) AS INTEGER, Psf.setlabel(3) AS STRING * 20 ' <<<<<<<<<<<<<<<<<<<<<<<<<<<< these never used
  36. DIM SHARED Psfset(3, 1 TO 220) AS Psfparamtype '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< changed SHARED
  37. '-----------------------------------------------------------------------------
  38. 'General
  39. COMMON SHARED Softiss AS STRING * 2, Softdate AS STRING * 13, Printerok%
  40. COMMON SHARED Type.number AS STRING * 6, Choose.done%
  41. 'File operations
  42. COMMON SHARED Drive$, Path$, Psf$, Psfoption$, Prev.issue AS STRING * 3
  43. COMMON SHARED Fileunfound%, Fileduplicate%
  44. 'File contents data
  45. COMMON SHARED Psf.typeno AS STRING * 6, Psf.progiss AS STRING * 3
  46. COMMON SHARED Psf.preceding AS STRING * 3, Psf.progdate AS STRING * 10
  47. COMMON SHARED Psf.sourcename AS STRING * 20, Psf.sourceiss AS STRING * 5
  48. COMMON SHARED Psf.sourcedate AS STRING * 10, Psf.amendrefs AS STRING * 80
  49. COMMON SHARED Psf.custype AS STRING * 20, Psf.hitemp AS INTEGER
  50. COMMON SHARED Psf.lotemp AS INTEGER, Psf.sermark AS INTEGER
  51. COMMON SHARED Psf.history AS STRING * 80, Psf.crn AS STRING * 6
  52. COMMON SHARED Psf.eng AS STRING * 10, Psf.comment1 AS STRING * 80
  53. COMMON SHARED Psf.comment2 AS STRING * 80, Psf.comment3 AS STRING * 80
  54. COMMON SHARED Psf.comment4 AS STRING * 80, Psf.comment5 AS STRING * 80
  55. COMMON SHARED Psf.numsets AS INTEGER, Psf.numpars AS INTEGER
  56. COMMON SHARED Psf.numspaces AS INTEGER, Psf.setlabel AS STRING * 20
  57. 'COMMON SHARED Psfset AS Psfparamtype, Host AS STRING * 20  '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< changed
  58. DIM SHARED Host AS STRING * 20
  59. '-----------------------------------------------------------------------------
  60. 'SPECIFICATION EDITOR PROGRAM - SPECEDIT.BAS    S J Oxley
  61. Softiss$ = "5 ": Softdate$ = "- 08/11/04"
  62. 'REVISION RECORD:
  63. '..DATE....ISSUE......................REVISION DETAILS..................
  64. '25/01/99   1     FIRST ISSUE - Archived as SPECED01.BAS + UTILS02.BAS
  65. '22/02/99  (1)    Added choice of Template File in CHOOSE, F9 & F10 functions
  66. '                 on editor P.2 (default indices & copy set)
  67. '13/10/99   2     Added clearance of unused parameter sets when loading a PSF
  68. '                 with fewer parameter sets than the previous PSF.
  69. '                 Cleared Print.tol format bug; Label/Units trailing spaces.
  70. '                 Archived as SPECED02.BAS
  71. '19/10/99  (2)    Added default drive selection using OPTIONH.PSF file.
  72. '14/01/00  (2)    Changed Filename$ to Psf$ when saving edited PSF at end of
  73. '                 EDIT. The global Psf$ is now updated when changing class.
  74. '28/02/00  (2)    Removal of F7 option.
  75. '04/06/03   3     Default drive and paths set to T and \TEST\SPECS.
  76. '02/09/03   4     Index as STRING * 3 changed to * 4.
  77. '                 Changed to allow for index>100 " 100" is 4 CHRs.
  78. '                 Changed default drive and paths back to C and \BLP\SPECS.
  79. '07/11/04   5     Changed DIM Psfset(3,1 TO 200) to 220 to get more parameters.
  80. '-----------------------------------------------------------------------------
  81. OPEN "LPT1" FOR OUTPUT AS #1
  82. ON ERROR GOTO Errhandler
  83. CALL Show.bars
  84. CLS 2
  85. CALL Init.vars
  86. Stay% = YES
  87. WHILE Stay% = YES
  88.     ON KEY(1) GOSUB Callchoose
  89.     ON KEY(2) GOSUB Calledit
  90.     ON KEY(3) GOSUB Calltolerance
  91.     ON KEY(4) GOSUB Callhistory
  92.     ON KEY(8) GOSUB Quit
  93.     LOCATE 2
  94.     CALL Show.bars
  95.     CLS 2
  96.     LOCATE 3, 28: PRINT "MAIN MENU"
  97.     LOCATE 4, 28: PRINT "========="
  98.     LOCATE 7, 28: PRINT "F1. CHOOSE    ";: COLOR 7: PRINT "  - Set directory, file & options": COLOR 6: IF Choose.done% = YES THEN COLOR 15
  99.     LOCATE 8, 28: PRINT "F2. EDIT      ";: COLOR 7: PRINT "  - Edit spec data": COLOR 6: IF Choose.done% = YES THEN COLOR 15
  100.     LOCATE 9, 28: PRINT "F3. TOLERANCE ";: COLOR 7: PRINT "  - View / print tolerances": COLOR 6: IF Choose.done% = YES AND Psfoption$ = "CURRENT" THEN COLOR 15
  101.     LOCATE 10, 28: PRINT "F4. HISTORY   ";: COLOR 7: PRINT "  - View / print history": COLOR 11
  102.     LOCATE 12, 28: PRINT "F8. QUIT      ";: COLOR 7: PRINT "  - Exit": COLOR 15
  103.     FOR S = 1 TO 4
  104.         KEY(S) ON
  105.     NEXT S
  106.     KEY(8) ON
  107.     Continue% = NO
  108.     DO
  109.         DO
  110.             IF Continue% = YES THEN EXIT DO
  111.         LOOP WHILE INKEY$ = ""
  112.         IF Continue% = YES THEN EXIT DO
  113.     LOOP
  114. VIEW PRINT 1 TO 25: COLOR 15, 0
  115. CLS 2
  116. '-----------------------------------------------------------------------------
  117. Keysoff: 'De-activate main menu softkeys
  118. FOR S = 1 TO 4
  119.     KEY(S) OFF
  120. KEY(8) OFF
  121. Callchoose: GOSUB Keysoff: CALL CHOOSE: Continue% = YES: RETURN
  122. Calledit: GOSUB Keysoff: CALL EDIT: Continue% = YES: RETURN
  123. Calltolerance: GOSUB Keysoff: CALL TOLERANCE: Continue% = YES: RETURN
  124. Callhistory: GOSUB Keysoff: CALL HISTORY: Continue% = YES: RETURN
  125. Quit: GOSUB Keysoff: Stay% = NO: Continue% = YES: RETURN
  126. Errhandler: '------------------------------------------------------------------
  127.     CASE 25, 27
  128.         SOUND 1000, 10
  129.         CALL State("PRINTER NOT READY - Check paper loaded & on-line, then press any key.")
  130.     CASE 53, 64, 76
  131.         Fileunfound% = TRUE
  132.         RESUME NEXT
  133.     CASE 58
  134.         Fileduplicate% = TRUE
  135.         RESUME NEXT
  136.     CASE 61, 72
  137.         SOUND 1500, 5
  138.         CALL State("DISK FULL OR BAD - Replace disk, then press any key.")
  139.     CASE 71
  140.         SOUND 1500, 5
  141.         CALL State("DISK WRITE-PROTECTED - Replace or unprotect disk, then press any key.")
  142.     CASE ELSE
  143.         'SOUND 800, 15
  144.         Message$ = "ERROR NUMBER " + STR$(ERR)
  145.         CALL State(Message$)
  146. CALL Waitkey
  147. CALL State(SPACE$(80))
  148. IF (ERR = 25 OR ERR = 27) THEN
  149.     IF Ask%("Do you want to ABANDON PRINT") = YES THEN
  150.         Printerok% = NO
  151.         RESUME NEXT
  152.     END IF
  153.  
  154. DEFSNG A-Z
  155. SUB CHOOSE
  156.     CALL Edit.setup
  157.     Pathname$ = Drive$ + ":" + Path$ + Psf$
  158.     Fileunfound% = RESETFLAG
  159.     OPEN Pathname$ FOR INPUT AS #2
  160.     IF Fileunfound% = NO THEN
  161.         CALL Read.psf
  162.         CLOSE #2
  163.         Choose.done% = YES
  164.     ELSE
  165.         IF Psfoption$ = "PREVIOUS" THEN
  166.             PRINT "FAILED TO FIND PREVIOUS PSF "; Pathname$; ". Press any key."
  167.             CALL Waitkey
  168.         ELSEIF Ask%("This PSF does not exist. Do you want to CREATE NEW PSF") = YES THEN
  169.             State ("Just press ENTER FOR DEFAULT - C:\BLP\SPECS\SPECEDIT.PSF")
  170.             LOCATE 23: LINE INPUT ; "Enter TEMPLATE FILE pathname - "; Entry$
  171.             IF Entry$ = "" THEN
  172.                 Pathname$ = "C:\BLP\SPECS\SPECEDIT.PSF"
  173.             ELSE
  174.                 Pathname$ = UCASE$(LTRIM$(RTRIM$(Entry$)))
  175.             END IF
  176.             Fileunfound% = RESETFLAG
  177.             OPEN Pathname$ FOR INPUT AS #2
  178.             IF Fileunfound% = NO THEN
  179.                 CALL Read.psf
  180.                 CLOSE #2
  181.                 Psf.typeno$ = "******"
  182.                 Psf.preceding$ = "*"
  183.                 Choose.done% = YES
  184.             ELSE
  185.                 State ("Could not find " + Pathname$ + " Press any key.")
  186.                 Waitkey
  187.             END IF
  188.         END IF
  189.     END IF
  190.  
  191. SUB EDIT
  192.     IF Choose.done% = NO THEN
  193.         SOUND 300, 4
  194.         CALL State("Working file not specified yet; select CHOOSE first. Press any key.")
  195.         CALL Waitkey
  196.         EXIT SUB
  197.     END IF
  198.     CLS 2
  199.     Issue.raised% = NO
  200.     IF Psfoption$ = "CURRENT" THEN
  201.         IF Psf.typeno$ = "******" THEN 'New PSF
  202.             Valid% = NO
  203.             WHILE Valid% = NO
  204.                 CALL State("The issue must be a valid DOS filename extension.")
  205.                 LOCATE 23, 1: PRINT SPACE$(80);
  206.                 LOCATE 23, 1: LINE INPUT "Enter the FIRST ISSUE (up to 3 characters), or ENTER for A - "; New.iss$
  207.                 IF New.iss$ = "" THEN New.iss$ = "A"
  208.                 New.iss$ = LEFT$(New.iss$, 3)
  209.                 IF Dosvalid%(New.iss$) = YES THEN
  210.                     Valid% = YES
  211.                 ELSE
  212.                     SOUND 300, 4
  213.                 END IF
  214.             WEND
  215.             Psf.progiss$ = New.iss$
  216.             Psf.preceding$ = "*"
  217.         ELSE
  218.             Stay% = YES
  219.             WHILE Stay% = YES
  220.                 CALL State("If you up-issue, the loaded CURRENT PSF is first archived as a PREVIOUS PSF.")
  221.                 IF Ask%("Are you CHANGING THE ISSUE of the test program & PSF") = YES THEN
  222.                     Valid% = NO
  223.                     WHILE Valid% = NO
  224.                         CALL State("Current issue is " + Psf.progiss$ + ". The issue must be a valid DOS filename extension.")
  225.                         LOCATE 23, 1: PRINT SPACE$(80);
  226.                         LOCATE 23, 1: LINE INPUT "Enter the NEW ISSUE (up to 3 characters): "; New.iss$
  227.                         New.iss$ = LEFT$(New.iss$, 3)
  228.                         IF Dosvalid%(New.iss$) = YES THEN
  229.                             Valid% = YES
  230.                         ELSE
  231.                             SOUND 300, 4
  232.                         END IF
  233.                     WEND
  234.                     CALL State("About to change issue from " + Psf.progiss$ + " to " + New.iss$)
  235.                     IF Ask%("Are you sure you want to CHANGE ISSUE NOW") = YES THEN
  236.                         Filename$ = TType.number$ + "P." + Psf.progiss$
  237.                         OPEN Drive$ + ":" + Path$ + Filename$ FOR OUTPUT AS #3
  238.                         CALL Write.psf
  239.                         CLOSE #3
  240.                         Issue.raised% = YES
  241.                         Psf.preceding$ = Psf.progiss$
  242.                         Psf.progiss$ = New.iss$
  243.                         Stay% = NO
  244.                     END IF
  245.                 ELSE
  246.                     Stay% = NO
  247.                 END IF
  248.             WEND
  249.         END IF
  250.     END IF
  251.     CALL Show.bars
  252.     COLOR , 4
  253.     Pageno% = 1
  254.     Stay% = YES
  255.     WHILE Stay% = YES
  256.         SELECT CASE Pageno%
  257.             CASE 0
  258.                 Stay% = NO
  259.             CASE 1
  260.                 CALL Edit.head1(Pageno%)
  261.                 Edit.set% = 0: Edit.line% = 1: Copy.set% = 1
  262.             CASE 2
  263.                 CALL Edit.head2(Pageno%, Edit.set%, Edit.line%, Copy.set%)
  264.             CASE 3
  265.                 CALL Edit.param(Pageno%, Edit.set%, Edit.line%)
  266.         END SELECT
  267.     WEND
  268.     CLS 2
  269.     Save.file% = YES
  270.     IF Issue.raised% = NO THEN
  271.         CALL State("You can either save the edited PSF or quit without saving & lose any edits.")
  272.         IF Psfoption$ = "PREVIOUS" THEN
  273.             Question$ = "Do you wish to SAVE THE EDITED PREVIOUS PSF AS HYPOTHETICAL"
  274.         ELSE
  275.             Question$ = "Do you wish to SAVE THE EDITED PSF"
  276.         END IF
  277.         IF Ask%(Question$) = NO THEN
  278.             Save.file% = NO
  279.         ELSE
  280.             IF Psfoption$ = "PREVIOUS" THEN Psfoption$ = "HYPOTHETICAL"
  281.             IF Psfoption$ = "CURRENT" THEN
  282.                 CALL State("You can either save as CURRENT PSF (same issue) or convert to HYPOTHETICAL.")
  283.                 IF Ask("Do you wish to SAVE AS CURRENT PSF") = NO THEN Psfoption$ = "HYPOTHETICAL"
  284.             END IF
  285.         END IF
  286.     END IF
  287.     IF Save.file% = YES THEN
  288.         Psf$ = TType.number$ + LEFT$(Psfoption$, 1) + ".PSF"
  289.         OPEN Drive$ + ":" + Path$ + Psf$ FOR OUTPUT AS #3
  290.         CALL Write.psf
  291.         CLOSE #3
  292.     END IF
  293.  
  294. SUB Edit.head1 (Pageno%)
  295.     'Move cursor around first header screen and edit data
  296.     STATIC Hitempst AS STRING * 3
  297.     STATIC Lotempst AS STRING * 3
  298.     STATIC Sermarkst AS STRING * 1
  299.     Lineno% = 4
  300.     Stay% = YES
  301.     WHILE Stay% = YES
  302.         CALL Show.head1
  303.         IF Lineno% = 12 OR Lineno% = 18 THEN
  304.             Colno% = 1
  305.         ELSE
  306.             Colno% = 30
  307.         END IF
  308.         LOCATE Lineno%, Colno%
  309.         SELECT CASE Lineno%
  310.             CASE 4
  311.                 CALL Line.edit(Psf.typeno$, 6, Exit.code%)
  312.             CASE 7
  313.                 CALL Line.edit(Psf.progdate$, 10, Exit.code%)
  314.             CASE 8
  315.                 CALL Line.edit(Psf.sourcename$, 20, Exit.code%)
  316.             CASE 9
  317.                 CALL Line.edit(Psf.sourceiss$, 5, Exit.code%)
  318.             CASE 10
  319.                 CALL Line.edit(Psf.sourcedate$, 10, Exit.code%)
  320.             CASE 12
  321.                 CALL Line.edit(Psf.amendrefs$, 80, Exit.code%)
  322.             CASE 13
  323.                 CALL Line.edit(Psf.custype$, 20, Exit.code%)
  324.             CASE 14
  325.                 Hitempst$ = LTRIM$(STR$(Psf.hitemp%))
  326.                 CALL Line.edit(Hitempst$, 3, Exit.code%)
  327.                 Entry% = VAL(Hitempst$)
  328.                 IF Entry% = 999 THEN
  329.                     Psf.hitemp% = Entry%
  330.                 ELSE
  331.                     IF Checkint%(Entry%, 23, 200) = YES THEN Psf.hitemp% = Entry%
  332.                 END IF
  333.             CASE 15
  334.                 Lotempst$ = LTRIM$(STR$(Psf.lotemp%))
  335.                 CALL Line.edit(Lotempst$, 3, Exit.code%)
  336.                 Entry% = VAL(Lotempst$)
  337.                 IF Entry% = 999 THEN
  338.                     Psf.lotemp% = Entry%
  339.                 ELSE
  340.                     IF Checkint%(Entry%, -99, 23) = YES THEN Psf.lotemp% = Entry%
  341.                 END IF
  342.             CASE 16
  343.                 Sermarkst$ = LTRIM$(STR$(Psf.sermark%))
  344.                 CALL Line.edit(Sermarkst$, 1, Exit.code%)
  345.                 Entry% = VAL(Sermarkst$)
  346.                 IF Checkint%(Entry%, 0, 1) = YES THEN Psf.sermark% = Entry%
  347.             CASE 18
  348.                 CALL Line.edit(Psf.history$, 80, Exit.code%)
  349.             CASE 19
  350.                 CALL Line.edit(Psf.crn$, 6, Exit.code%)
  351.             CASE 20
  352.                 CALL Line.edit(Psf.eng$, 10, Exit.code%)
  353.         END SELECT
  354.         SELECT CASE Exit.code%
  355.             CASE 9, 80, 13 'TAB, Down, ENTER
  356.                 SELECT CASE Lineno%
  357.                     CASE 4
  358.                         Lineno% = Lineno% + 3
  359.                     CASE 10, 16
  360.                         Lineno% = Lineno% + 2
  361.                     CASE 20
  362.                     CASE ELSE
  363.                         Lineno% = Lineno% + 1
  364.                 END SELECT
  365.             CASE 15, 72 'Shift TAB, Up
  366.                 SELECT CASE Lineno%
  367.                     CASE 4
  368.                     CASE 7
  369.                         Lineno% = Lineno% - 3
  370.                     CASE 12, 18
  371.                         Lineno% = Lineno% - 2
  372.                     CASE ELSE
  373.                         Lineno% = Lineno% - 1
  374.                 END SELECT
  375.             CASE 71 'Home
  376.                 Lineno% = 4
  377.             CASE 79 'End
  378.                 Lineno% = 20
  379.             CASE 81 'Pg Down
  380.                 Pageno% = 2
  381.                 Stay% = NO
  382.             CASE 73 'Pg Up
  383.             CASE 27 'ESC
  384.                 Pageno% = 0
  385.                 Stay% = NO
  386.         END SELECT
  387.     WEND
  388.  
  389. SUB Edit.head2 (Pageno%, Edit.set%, Edit.line%, Copy.set%)
  390.     'Move cursor around second header screen and edit data
  391.     STATIC Numparsst AS STRING * 3
  392.     STATIC Numspacesst AS STRING * 3
  393.     STATIC Setst AS STRING * 1
  394.     STATIC Linest AS STRING * 3
  395.     STATIC Copysetst AS STRING * 1
  396.     Lineno% = 5
  397.     Stay% = YES
  398.     WHILE Stay% = YES
  399.         CALL Show.head2(Edit.set%, Edit.line%, Copy.set%)
  400.         IF Lineno% < 10 THEN
  401.             Colno% = 1
  402.         ELSE
  403.             Colno% = 30
  404.         END IF
  405.         LOCATE Lineno%, Colno%
  406.         SELECT CASE Lineno%
  407.             CASE 5
  408.                 CALL Line.edit(Psf.comment1$, 80, Exit.code%)
  409.             CASE 6
  410.                 CALL Line.edit(Psf.comment2$, 80, Exit.code%)
  411.             CASE 7
  412.                 CALL Line.edit(Psf.comment3$, 80, Exit.code%)
  413.             CASE 8
  414.                 CALL Line.edit(Psf.comment4$, 80, Exit.code%)
  415.             CASE 9
  416.                 CALL Line.edit(Psf.comment5$, 80, Exit.code%)
  417.             CASE 11
  418.                 CALL Line.edit(Psf.setlabel$(0), 20, Exit.code%)
  419.             CASE 12
  420.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(0)))
  421.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  422.                 Entry% = VAL(Numparsst$)
  423.                 IF Checkint%(Entry%, 1, Psf.numspaces%) = YES THEN Psf.numpars%(0) = Entry%
  424.             CASE 13
  425.                 CALL Line.edit(Psf.setlabel$(1), 20, Exit.code%)
  426.             CASE 14
  427.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(1)))
  428.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  429.                 Entry% = VAL(Numparsst$)
  430.                 IF Checkint%(Entry%, 0, Psf.numspaces%) = YES THEN Psf.numpars%(1) = Entry%
  431.             CASE 15
  432.                 CALL Line.edit(Psf.setlabel$(2), 20, Exit.code%)
  433.             CASE 16
  434.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(2)))
  435.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  436.                 Entry% = VAL(Numparsst$)
  437.                 IF Checkint%(Entry%, 0, Psf.numspaces%) = YES THEN Psf.numpars%(2) = Entry%
  438.             CASE 17
  439.                 CALL Line.edit(Psf.setlabel$(3), 20, Exit.code%)
  440.             CASE 18
  441.                 Numparsst$ = LTRIM$(STR$(Psf.numpars%(3)))
  442.                 CALL Line.edit(Numparsst$, 3, Exit.code%)
  443.                 Entry% = VAL(Numparsst$)
  444.                 IF Checkint%(Entry%, 0, Psf.numspaces%) = YES THEN Psf.numpars%(3) = Entry%
  445.             CASE 19
  446.                 Numspacesst$ = LTRIM$(STR$(Psf.numspaces%))
  447.                 CALL Line.edit(Numspacesst$, 3, Exit.code%)
  448.                 Entry% = VAL(Numspacesst$)
  449.                 IF Checkint%(Entry%, 1, 220) = YES THEN Psf.numspaces% = Entry%
  450.             CASE 21
  451.                 Setst$ = LTRIM$(STR$(Edit.set%))
  452.                 CALL Line.edit(Setst$, 1, Exit.code%)
  453.                 Entry% = VAL(Setst$)
  454.                 IF Checkint%(Entry%, 0, Psf.numsets%) = YES THEN Edit.set% = Entry%
  455.             CASE 22
  456.                 Linest$ = LTRIM$(STR$(Edit.line%))
  457.                 CALL Line.edit(Linest$, 3, Exit.code%)
  458.                 Entry% = VAL(Linest$)
  459.                 IF Checkint%(Entry%, 1, 220) = YES THEN Edit.line% = Entry%
  460.             CASE 23
  461.                 Copysetst$ = LTRIM$(STR$(Copy.set%))
  462.                 CALL Line.edit(Copysetst$, 1, Exit.code%)
  463.                 Entry% = VAL(Copysetst$)
  464.                 IF Checkint%(Entry%, 0, Psf.numsets%) = YES THEN Copy.set% = Entry%
  465.         END SELECT
  466.         SELECT CASE Exit.code%
  467.             CASE 9, 80, 13 'TAB, Down, ENTER
  468.                 SELECT CASE Lineno%
  469.                     CASE 9, 19
  470.                         Lineno% = Lineno% + 2
  471.                     CASE 14
  472.                         Lineno% = 15: IF Psf.numpars%(1) = 0 THEN Lineno% = 19
  473.                     CASE 16
  474.                         Lineno% = 17: IF Psf.numpars%(2) = 0 THEN Lineno% = 19
  475.                     CASE 23
  476.                     CASE ELSE
  477.                         Lineno% = Lineno% + 1
  478.                 END SELECT
  479.             CASE 15, 72 'Shift TAB, Up
  480.                 SELECT CASE Lineno%
  481.                     CASE 5
  482.                     CASE 11, 21
  483.                         Lineno% = Lineno% - 2
  484.                     CASE 19
  485.                         IF Psf.numpars%(1) = 0 THEN
  486.                             Lineno% = 14
  487.                         ELSEIF Psf.numpars%(2) = 0 THEN
  488.                             Lineno% = 16
  489.                         ELSE
  490.                             Lineno% = 18
  491.                         END IF
  492.                     CASE ELSE
  493.                         Lineno% = Lineno% - 1
  494.                 END SELECT
  495.             CASE 71 'Home
  496.                 Lineno% = 5
  497.             CASE 79 'End
  498.                 Lineno% = 23
  499.             CASE 73 'Pg Up
  500.                 Pageno% = 1
  501.                 Stay% = NO
  502.             CASE 81 'Pg Down
  503.                 Pageno% = 3
  504.                 Stay% = NO
  505.             CASE 27 'ESC
  506.                 Pageno% = 0
  507.                 Stay% = NO
  508.             CASE 67 'F9
  509.                 Setst$ = LTRIM$(STR$(Edit.set%))
  510.                 IF Ask("Are you sure you want to MAKE INDICES = LINE NUMBERS in Set " + Setst$) = YES THEN
  511.                     FOR Line.number% = 1 TO Psf.numpars%(Edit.set%)
  512.                         Psfset(Edit.set%, Line.number%).Index = Line.number%
  513.                     NEXT Line.number%
  514.                 END IF
  515.                 COLOR , 4
  516.             CASE 68 'F10
  517.                 IF Copy.set% <> Edit.set% THEN
  518.                     Setst$ = LTRIM$(STR$(Edit.set%))
  519.                     Copysetst$ = LTRIM$(STR$(Copy.set%))
  520.                     IF Ask("Are you sure you want to COPY SET " + Setst$ + " TO SET " + Copysetst$) = YES THEN
  521.                         Psf.numpars%(Copy.set%) = Psf.numpars%(Edit.set%)
  522.                         FOR Line.number% = 1 TO Psf.numpars%(Edit.set%)
  523.                             Psfset(Copy.set%, Line.number%).Index = Psfset(Edit.set%, Line.number%).Index
  524.                             Psfset(Copy.set%, Line.number%).Label = Psfset(Edit.set%, Line.number%).Label
  525.                             Psfset(Copy.set%, Line.number%).Units = Psfset(Edit.set%, Line.number%).Units
  526.                             Psfset(Copy.set%, Line.number%).Lower = Psfset(Edit.set%, Line.number%).Lower
  527.                             Psfset(Copy.set%, Line.number%).Upper = Psfset(Edit.set%, Line.number%).Upper
  528.                         NEXT Line.number%
  529.                     END IF
  530.                 END IF
  531.                 COLOR , 4
  532.         END SELECT
  533.         IF Psf.numpars%(1) = 0 THEN
  534.             Psf.numpars%(2) = 0
  535.             Psf.numpars%(3) = 0
  536.             Psf.numsets% = 1
  537.         ELSEIF Psf.numpars%(2) = 0 THEN
  538.             Psf.numpars%(3) = 0
  539.             Psf.numsets% = 2
  540.         ELSEIF Psf.numpars%(3) = 0 THEN
  541.             Psf.numsets% = 3
  542.         ELSE
  543.             Psf.numsets% = 4
  544.         END IF
  545.         IF Edit.set% > Psf.numsets% THEN Edit.set% = Psf.numsets%
  546.         IF Copy.set% > Psf.numsets% THEN Copy.set% = Psf.numsets%
  547.     WEND
  548.     IF Edit.set% > Psf.numsets% - 1 THEN Edit.set% = Psf.numsets% - 1
  549.  
  550. SUB Edit.param (Pageno%, Edit.set%, Edit.line%)
  551.     'Scroll and edit parameter data
  552.     STATIC Indexst AS STRING * 3
  553.     STATIC Lowerst AS STRING * 10
  554.     STATIC Upperst AS STRING * 10
  555.     Colno% = 7
  556.     Stay% = YES
  557.     IF Psf.numpars%(Edit.set%) = 0 THEN
  558.         Pageno% = 2
  559.         Stay% = NO
  560.     END IF
  561.     WHILE Stay% = YES
  562.         CALL Show.param(Edit.set%, Edit.line%)
  563.         LOCATE 14, Colno%
  564.         SELECT CASE Colno%
  565.             CASE 7
  566.                 Indexst$ = LTRIM$(STR$(Psfset(Edit.set%, Edit.line%).Index))
  567.                 CALL Line.edit(Indexst$, 3, Exit.code%)
  568.                 Entry% = VAL(Indexst$)
  569.                 Unique% = YES
  570.                 FOR Line.number% = 1 TO Psf.numpars%(Edit.set%)
  571.                     IF Line.number% <> Edit.line% THEN
  572.                         IF Psfset(Edit.set%, Line.number%).Index = Entry% THEN Unique% = NO
  573.                     END IF
  574.                 NEXT Line.number%
  575.                 IF Unique% = YES THEN
  576.                     Psfset(Edit.set%, Edit.line%).Index = Entry%
  577.                 ELSE
  578.                     SOUND 300, 4: COLOR , 4: LOCATE 23, 1: PRINT "INDEX"; Entry%; "ALREADY USED! Indices must be unique within each set. Press any key.";
  579.                     CALL Waitkey
  580.                     Exit.code% = 0
  581.                 END IF
  582.             CASE 13
  583.                 CALL Line.edit(Psfset(Edit.set%, Edit.line%).Label, 24, Exit.code%)
  584.             CASE 40
  585.                 CALL Line.edit(Psfset(Edit.set%, Edit.line%).Units, 5, Exit.code%)
  586.             CASE 48
  587.                 Lowerst$ = LTRIM$(STR$(Psfset(Edit.set%, Edit.line%).Lower))
  588.                 CALL Line.edit(Lowerst$, 10, Exit.code%)
  589.                 Entry.real! = VAL(Lowerst$)
  590.                 IF Entry.real! < -9999.999 THEN Entry.real! = -9999.999
  591.                 IF Entry.real! > 9999.999 THEN Entry.real! = 9999.999
  592.                 Hilim! = Psfset(Edit.set%, Edit.line%).Upper
  593.                 IF Checkreal%(Entry.real!, -9999.999, Hilim!) = YES THEN
  594.                     Psfset(Edit.set%, Edit.line%).Lower = Entry.real!
  595.                 ELSE
  596.                     IF Exit.code% = 9 OR Exit.code% = 13 THEN
  597.                         Psfset(Edit.set%, Edit.line%).Lower = Entry.real!
  598.                     ELSE
  599.                         SOUND 300, 4: COLOR , 4: LOCATE 23, 1: PRINT "LIMITS OUT OF RANGE! (-/+9999.999 and LOWER < UPPER). Press any key.";
  600.                         CALL Waitkey
  601.                         Exit.code% = 0
  602.                     END IF
  603.                 END IF
  604.             CASE 61
  605.                 Upperst$ = LTRIM$(STR$(Psfset(Edit.set%, Edit.line%).Upper))
  606.                 CALL Line.edit(Upperst$, 10, Exit.code%)
  607.                 Entry.real! = VAL(Upperst$)
  608.                 IF Entry.real! < -9999.999 THEN Entry.real! = -9999.999
  609.                 IF Entry.real! > 9999.999 THEN Entry.real! = 9999.999
  610.                 Lolim! = Psfset(Edit.set%, Edit.line%).Lower
  611.                 IF Checkreal%(Entry.real!, Lolim!, 9999.999) = YES THEN
  612.                     Psfset(Edit.set%, Edit.line%).Upper = Entry.real!
  613.                 ELSE
  614.                     IF Exit.code% = 15 THEN
  615.                         Psfset(Edit.set%, Edit.line%).Upper = Entry.real!
  616.                     ELSE
  617.                         SOUND 300, 4: COLOR , 4: LOCATE 23, 1: PRINT "LIMITS OUT OF RANGE! (-/+9999.999 and LOWER < UPPER). Press any key.";
  618.                         CALL Waitkey
  619.                         Exit.code% = 0
  620.                     END IF
  621.                 END IF
  622.         END SELECT
  623.         SELECT CASE Exit.code%
  624.             CASE 0
  625.             CASE 9, 13 'TAB, ENTER
  626.                 IF Colno% < 13 THEN
  627.                     Colno% = 13
  628.                 ELSEIF Colno% < 40 THEN
  629.                     Colno% = 40
  630.                 ELSEIF Colno% < 48 THEN
  631.                     Colno% = 48
  632.                 ELSEIF Colno% < 61 THEN
  633.                     Colno% = 61
  634.                 END IF
  635.             CASE 15 'Shift TAB
  636.                 IF Colno% >= 61 THEN
  637.                     Colno% = 48
  638.                 ELSEIF Colno% >= 48 THEN
  639.                     Colno% = 40
  640.                 ELSEIF Colno% >= 40 THEN
  641.                     Colno% = 13
  642.                 ELSEIF Colno% >= 13 THEN
  643.                     Colno% = 7
  644.                 END IF
  645.             CASE 80 'Down
  646.                 IF Edit.line% < Psf.numpars%(Edit.set%) THEN Edit.line% = Edit.line% + 1
  647.             CASE 72 'Up
  648.                 IF Edit.line% > 1 THEN Edit.line% = Edit.line% - 1
  649.             CASE 71 'Home
  650.                 Edit.line% = 1
  651.             CASE 79 'End
  652.                 Edit.line% = Psf.numpars%(Edit.set%)
  653.             CASE 67 'F9
  654.                 IF Psf.numpars%(Edit.set%) < Psf.numspaces% THEN
  655.                     FOR Line.number% = Psf.numpars%(Edit.set%) TO Edit.line% STEP -1
  656.                         Psfset(Edit.set%, (Line.number% + 1)).Index = Psfset(Edit.set%, Line.number%).Index
  657.                         Psfset(Edit.set%, (Line.number% + 1)).Label = Psfset(Edit.set%, Line.number%).Label
  658.                         Psfset(Edit.set%, (Line.number% + 1)).Units = Psfset(Edit.set%, Line.number%).Units
  659.                         Psfset(Edit.set%, (Line.number% + 1)).Lower = Psfset(Edit.set%, Line.number%).Lower
  660.                         Psfset(Edit.set%, (Line.number% + 1)).Upper = Psfset(Edit.set%, Line.number%).Upper
  661.                     NEXT Line.number%
  662.                     Psfset(Edit.set%, Edit.line%).Index = 0
  663.                     Psfset(Edit.set%, Edit.line%).Label = ""
  664.                     Psfset(Edit.set%, Edit.line%).Units = ""
  665.                     Psfset(Edit.set%, Edit.line%).Lower = 0
  666.                     Psfset(Edit.set%, Edit.line%).Upper = 0
  667.                     Psf.numpars%(Edit.set%) = Psf.numpars%(Edit.set%) + 1
  668.                 ELSE
  669.                     SOUND 300, 4: COLOR , 4: LOCATE 23: PRINT "NO SPACE to insert new parameter! Increase TRF record size first. Press any key.";
  670.                     CALL Waitkey
  671.                 END IF
  672.             CASE 68 'F10
  673.                 IF Ask("Are you sure you want to DELETE THIS LINE") = YES THEN
  674.                     IF Edit.line% < Psf.numpars%(Edit.set%) THEN
  675.                         FOR Line.number% = Edit.line% + 1 TO Psf.numpars%(Edit.set%)
  676.                             Psfset(Edit.set%, (Line.number% - 1)).Index = Psfset(Edit.set%, Line.number%).Index
  677.                             Psfset(Edit.set%, (Line.number% - 1)).Label = Psfset(Edit.set%, Line.number%).Label
  678.                             Psfset(Edit.set%, (Line.number% - 1)).Units = Psfset(Edit.set%, Line.number%).Units
  679.                             Psfset(Edit.set%, (Line.number% - 1)).Lower = Psfset(Edit.set%, Line.number%).Lower
  680.                             Psfset(Edit.set%, (Line.number% - 1)).Upper = Psfset(Edit.set%, Line.number%).Upper
  681.                         NEXT Line.number%
  682.                     END IF
  683.                     Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Index = 0
  684.                     Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Label = ""
  685.                     Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Units = ""
  686.                     Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Lower = 0
  687.                     Psfset(Edit.set%, Psf.numpars%(Edit.set%)).Upper = 0
  688.                     Psf.numpars%(Edit.set%) = Psf.numpars%(Edit.set%) - 1
  689.                     IF Psf.numpars%(Edit.set%) = 0 THEN
  690.                         Pageno% = 2
  691.                         Stay% = NO
  692.                     END IF
  693.                 END IF
  694.                 COLOR , 4
  695.             CASE 73 'Pg Up
  696.                 Pageno% = 2
  697.                 Stay% = NO
  698.             CASE 81 'Pg Down
  699.             CASE 27 'ESC
  700.                 Pageno% = 0
  701.                 Stay% = NO
  702.         END SELECT
  703.     WEND
  704.  
  705. SUB Edit.setup
  706.     'Move cursor around setup screen and edit data
  707.     Prev.issue$ = "1  "
  708.     Lineno% = 9
  709.     Stay% = YES
  710.     WHILE Stay% = YES
  711.         CALL Show.bars
  712.         CALL Show.setup
  713.         LOCATE Lineno%, 20
  714.         SELECT CASE Lineno%
  715.             CASE 7
  716.                 CALL Line.edit(Drive$, 1, Exit.code%)
  717.                 Drive$ = UCASE$(LEFT$(Drive$, 1))
  718.             CASE 8
  719.                 CALL Line.edit(Path$, 40, Exit.code%)
  720.                 Path$ = UCASE$(LTRIM$(RTRIM$(Path$)))
  721.                 IF LEFT$(Path$, 1) <> "\" THEN Path$ = "\" + Path$
  722.                 IF RIGHT$(Path$, 1) <> "\" THEN Path$ = Path$ + "\"
  723.             CASE 9
  724.                 CALL Line.edit(TType.number$, 6, Exit.code%)
  725.             CASE 10
  726.                 Option$ = LEFT$(Psfoption$, 1)
  727.                 CALL Line.edit(Option$, 1, Exit.code%)
  728.                 Option$ = UCASE$(Option$)
  729.                 SELECT CASE Option$
  730.                     CASE "C"
  731.                         Psfoption$ = "CURRENT"
  732.                     CASE "P"
  733.                         Psfoption$ = "PREVIOUS"
  734.                     CASE "H"
  735.                         Psfoption$ = "HYPOTHETICAL"
  736.                 END SELECT
  737.             CASE 11
  738.                 Edit.prev.issue$ = Prev.issue$
  739.                 CALL Line.edit(Edit.prev.issue$, 3, Exit.code%)
  740.                 IF Dosvalid%(Edit.prev.issue$) = YES THEN Prev.issue$ = Edit.prev.issue$
  741.         END SELECT
  742.         SELECT CASE Exit.code%
  743.             CASE 80, 13 'Down, ENTER
  744.                 IF Lineno% < 10 THEN Lineno% = Lineno% + 1
  745.                 IF Lineno% = 10 AND Psfoption$ = "PREVIOUS" THEN Lineno% = 11
  746.             CASE 72 'Up
  747.                 IF Lineno% > 7 THEN Lineno% = Lineno% - 1
  748.             CASE 71 'Home
  749.                 Lineno% = 7
  750.             CASE 79 'End
  751.                 IF Psfoption$ = "PREVIOUS" THEN
  752.                     Lineno% = 11
  753.                 ELSE
  754.                     Lineno% = 10
  755.                 END IF
  756.             CASE 81, 73 'Pg Down, Pg Up
  757.             CASE 27 'ESC
  758.                 Stay% = NO
  759.         END SELECT
  760.     WEND
  761.     CALL Show.setup
  762.  
  763. SUB Hist.print
  764.     'Print out the History Report entry for the PSF now loaded
  765.     PRINT #1, " " '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<, just skip ???  blank line I bet!
  766.     IF Plain$(Psf.crn$) <> "NONE" THEN
  767.         Issued$ = ") issued under Change Note No. " + Psf.crn$
  768.     ELSE
  769.         Issued$ = ") not issued."
  770.     END IF
  771.     PRINT #1, Psfoption$; " ("; Psf$; Issued$
  772.     PRINT #1, "PROG Iss. "; Psf.progiss$; " - "; Psf.progdate$; "  SPEC "; Psf.sourcename$; " Iss. "; Psf.sourceiss$; " - "; Psf.sourcedate$
  773.     IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT #1, Psf.amendrefs$
  774.     PRINT #1, Psf.history$
  775.  
  776. SUB Hist.show
  777.     'Display the History Report entry for the PSF now loaded
  778.     COLOR 14, 4: PRINT
  779.     IF Plain$(Psf.crn$) <> "NONE" THEN
  780.         Issued$ = " issued under Change Note No. " + Psf.crn$
  781.     ELSE
  782.         Issued$ = " not issued."
  783.     END IF
  784.     COLOR 14: PRINT Psfoption$; " ("; Psf$; ")";: COLOR 15: PRINT Issued$
  785.     PRINT "PROG Iss. "; Psf.progiss$; " - "; Psf.progdate$; "  SPEC "; Psf.sourcename$; " Iss. "; Psf.sourceiss$; " - "; Psf.sourcedate$
  786.     IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT Psf.amendrefs$
  787.     PRINT Psf.history$
  788.  
  789. SUB HISTORY
  790.     STATIC Lotempst AS STRING * 8
  791.     STATIC Hitempst AS STRING * 8
  792.     IF Choose.done% = NO THEN
  793.         SOUND 300, 4
  794.         CALL State("Working file not specified yet; select CHOOSE first. Press any key.")
  795.         CALL Waitkey
  796.         EXIT SUB
  797.     END IF
  798.     IF Psfoption$ <> "CURRENT" THEN
  799.         SOUND 300, 4
  800.         CALL State("You can produce a History Report only from a CURRENT PSF . Press any key.")
  801.         CALL Waitkey
  802.         EXIT SUB
  803.     END IF
  804.     Pathname$ = Drive$ + ":" + Path$ + Psf$
  805.     Fileunfound% = RESETFLAG
  806.     OPEN Pathname$ FOR INPUT AS #2
  807.     IF Fileunfound% = NO THEN
  808.         CALL Read.psf
  809.         CLOSE #2
  810.     END IF
  811.     History.complete% = YES
  812.     CLS 2
  813.     LOCATE 3: COLOR 14
  814.     PRINT "HISTORY REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  815.     COLOR 15: PRINT STRING$(78, "-")
  816.     PRINT "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; "               Dated:"; Psf.progdate$
  817.     PRINT "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  818.     IF Psf.sermark% = YES THEN
  819.         Sermarked$ = "              Serial Marked"
  820.     ELSE
  821.         Sermarked$ = "              Not Serial Marked"
  822.     END IF
  823.     PRINT "Customer Reference:"; Psf.custype$; Sermarked$
  824.     IF Psf.lotemp% = 999 THEN
  825.         Lotempst$ = " N/A    "
  826.     ELSE
  827.         Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  828.     END IF
  829.     IF Psf.hitemp% = 999 THEN
  830.         Hitempst$ = " N/A    "
  831.     ELSE
  832.         Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  833.     END IF
  834.     PRINT "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  835.     PRINT STRING$(78, "-")
  836.     Line.counter% = 7
  837.     CALL Hist.show
  838.     Line.counter% = Line.counter% + 5
  839.     Psfoption$ = "PREVIOUS"
  840.     Preceding.issue% = Dosvalid%(Psf.preceding$)
  841.     WHILE Preceding.issue% = YES
  842.         Psf$ = TType.number$ + "P." + Noblanks$(Psf.preceding$)
  843.         Pathname$ = Drive$ + ":" + Path$ + Psf$
  844.         Fileunfound% = RESETFLAG
  845.         OPEN Pathname$ FOR INPUT AS #2
  846.         IF Fileunfound% = NO THEN
  847.             CALL Read.psf
  848.             CLOSE #2
  849.             CALL Hist.show
  850.             Line.counter% = Line.counter% + 5
  851.             Preceding.issue% = Dosvalid%(Psf.preceding$)
  852.             IF Line.counter% > 14 THEN
  853.                 CALL State("Press any key to continue."): COLOR 15, 4
  854.                 CALL Waitkey
  855.                 Line.counter% = 0
  856.                 CLS 2: LOCATE 3
  857.             END IF
  858.         ELSE
  859.             PRINT: COLOR 14
  860.             PRINT "HISTORY REPORT MAY BE INCOMPLETE: "; Psf$; " was referenced but not found."
  861.             COLOR 15
  862.             Preceding.issue% = NO
  863.             History.complete% = NO
  864.         END IF
  865.     WEND
  866.     IF History.complete% = YES THEN
  867.         PRINT: COLOR 14
  868.         PRINT "HISTORY REPORT COMPLETE."
  869.         COLOR 15
  870.     END IF
  871.     Psfoption$ = "CURRENT"
  872.     Psf$ = TType.number$ + "C.PSF"
  873.     Pathname$ = Drive$ + ":" + Path$ + Psf$
  874.     OPEN Pathname$ FOR INPUT AS #2
  875.     CALL Read.psf
  876.     CLOSE #2
  877.     IF Ask%("Do you want to PRINT THIS REPORT") = YES THEN
  878.         History.complete% = YES
  879.         PRINT #1, "HISTORY REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  880.         PRINT #1, STRING$(78, "-")
  881.         PRINT #1, "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; "               Dated:"; Psf.progdate$
  882.         PRINT #1, "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  883.         IF Psf.sermark% = YES THEN
  884.             Sermarked$ = "              Serial Marked"
  885.         ELSE
  886.             Sermarked$ = "              Not Serial Marked"
  887.         END IF
  888.         PRINT #1, "Customer Reference:"; Psf.custype$; Sermarked$
  889.         IF Psf.lotemp% = 999 THEN
  890.             Lotempst$ = " N/A    "
  891.         ELSE
  892.             Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  893.         END IF
  894.         IF Psf.hitemp% = 999 THEN
  895.             Hitempst$ = " N/A    "
  896.         ELSE
  897.             Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  898.         END IF
  899.         PRINT #1, "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  900.         PRINT #1, STRING$(78, "-")
  901.         CALL Hist.print
  902.         Line.counter% = 1
  903.         Psfoption$ = "PREVIOUS"
  904.         Preceding.issue% = Dosvalid%(Psf.preceding$)
  905.         WHILE Preceding.issue% = YES
  906.             Psf$ = TType.number$ + "P." + Noblanks$(Psf.preceding$)
  907.             Pathname$ = Drive$ + ":" + Path$ + Psf$
  908.             Fileunfound% = RESETFLAG
  909.             OPEN Pathname$ FOR INPUT AS #2
  910.             IF Fileunfound% = NO THEN
  911.                 CALL Read.psf
  912.                 CLOSE #2
  913.                 CALL Hist.print
  914.                 Line.counter% = Line.counter% + 1
  915.                 Preceding.issue% = Dosvalid%(Psf.preceding$)
  916.             ELSE
  917.                 PRINT #1, " "
  918.                 PRINT #1, "HISTORY REPORT MAY BE INCOMPLETE: "; Psf$; " was referenced but not found."
  919.                 Preceding.issue% = NO
  920.                 History.complete% = NO
  921.             END IF
  922.         WEND
  923.         IF History.complete% = YES THEN
  924.             PRINT #1, " "
  925.             PRINT #1, "HISTORY REPORT COMPLETE."
  926.         END IF
  927.         PRINT #1, CHR$(12)
  928.         Psfoption$ = "CURRENT" ' Restore current file
  929.         Psf$ = TType.number$ + "C.PSF"
  930.         Pathname$ = Drive$ + ":" + Path$ + Psf$
  931.         OPEN Pathname$ FOR INPUT AS #2
  932.         CALL Read.psf
  933.         CLOSE #2
  934.     END IF
  935.  
  936. SUB Init.vars
  937.     'Initialise all shared variables
  938.  
  939.     Fileunfound% = RESETFLAG
  940.     OPEN "C:\BLP\SPECS\OPTIONH.PSF" FOR INPUT AS #2
  941.     IF Fileunfound% = NO THEN
  942.         CALL Read.psf
  943.         CLOSE #2
  944.         Host$ = Psf.custype$
  945.         Drive$ = UCASE$(LEFT$(Psf.progdate$, 1))
  946.     ELSE
  947.         Host$ = ""
  948.         Drive$ = "C"
  949.     END IF
  950.  
  951.     Printerok% = YES
  952.     TType.number$ = "~~~~~~"
  953.     Choose.done% = NO
  954.     Path$ = "\BLP\SPECS\"
  955.     Psf$ = "SPECEDIT.PSF"
  956.     Psfoption$ = "CURRENT"
  957.     Fileunfound% = FALSE
  958.     Fileduplicate% = FALSE
  959.  
  960.  
  961. SUB Line.edit (Edit.string$, Field.size%, Exit.code%)
  962.     'Line editor - processes left & right arrow, delete and insert keys to edit
  963.     'Edit.string$, which is padded if necessary to a length of Field.size%.
  964.     'Exit.code% is ASCII code of key used to quit line edit:- TAB, Shift+TAB, Up,
  965.     'Down, ENTER, Pg Up, Pg Down, ESC, Home, End, F9, F10
  966.     COLOR , 0
  967.     IF Field.size% < LEN(Edit.string$) THEN
  968.         PRINT "Line.edit: Edit string exceeds field size": STOP
  969.     END IF
  970.     Start.char% = POS(0)
  971.     End.char% = Start.char% + Field.size% - 1
  972.     Char% = Start.char%
  973.     Insert.mode% = NO: LOCATE , , , 0, 7
  974.     Stay% = YES
  975.     WHILE Stay% = YES
  976.         Spaces% = Field.size% - LEN(Edit.string$)
  977.         Edit.string$ = Edit.string$ + STRING$(Spaces%, " ")
  978.         LOCATE , Start.char%: PRINT Edit.string$;: LOCATE , Char%, 1
  979.         Chars.left% = Char% - Start.char%
  980.         Chars.right% = Start.char% + LEN(Edit.string$) - Char% - 1: IF Chars.right% < 0 THEN Chars.right% = 0
  981.         Left.part$ = LEFT$(Edit.string$, Chars.left%)
  982.         Right.part$ = RIGHT$(Edit.string$, Chars.right%)
  983.         Incl.right.part$ = RIGHT$(Edit.string$, Chars.right% + 1)
  984.         DO
  985.             K$ = INKEY$
  986.         LOOP WHILE K$ <> "" 'Empty keyboard buffer
  987.         DO
  988.             K$ = INKEY$
  989.         LOOP WHILE K$ = ""
  990.         Keycode$ = RIGHT$(K$, 1)
  991.         Ascii% = ASC(Keycode$)
  992.         IF LEN(K$) = 2 THEN Ascii% = Ascii% * 100 ' EXTENDED CODE
  993.         SELECT CASE Ascii%
  994.             CASE 8, 7500 'LEFT
  995.                 IF Char% > Start.char% THEN Char% = Char% - 1: LOCATE , Char%
  996.             CASE 7700 'RIGHT
  997.                 IF Char% < End.char% THEN Char% = Char% + 1: LOCATE , Char%
  998.             CASE 8200 'INSERT
  999.                 IF Insert.mode% = NO THEN
  1000.                     Insert.mode% = YES: LOCATE , , , 7, 7
  1001.                 ELSE
  1002.                     Insert.mode% = NO: LOCATE , , , 0, 7
  1003.                 END IF
  1004.             CASE 8300 'DELETE
  1005.                 Edit.string$ = Left.part$ + Right.part$
  1006.             CASE 9, 1500, 7200, 8000, 13, 7300, 8100, 27, 7100, 7900, 6700, 6800 'EXIT CODES
  1007.                 Exit.code% = Ascii%: IF Exit.code% > 255 THEN Exit.code% = Exit.code% / 100
  1008.                 LOCATE , , 0, 7, 7
  1009.                 Stay% = NO
  1010.             CASE ELSE 'CHARACTER
  1011.                 IF Ascii% > 31 AND Ascii% < 128 THEN
  1012.                     IF Insert.mode% = YES THEN
  1013.                         Edit.string$ = Left.part$ + CHR$(Ascii%) + LEFT$(Incl.right.part$, Chars.right%)
  1014.                     ELSE 'Overwrite
  1015.                         Edit.string$ = Left.part$ + CHR$(Ascii%) + Right.part$
  1016.                     END IF
  1017.                     IF Char% < End.char% THEN Char% = Char% + 1: LOCATE , Char%
  1018.                 END IF
  1019.         END SELECT
  1020.     WEND
  1021.     COLOR , 4
  1022.  
  1023. SUB Read.psf
  1024.     'Enter all data from PSF file, which has already been opened as #2
  1025.     DIM Psfparamst AS Psfparamsttype
  1026.     LINE INPUT #2, Psf.typeno$: LINE INPUT #2, Psf.progiss$
  1027.     LINE INPUT #2, Psf.preceding$: LINE INPUT #2, Psf.progdate$
  1028.     LINE INPUT #2, Psf.sourcename$: LINE INPUT #2, Psf.sourceiss$
  1029.     LINE INPUT #2, Psf.sourcedate$: LINE INPUT #2, Psf.amendrefs$
  1030.     LINE INPUT #2, Psf.custype$: LINE INPUT #2, Psf.hitempst$
  1031.     LINE INPUT #2, Psf.lotempst$: LINE INPUT #2, Psf.sermarkst$
  1032.     LINE INPUT #2, Psf.history$: LINE INPUT #2, Psf.crn$
  1033.     LINE INPUT #2, Psf.eng$: LINE INPUT #2, Psf.comment1$
  1034.     LINE INPUT #2, Psf.comment2$: LINE INPUT #2, Psf.comment3$
  1035.     LINE INPUT #2, Psf.comment4$: LINE INPUT #2, Psf.comment5$
  1036.     LINE INPUT #2, Psf.numsetsst$
  1037.     Psf.numsets% = VAL(Psf.numsetsst$)
  1038.     FOR Setno% = 0 TO Psf.numsets% - 1
  1039.         LINE INPUT #2, Psf.numparsst$
  1040.         Psf.numpars%(Setno%) = VAL(Psf.numparsst$)
  1041.     NEXT Setno%
  1042.     FOR Setno% = Psf.numsets% TO 3 'Clear unused parameter sets
  1043.         Psf.numpars%(Setno%) = 0
  1044.     NEXT Setno%
  1045.     LINE INPUT #2, Psf.numspacesst$
  1046.     FOR Setno% = 0 TO Psf.numsets% - 1
  1047.         LINE INPUT #2, Psf.setlabel$(Setno%)
  1048.     NEXT Setno%
  1049.     FOR Setno% = Psf.numsets% TO 3 'Clear unused parameter sets
  1050.         Psf.setlabel$(Setno%) = ""
  1051.     NEXT Setno%
  1052.     FOR Setno% = 0 TO Psf.numsets% - 1
  1053.         FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1054.             LINE INPUT #2, Psfparamst.Index
  1055.             LINE INPUT #2, Psfparamst.Label
  1056.             LINE INPUT #2, Psfparamst.Units
  1057.             LINE INPUT #2, Psfparamst.Lower
  1058.             LINE INPUT #2, Psfparamst.Upper
  1059.             Psfset(Setno%, Paramno%).Index = VAL(Psfparamst.Index)
  1060.             Psfset(Setno%, Paramno%).Label = Psfparamst.Label
  1061.             Psfset(Setno%, Paramno%).Units = Psfparamst.Units
  1062.             Psfset(Setno%, Paramno%).Lower = VAL(Psfparamst.Lower) / 10000
  1063.             Psfset(Setno%, Paramno%).Upper = VAL(Psfparamst.Upper) / 10000
  1064.         NEXT Paramno%
  1065.     NEXT Setno%
  1066.     Psf.hitemp% = VAL(Psf.hitempst$)
  1067.     Psf.lotemp% = VAL(Psf.lotempst$)
  1068.     Psf.sermark% = VAL(Psf.sermarkst$)
  1069.     Psf.numspaces% = VAL(Psf.numspacesst$)
  1070.  
  1071. SUB Show.bars
  1072.     'Display / refresh status bars at top & bottom of screen
  1073.     Linenum% = CSRLIN
  1074.     Colnum% = POS(0)
  1075.     VIEW PRINT 1 TO 25: COLOR 4, 7
  1076.     LOCATE 1, 1: PRINT SPACE$(80);
  1077.     LOCATE 1, 1: PRINT "***  SPECification EDITor   SOFTWARE ISSUE "; Softiss$; Softdate$;: LOCATE 1, 66: PRINT "S J OXLEY   ***";
  1078.     LOCATE 25, 1: PRINT "***"; SPACE$(74); "***";
  1079.     IF Choose.done% = YES THEN
  1080.         Specpath$ = Drive$ + ":" + Path$
  1081.         IF LEN(Specpath$) > 22 THEN Specpath$ = LEFT$(Specpath$, 19) + "..."
  1082.         LOCATE 25, 5: PRINT "Directory "; Specpath$; "  File "; TType.number$; " - "; Psfoption$;
  1083.         IF Psfoption$ <> "HYPOTHETICAL" THEN PRINT "  Issue: "; Psf.progiss$;
  1084.     ELSE
  1085.         LOCATE 25, 5: PRINT "Working File not chosen.  ";
  1086.         LOCATE 25, 40: COLOR 0: PRINT "Running on "; Host$;
  1087.     END IF
  1088.     VIEW PRINT 2 TO 24: COLOR 15, 4
  1089.     LOCATE Linenum%, Colnum%
  1090.  
  1091. SUB Show.head1
  1092.     'Display first header edit screen
  1093.     STATIC Hitempst AS STRING * 3
  1094.     STATIC Lotempst AS STRING * 3
  1095.     STATIC Sermarkst AS STRING * 1
  1096.     CLS 2
  1097.     LOCATE 2: PRINT "Page 1";
  1098.     LOCATE , 30: COLOR 15: PRINT "Main Header Data";: COLOR 14: PRINT "      (Yellow fields are optional.)"
  1099.     PRINT
  1100.     COLOR 15, 4: PRINT "Type Number";: LOCATE , 30: COLOR , 1: PRINT Psf.typeno$
  1101.     COLOR 15, 4: PRINT "Program Issue";: LOCATE , 30: PRINT Psf.progiss$
  1102.     COLOR 15, 4: PRINT "Preceding Program Issue";: LOCATE , 30: PRINT Psf.preceding$
  1103.     COLOR 15, 4: PRINT "Program Date";: LOCATE , 30: COLOR , 1: PRINT Psf.progdate$
  1104.     COLOR 15, 4: PRINT "Source Spec Name";: LOCATE , 30: COLOR , 1: PRINT Psf.sourcename$
  1105.     COLOR 15, 4: PRINT "Source Spec Issue";: LOCATE , 30: COLOR , 1: PRINT Psf.sourceiss$
  1106.     COLOR 14, 4: PRINT "Source Spec Date";: LOCATE , 30: COLOR 15, 1: PRINT Psf.sourcedate$
  1107.     COLOR 14, 4: PRINT "Source Spec Amendments..."
  1108.     COLOR 15, 1: PRINT Psf.amendrefs$
  1109.     COLOR 14, 4: PRINT "Customer Type";: LOCATE , 30: COLOR 15, 1: PRINT Psf.custype$
  1110.     Hitempst$ = LTRIM$(STR$(Psf.hitemp%))
  1111.     COLOR 15, 4: PRINT "High Temperature [23 to 200]";: LOCATE , 30: COLOR , 1: PRINT Hitempst$;: COLOR , 4: PRINT "    (Enter 999 if not applicable.)"
  1112.     Lotempst$ = LTRIM$(STR$(Psf.lotemp%))
  1113.     COLOR 15, 4: PRINT "Low Temperature [-99 to 23]";: LOCATE , 30: COLOR , 1: PRINT Lotempst$;: COLOR , 4: PRINT "    (Enter 999 if not applicable.)"
  1114.     Sermarkst$ = LTRIM$(STR$(Psf.sermark%))
  1115.     COLOR 15, 4: PRINT "Serial Marked";: LOCATE , 30: COLOR , 1: PRINT Sermarkst$;: COLOR , 4: PRINT "      (Enter [0]/1 for [not] serial marked.)"
  1116.     COLOR 15, 4: PRINT "Change History..."
  1117.     COLOR , 1: PRINT Psf.history$
  1118.     COLOR 15, 4: PRINT "Change Note Number";: LOCATE , 30: COLOR , 1: PRINT Psf.crn$;: COLOR , 4: PRINT " (Enter NONE for pre-issue program.)"
  1119.     COLOR 14, 4: PRINT "Engineer Responsible";: LOCATE , 30: COLOR 15, 1: PRINT Psf.eng$
  1120.     LOCATE 24
  1121.     COLOR 15, 2: PRINT "Up/Dn, Home/End, TAB keys to move; Ins/Del as normal; Pg Dn for P.2; ESC to quit";: COLOR 15, 4
  1122.  
  1123.  
  1124. SUB Show.head2 (Edit.set%, Edit.line%, Copy.set%)
  1125.     'Display second header edit screen
  1126.     STATIC Numparsst AS STRING * 3
  1127.     STATIC Numspacesst AS STRING * 3
  1128.     STATIC Setst AS STRING * 1
  1129.     STATIC Linest AS STRING * 3
  1130.     STATIC Copysetst AS STRING * 1
  1131.     CLS 2
  1132.     LOCATE 2: PRINT "Page 2";
  1133.     LOCATE , 30: PRINT "Comments & Parameter Set Data"
  1134.     PRINT
  1135.     COLOR 14, 4: PRINT "Comments...": COLOR 15, 1
  1136.     PRINT Psf.comment1$
  1137.     PRINT Psf.comment2$
  1138.     PRINT Psf.comment3$
  1139.     PRINT Psf.comment4$
  1140.     PRINT Psf.comment5$
  1141.     PRINT
  1142.     COLOR 15, 4: PRINT "Parameter Set 0 Label";: LOCATE , 30: COLOR , 1: PRINT Psf.setlabel$(0)
  1143.     Numparsst$ = LTRIM$(STR$(Psf.numpars%(0)))
  1144.     COLOR 15, 4: PRINT "                Size";: LOCATE , 30: COLOR , 1: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size.)"
  1145.     COLOR 14, 4: PRINT "Parameter Set 1 Label";: LOCATE , 30: COLOR 15, 1: PRINT Psf.setlabel$(1)
  1146.     Numparsst$ = LTRIM$(STR$(Psf.numpars%(1)))
  1147.     COLOR 14, 4: PRINT "                Size";: LOCATE , 30: COLOR 15, 1: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size, 0 if unused.)"
  1148.     Col% = 1: IF Psf.numpars(1) = 0 THEN Col% = 4
  1149.     COLOR 14, 4: PRINT "Parameter Set 2 Label";: LOCATE , 30: COLOR 15, Col%: PRINT Psf.setlabel$(2)
  1150.     Numparsst$ = LTRIM$(STR$(Psf.numpars%(2)))
  1151.     COLOR 14, 4: PRINT "                Size";: LOCATE , 30: COLOR 15, Col%: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size, 0 if unused.)"
  1152.     Col% = 1: IF Psf.numpars(2) = 0 THEN Col% = 4
  1153.     COLOR 14, 4: PRINT "Parameter Set 3 Label";: LOCATE , 30: COLOR 15, Col%: PRINT Psf.setlabel$(3)
  1154.     Numparsst$ = LTRIM$(STR$(Psf.numpars%(3)))
  1155.     COLOR 14, 4: PRINT "                Size";: LOCATE , 30: COLOR 15, Col%: PRINT Numparsst$;: COLOR , 4: PRINT "  (1 to TRF record size, 0 if unused.)"
  1156.     Numspacesst$ = LTRIM$(STR$(Psf.numspaces%))
  1157.     COLOR 15, 4: PRINT "TRF Record Size";: LOCATE , 30: COLOR , 1: PRINT Numspacesst$;: COLOR , 4: PRINT "  (1 to 220 parameter spaces in TRF record.)"
  1158.     PRINT
  1159.     COLOR 15, 2: PRINT SPACE$(80): PRINT SPACE$(80): PRINT SPACE$(80);: LOCATE 20
  1160.     Setst$ = LTRIM$(STR$(Edit.set%))
  1161.     COLOR 15, 2: PRINT "             Current Set";: LOCATE , 30: COLOR , 0: PRINT Setst$;
  1162.     COLOR , 2: LOCATE , 35: PRINT "Pg Dn to Edit Current Line in Current Set"
  1163.     Linest$ = LTRIM$(STR$(Edit.line%))
  1164.     COLOR 15, 2: PRINT "             Current Line";: LOCATE , 30: COLOR , 0: PRINT Linest$;
  1165.     Copysetst$ = LTRIM$(STR$(Copy.set%))
  1166.     COLOR , 2: LOCATE , 35: PRINT "F9 for Default Indices in Current Set";
  1167.     COLOR 15, 2: PRINT "             Destination Set";: LOCATE , 30: COLOR , 0: PRINT Copysetst$;
  1168.     COLOR , 2: LOCATE , 35: PRINT "F10 to Copy Current Set to Destination Set";
  1169.     LOCATE 23
  1170.     COLOR 15, 2: PRINT "Up/Dn, Home/End or TAB keys to move; Ins; Del; Pg Up/Dn for P.1/P.3; ESC to quit";: COLOR 15, 4
  1171.  
  1172. SUB Show.param (Edit.set%, Edit.line%)
  1173.     'Display parameter edit screen
  1174.     STATIC Indexst AS STRING * 3
  1175.     STATIC Lowerst AS STRING * 10
  1176.     STATIC Upperst AS STRING * 10
  1177.     CLS 2
  1178.     Setlabelst$ = "- " + Psf.setlabel$(Edit.set%)
  1179.     LOCATE 2: PRINT "Page 3";: LOCATE , 30: PRINT "Parameter Data for Set"; Edit.set%; Setlabelst$
  1180.     COLOR 15, 4: LOCATE 4, 1: PRINT "Line  IND.  LABEL                      UNITS   LOWER        UPPER        Line"
  1181.     IF Edit.line% > Psf.numpars%(Edit.set%) THEN Edit.line% = Psf.numpars%(Edit.set%)
  1182.     IF Edit.line% < 1 THEN Edit.line% = 1
  1183.     FOR Line.number% = Edit.line% - 9 TO Edit.line% + 8
  1184.         IF Line.number% > 0 AND Line.number% <= Psf.numpars%(Edit.set%) THEN
  1185.             COLOR 15, 4: PRINT Line.number%;
  1186.             IF Line.number% = Edit.line% THEN
  1187.                 COLOR 15, 1
  1188.             ELSE
  1189.                 COLOR 14
  1190.             END IF
  1191.             Indexst$ = LTRIM$(STR$(Psfset(Edit.set%, Line.number%).Index))
  1192.             LOCATE , 7: PRINT Indexst$;
  1193.             LOCATE , 13: PRINT Psfset(Edit.set%, Line.number%).Label;
  1194.             LOCATE , 40: PRINT Psfset(Edit.set%, Line.number%).Units;
  1195.             Lowerst$ = LTRIM$(STR$(Psfset(Edit.set%, Line.number%).Lower))
  1196.             LOCATE , 48: PRINT Lowerst$;
  1197.             Upperst$ = LTRIM$(STR$(Psfset(Edit.set%, Line.number%).Upper))
  1198.             LOCATE , 61: PRINT Upperst$;
  1199.             LOCATE , 74: COLOR 15, 4: PRINT Line.number%
  1200.         ELSE
  1201.             PRINT
  1202.         END IF
  1203.     NEXT Line.number%
  1204.     Lowval! = Psfset(Edit.set%, Edit.line%).Lower
  1205.     Upval! = Psfset(Edit.set%, Edit.line%).Upper
  1206.     IF Lowval! > Upval! THEN
  1207.         LOCATE 23, 15: COLOR 10, 1: PRINT " Lower limit is greater than upper limit.      "
  1208.     ELSE
  1209.         Unit$ = LTRIM$(RTRIM$(Psfset(Edit.set%, Edit.line%).Units))
  1210.         Nominal! = (Round!(((Lowval! + Upval!) / 2), 3))
  1211.         Nomval$ = LTRIM$(RTRIM$(STR$(Nominal!)))
  1212.         IF LEFT$(Nomval$, 1) = "." THEN Nomval$ = "0" + Nomval$
  1213.         Rangeval$ = LTRIM$(RTRIM$(STR$(Round!(((Upval! - Lowval!) / 2), 3))))
  1214.         IF LEFT$(Rangeval$, 1) = "." THEN Rangeval$ = "0" + Rangeval$
  1215.         IF Lowval! * Upval! <= 0 OR INSTR(Unit$, "dB") > 0 OR INSTR(Unit$, "%") > 0 THEN
  1216.             LOCATE 23, 15: COLOR 10, 1: PRINT " Specified Value: "; Nomval$; Unit$; " "; CHR$(241); " "; Rangeval$; Unit$; " "
  1217.         ELSE
  1218.             Tolval$ = LTRIM$(RTRIM$(STR$(Round!((ABS(100 * (Upval! - Lowval!) / 2 / Nominal!)), 2))))
  1219.             IF LEFT$(Tolval$, 1) = "." THEN Tolval$ = "0" + Tolval$
  1220.             LOCATE 23, 15: COLOR 10, 1: PRINT " Specified Value: "; Nomval$; Unit$; " "; CHR$(241); " "; Rangeval$; Unit$; " ("; Tolval$; "%) "
  1221.         END IF
  1222.     END IF
  1223.     COLOR 15, 2: PRINT "Arrow & TAB keys to move; F9/F10 Insert/Delete line; Pg Up for P.2; ESC to quit ";: COLOR 15, 4
  1224.  
  1225. SUB Show.setup
  1226.     'Display current CHOOSE options
  1227.     CLS 2
  1228.     LOCATE 5, 20: COLOR 15: PRINT "Working Directory & PSF Selection"
  1229.     PRINT
  1230.     COLOR 15, 4: PRINT "Drive";: LOCATE , 20: COLOR , 1: PRINT Drive$
  1231.     COLOR 15, 4: PRINT "Path";: LOCATE , 20: COLOR , 1: PRINT Path$
  1232.     COLOR 15, 4: PRINT "Product type";: LOCATE , 20: COLOR , 1: PRINT TType.number$
  1233.     Option$ = LEFT$(Psfoption$, 1)
  1234.     COLOR 15, 4: PRINT "PSF Class";: LOCATE , 20: COLOR , 1: PRINT Option$;: COLOR , 4: PRINT "   C=CURRENT, P=PREVIOUS, H=HYPOTHETICAL"
  1235.     IF UCASE$(Option$) = "P" THEN
  1236.         COLOR 15, 4: PRINT "Issue";: LOCATE , 20: COLOR , 1: PRINT Prev.issue$;: COLOR , 4: PRINT " The issue must be a valid DOS filename extension."
  1237.         Psf$ = TType.number$ + "P." + Noblanks$(Prev.issue$)
  1238.     ELSE
  1239.         Psf$ = TType.number$ + Option$ + ".PSF"
  1240.     END IF
  1241.     LOCATE 13: COLOR 15, 4
  1242.         CASE "C"
  1243.             PRINT "If you load a CURRENT PSF you can edit it, produce a Tolerance Report or"
  1244.             PRINT "produce a History Report."
  1245.             PRINT "If you choose to edit it, you must decide whether you are going to raise the"
  1246.             PRINT "software issue of the test program. If so, the PSF will be archived as a"
  1247.             PRINT "PREVIOUS PSF before editing commences, and then the edited version will be"
  1248.             PRINT "saved as the new CURRENT PSF. If you choose not to change the issue, you will"
  1249.             PRINT "be able to save the edited version as either CURRENT or HYPOTHETICAL, or to"
  1250.             PRINT "quit the editor without saving the changes."
  1251.         CASE "H"
  1252.             PRINT "If you load a HYPOTHETICAL PSF you can edit it or produce a Tolerance Report,"
  1253.             PRINT "but not a History Report."
  1254.             PRINT "If you choose to edit it, you will be able to save the edited version as"
  1255.             PRINT "HYPOTHETICAL, or quit the editor without saving the changes. You cannot"
  1256.             PRINT "convert a HYPOTHETICAL PSF to CURRENT class. This preserves the integrity of"
  1257.             PRINT "the issue history."
  1258.         CASE "P"
  1259.             PRINT "If you load a PREVIOUS PSF you can edit it or produce a Tolerance Report, but"
  1260.             PRINT "not a History Report."
  1261.             PRINT "If you choose to edit it, you will be able to save the edited version as"
  1262.             PRINT "HYPOTHETICAL, or quit the editor without saving the changes. You cannot"
  1263.             PRINT "convert a PREVIOUS PSF to CURRENT class, nor can you over-write a PREVIOUS"
  1264.             PRINT "class file. This preserves the integrity of the issue history and of the"
  1265.             PRINT "archived PSF data."
  1266.     END SELECT
  1267.     LOCATE 24: COLOR 15, 2: PRINT "Up/Dn, Home/End keys to move; Edit entry or TAB to select option; ESC to finish ";: COLOR , 4
  1268.  
  1269.     'Print out a tolerance report for the loaded PSF
  1270.     STATIC Lotempst AS STRING * 8
  1271.     STATIC Hitempst AS STRING * 8
  1272.     STATIC Indexst AS STRING * 3
  1273.     ' STATIC Labelst AS STRING * 24
  1274.     STATIC Unitsst AS STRING * 5
  1275.     STATIC Lowerst AS STRING * 10
  1276.     STATIC Upperst AS STRING * 10
  1277.     STATIC Nomst AS STRING * 10
  1278.     STATIC Tolst AS STRING * 7
  1279.     PRINT #1, "TOLERANCE REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  1280.     PRINT #1, STRING$(78, "-")
  1281.     IF Psfoption$ = "HYPOTHETICAL" THEN
  1282.         PRINT #1, "HYPOTHETICAL PSF - Generated for results analysis, not applied in testing."
  1283.     ELSE
  1284.         IF Psfoption$ = "PREVIOUS" THEN
  1285.             Prev.psf$ = " (PREVIOUS)    Dated:"
  1286.         ELSE
  1287.             Prev.psf$ = "               Dated:"
  1288.         END IF
  1289.         PRINT #1, "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; Prev.psf$; Psf.progdate$
  1290.     END IF
  1291.     PRINT #1, "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  1292.     IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT #1, Psf.amendrefs$
  1293.     IF Psf.sermark% = YES THEN
  1294.         Sermarked$ = "              Serial Marked"
  1295.     ELSE
  1296.         Sermarked$ = "              Not Serial Marked"
  1297.     END IF
  1298.     PRINT #1, "Customer Reference:"; Psf.custype$; Sermarked$
  1299.     IF Psf.lotemp% = 999 THEN
  1300.         Lotempst$ = " N/A    "
  1301.     ELSE
  1302.         Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  1303.     END IF
  1304.     IF Psf.hitemp% = 999 THEN
  1305.         Hitempst$ = " N/A    "
  1306.     ELSE
  1307.         Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  1308.     END IF
  1309.     PRINT #1, "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  1310.     PRINT #1, STRING$(78, "-")
  1311.     FOR Setno% = 0 TO Psf.numsets% - 1
  1312.         PRINT #1, "PARAMETER SET NUMBER"; Setno%; "      "; Psf.setlabel$(Setno%); "   "; Psf.numpars%(Setno%); "Parameters:-"
  1313.         PRINT #1, " ============================================================================"
  1314.         PRINT #1, "[IND|        PARAMETER        |  LOWER   |  UPPER   |  Nominal & Tol. | UNITS]"
  1315.         PRINT #1, "[---+-------------------------+----------+----------+-----------------+------]"
  1316.         FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1317.             Indexst$ = RTRIM$(LTRIM$(STR$(Psfset(Setno%, Paramno%).Index)))
  1318.             Labelst$ = Psfset(Setno%, Paramno%).Label
  1319.             Unitsst$ = Psfset(Setno%, Paramno%).Units
  1320.             Lowerst$ = STR$(Psfset(Setno%, Paramno%).Lower)
  1321.             Upperst$ = STR$(Psfset(Setno%, Paramno%).Upper)
  1322.             Lowval! = Psfset(Setno%, Paramno%).Lower
  1323.             Upval! = Psfset(Setno%, Paramno%).Upper
  1324.             Nominal! = (Round!(((Lowval! + Upval!) / 2), 4))
  1325.             Nomst$ = STR$(Nominal!)
  1326.             IF Lowval! * Upval! <= 0 OR INSTR(Unitsst$, "dB") > 0 OR INSTR(Unitsst$, "%") > 0 THEN
  1327.                 Toleranceval! = (Upval! - Lowval!) / 2
  1328.                 IF Toleranceval! > 999 THEN
  1329.                     Tolst$ = "+->999"
  1330.                 ELSEIF Toleranceval! > 100 THEN
  1331.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 0))))
  1332.                 ELSEIF Toleranceval! > 10 THEN
  1333.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1))))
  1334.                 ELSEIF Toleranceval! > 1 THEN
  1335.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2))))
  1336.                 ELSE
  1337.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3))))
  1338.                 END IF
  1339.             ELSE
  1340.                 Toleranceval! = 100 * (Upval! - Lowval!) / 2 / ABS(Nominal!)
  1341.                 IF Toleranceval! > 99.9 THEN
  1342.                     Tolst$ = "+-99.9%"
  1343.                 ELSEIF Toleranceval! > 10 THEN
  1344.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1)))) + "%"
  1345.                 ELSEIF Toleranceval! > 1 THEN
  1346.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2)))) + "%"
  1347.                 ELSE
  1348.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3)))) + "%"
  1349.                 END IF
  1350.             END IF
  1351.             PRINT #1, "["; Indexst$; "| ";
  1352.             FOR Charpos = 1 TO 24
  1353.                 Char$ = MID$(Labelst$, Charpos, 1)
  1354.                 IF ASC(Char$) = 0 THEN
  1355.                     Char$ = " "
  1356.                 END IF
  1357.                 PRINT #1, Char$;
  1358.             NEXT Charpos
  1359.             PRINT #1, "|"; Lowerst$; "|"; Upperst$; "|"; Nomst$; Tolst$; "| ";
  1360.             FOR Charpos = 1 TO 5
  1361.                 Char$ = MID$(Unitsst$, Charpos, 1)
  1362.                 IF ASC(Char$) = 0 THEN
  1363.                     Char$ = " "
  1364.                 END IF
  1365.                 PRINT #1, Char$;
  1366.             NEXT Charpos
  1367.             PRINT #1, "]"
  1368.         NEXT Paramno%
  1369.         PRINT #1, " ============================================================================"
  1370.     NEXT Setno%
  1371.     PRINT #1, CHR$(12)
  1372.  
  1373. SUB Tol.show
  1374.     'Display a tolerance report for the loaded PSF
  1375.     STATIC Lotempst AS STRING * 8
  1376.     STATIC Hitempst AS STRING * 8
  1377.     STATIC Indexst AS STRING * 3
  1378.     STATIC Labelst AS STRING * 24
  1379.     STATIC Unitsst AS STRING * 5
  1380.     STATIC Lowerst AS STRING * 10
  1381.     STATIC Upperst AS STRING * 10
  1382.     STATIC Nomst AS STRING * 10
  1383.     STATIC Tolst AS STRING * 7
  1384.     LOCATE 3: COLOR 14
  1385.     PRINT "TOLERANCE REPORT for "; TType.number$; " produced on "; British$(DATE$); " @ "; LEFT$(TIME$, 5); " Engineer:"; Psf.eng$
  1386.     COLOR 15: PRINT STRING$(78, "-")
  1387.     IF Psfoption$ = "HYPOTHETICAL" THEN
  1388.         PRINT "HYPOTHETICAL PSF - Generated for results analysis, not applied in testing."
  1389.     ELSE
  1390.         IF Psfoption$ = "PREVIOUS" THEN
  1391.             Prev.psf$ = " (PREVIOUS)    Dated:"
  1392.         ELSE
  1393.             Prev.psf$ = "               Dated:"
  1394.         END IF
  1395.         PRINT "Program + "; Psf$; SPACE$(19 - LEN(Psf$)); "Issue:"; Psf.progiss$; Prev.psf$; Psf.progdate$
  1396.     END IF
  1397.     PRINT "Source:"; Psf.sourcename$; "  Issue:"; Psf.sourceiss$; "             Dated:"; Psf.sourcedate$
  1398.     IF LTRIM$(RTRIM$(Psf.amendrefs$)) <> "" THEN PRINT Psf.amendrefs$
  1399.     IF Psf.sermark% = YES THEN
  1400.         Sermarked$ = "              Serial Marked"
  1401.     ELSE
  1402.         Sermarked$ = "              Not Serial Marked"
  1403.     END IF
  1404.     PRINT "Customer Reference:"; Psf.custype$; Sermarked$
  1405.     IF Psf.lotemp% = 999 THEN
  1406.         Lotempst$ = " N/A    "
  1407.     ELSE
  1408.         Lotempst$ = "=" + STR$(Psf.lotemp%) + "DegC"
  1409.     END IF
  1410.     IF Psf.hitemp% = 999 THEN
  1411.         Hitempst$ = " N/A    "
  1412.     ELSE
  1413.         Hitempst$ = "=" + RTRIM$(LTRIM$(STR$(Psf.hitemp%))) + "DegC"
  1414.     END IF
  1415.     PRINT "Low Temp."; Lotempst$; "            Ambient Temp.=23DegC    High Temp."; Hitempst$
  1416.     PRINT STRING$(78, "-")
  1417.     Line.counter% = 7
  1418.     FOR Setno% = 0 TO Psf.numsets% - 1
  1419.         COLOR 14: PRINT "PARAMETER SET NUMBER"; Setno%;: COLOR 15: PRINT "      "; Psf.setlabel$(Setno%); "   "; Psf.numpars%(Setno%); "Parameters:-"
  1420.         PRINT " ============================================================================"
  1421.         PRINT "[IND|        PARAMETER        |  LOWER   |  UPPER   |  Nominal & Tol. | UNITS]"
  1422.         PRINT "[---+-------------------------+----------+----------+-----------------+------]"
  1423.         Line.counter% = Line.counter% + 4
  1424.         FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1425.             Indexst$ = RTRIM$(LTRIM$(STR$(Psfset(Setno%, Paramno%).Index)))
  1426.             Labelst$ = Psfset(Setno%, Paramno%).Label
  1427.             Unitsst$ = Psfset(Setno%, Paramno%).Units
  1428.             Lowerst$ = STR$(Psfset(Setno%, Paramno%).Lower)
  1429.             Upperst$ = STR$(Psfset(Setno%, Paramno%).Upper)
  1430.             Lowval! = Psfset(Setno%, Paramno%).Lower
  1431.             Upval! = Psfset(Setno%, Paramno%).Upper
  1432.             Nominal! = (Round!(((Lowval! + Upval!) / 2), 4))
  1433.             Nomst$ = STR$(Nominal!)
  1434.             IF Lowval! * Upval! <= 0 OR INSTR(Unitsst$, "dB") > 0 OR INSTR(Unitsst$, "%") > 0 THEN
  1435.                 Toleranceval! = (Upval! - Lowval!) / 2
  1436.                 IF Toleranceval! > 999 THEN
  1437.                     Tolst$ = "+->999"
  1438.                 ELSEIF Toleranceval! > 100 THEN
  1439.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 0))))
  1440.                 ELSEIF Toleranceval! > 10 THEN
  1441.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1))))
  1442.                 ELSEIF Toleranceval! > 1 THEN
  1443.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2))))
  1444.                 ELSE
  1445.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3))))
  1446.                 END IF
  1447.             ELSE
  1448.                 Toleranceval! = 100 * (Upval! - Lowval!) / 2 / ABS(Nominal!)
  1449.                 IF Toleranceval! > 99.9 THEN
  1450.                     Tolst$ = "+-99.9%"
  1451.                 ELSEIF Toleranceval! > 10 THEN
  1452.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 1)))) + "%"
  1453.                 ELSEIF Toleranceval! > 1 THEN
  1454.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 2)))) + "%"
  1455.                 ELSE
  1456.                     Tolst$ = "+-" + LTRIM$(RTRIM$(STR$(Round!(Toleranceval!, 3)))) + "%"
  1457.                 END IF
  1458.             END IF
  1459.             PRINT "["; Indexst$; "| ";
  1460.             FOR Charpos = 1 TO 24
  1461.                 Char$ = MID$(Labelst$, Charpos, 1)
  1462.                 IF ASC(Char$) = 0 THEN
  1463.                     Char$ = " "
  1464.                 END IF
  1465.                 PRINT Char$;
  1466.             NEXT Charpos
  1467.             PRINT "|"; Lowerst$; "|"; Upperst$; "|"; Nomst$; Tolst$; "| ";
  1468.             FOR Charpos = 1 TO 5
  1469.                 Char$ = MID$(Unitsst$, Charpos, 1)
  1470.                 IF ASC(Char$) = 0 THEN
  1471.                     Char$ = " "
  1472.                 END IF
  1473.                 PRINT Char$;
  1474.             NEXT Charpos
  1475.             PRINT "]"
  1476.             Line.counter% = Line.counter% + 1
  1477.             IF Line.counter% > 19 THEN
  1478.                 CALL State("Press any key to continue."): COLOR 15, 4
  1479.                 CALL Waitkey
  1480.                 CLS 2: LOCATE 3
  1481.                 Line.counter% = 0
  1482.             END IF
  1483.         NEXT Paramno%
  1484.         PRINT " ============================================================================"
  1485.         Line.counter% = Line.counter% + 1
  1486.         IF Line.counter% > 15 THEN
  1487.             CALL State("Press any key to continue."): COLOR 15, 4
  1488.             CALL Waitkey
  1489.             CLS 2: LOCATE 3
  1490.             Line.counter% = 0
  1491.         END IF
  1492.     NEXT Setno%
  1493.  
  1494. SUB TOLERANCE
  1495.     IF Choose.done% = NO THEN
  1496.         SOUND 300, 4
  1497.         CALL State("Working file not specified yet; select CHOOSE first. Press any key.")
  1498.         CALL Waitkey
  1499.         EXIT SUB
  1500.     END IF
  1501.     CLS 2
  1502.     Pathname$ = Drive$ + ":" + Path$ + Psf$
  1503.     Fileunfound% = RESETFLAG
  1504.     OPEN Pathname$ FOR INPUT AS #2
  1505.     IF Fileunfound% = NO THEN
  1506.         CALL Read.psf
  1507.         CLOSE #2
  1508.     END IF
  1509.     CALL Tol.show
  1510.     IF Ask%("Do you want to PRINT THIS REPORT") = YES THEN
  1511.         State ("Printing Tolerance Report...")
  1512.         CALL Tol.print
  1513.         State ("")
  1514.     END IF
  1515.  
  1516.     ' Output all data to PSF file, which has already been opened as #3
  1517.     DIM Psfparamst AS Psfparamsttype
  1518.     Psf.hitempst$ = STR$(Psf.hitemp%)
  1519.     Psf.lotempst$ = STR$(Psf.lotemp%)
  1520.     Psf.sermarkst$ = STR$(Psf.sermark%)
  1521.     Psf.numspacesst$ = STR$(Psf.numspaces%)
  1522.     PRINT #3, Psf.typeno$: PRINT #3, Psf.progiss$
  1523.     PRINT #3, Psf.preceding$: PRINT #3, Psf.progdate$
  1524.     PRINT #3, Psf.sourcename$: PRINT #3, Psf.sourceiss$
  1525.     PRINT #3, Psf.sourcedate$: PRINT #3, Psf.amendrefs$
  1526.     PRINT #3, Psf.custype$: PRINT #3, Psf.hitempst$
  1527.     PRINT #3, Psf.lotempst$: PRINT #3, Psf.sermarkst$
  1528.     PRINT #3, Psf.history$: PRINT #3, Psf.crn$
  1529.     PRINT #3, Psf.eng$: PRINT #3, Psf.comment1$
  1530.     PRINT #3, Psf.comment2$: PRINT #3, Psf.comment3$
  1531.     PRINT #3, Psf.comment4$: PRINT #3, Psf.comment5$
  1532.     Psf.numsetsst$ = STR$(Psf.numsets%)
  1533.     PRINT #3, Psf.numsetsst$
  1534.     FOR Setno% = 0 TO Psf.numsets% - 1
  1535.         Psf.numparsst$ = STR$(Psf.numpars%(Setno%))
  1536.         PRINT #3, Psf.numparsst$
  1537.     NEXT Setno%
  1538.     PRINT #3, Psf.numspacesst$
  1539.     FOR Setno% = 0 TO Psf.numsets% - 1
  1540.         PRINT #3, Psf.setlabel$(Setno%)
  1541.     NEXT Setno%
  1542.     FOR Setno% = 0 TO Psf.numsets% - 1
  1543.         FOR Paramno% = 1 TO Psf.numpars%(Setno%)
  1544.             Psfparamst.Index = STR$(Psfset(Setno%, Paramno%).Index)
  1545.             Psfparamst.Label = Psfset(Setno%, Paramno%).Label
  1546.             Psfparamst.Units = Psfset(Setno%, Paramno%).Units
  1547.             Lower.val! = (Psfset(Setno%, Paramno%).Lower * 10000)
  1548.             Lower.val! = Lower.val! + .1 * SGN(Lower.val!) 'Eliminate rounding errors
  1549.             Lower.int& = FIX(Lower.val!)
  1550.             Psfparamst.Lower = STR$(Lower.int&)
  1551.             Upper.val! = (Psfset(Setno%, Paramno%).Upper * 10000)
  1552.             Upper.val! = Upper.val! + .1 * SGN(Upper.val!) 'Eliminate rounding errors
  1553.             Upper.int& = FIX(Upper.val!)
  1554.             Psfparamst.Upper = STR$(Upper.int&)
  1555.             PRINT #3, Psfparamst.Index
  1556.             PRINT #3, Psfparamst.Label
  1557.             PRINT #3, Psfparamst.Units
  1558.             PRINT #3, Psfparamst.Lower
  1559.             PRINT #3, Psfparamst.Upper
  1560.         NEXT Paramno%
  1561.     NEXT Setno%
  1562.  
  1563. ' UTILs _____________________________________________________________________________________
  1564.  
  1565. FUNCTION Ask% (Question$)
  1566.     'Prompt for Y / N response
  1567.     DO
  1568.         Dummy$ = INKEY$
  1569.     LOOP UNTIL Dummy$ = ""
  1570.     COLOR 10, 1
  1571.     Valid% = NO
  1572.     WHILE Valid% = NO
  1573.         LOCATE 23, 1
  1574.         PRINT SPACE$(80);
  1575.         LOCATE 23, 1
  1576.         PRINT Question$; "? (Y/N) ";
  1577.         DO
  1578.             K$ = INKEY$
  1579.         LOOP WHILE K$ = ""
  1580.         Valid% = YES
  1581.         SELECT CASE K$
  1582.             CASE "Y", "y"
  1583.                 Ask% = YES
  1584.             CASE "N", "n"
  1585.                 Ask% = NO
  1586.             CASE ELSE
  1587.                 Valid% = NO
  1588.         END SELECT
  1589.     WEND
  1590.     COLOR 15, 1
  1591.     LOCATE 23, 1
  1592.     PRINT SPACE$(80);
  1593.  
  1594. FUNCTION British$ (Indate$)
  1595.     'Converts "m[m]{-./}d[d]{-./}yy[yy]" to "dd/mm/yy[yy]"
  1596.  
  1597.     Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1598.     IF Delim > 0 THEN
  1599.         Month% = VAL(LEFT$(Indate$, (Delim - 1)))
  1600.         Indate$ = RIGHT$(Indate$, (LEN(Indate$) - Delim))
  1601.         Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1602.         IF Delim > 0 THEN Day% = VAL(LEFT$(Indate$, (Delim - 1)))
  1603.         IF Delim > 0 THEN Year% = VAL(RIGHT$(Indate$, (LEN(Indate$) - Delim)))
  1604.     END IF
  1605.     d$ = STR$(Day%)
  1606.     d$ = RIGHT$(d$, (LEN(d$) - 1))
  1607.     IF LEN(d$) = 1 THEN d$ = "0" + d$
  1608.     m$ = STR$(Month%)
  1609.     m$ = RIGHT$(m$, (LEN(m$) - 1))
  1610.     IF LEN(m$) = 1 THEN m$ = "0" + m$
  1611.     y$ = STR$(Year%)
  1612.     y$ = RIGHT$(y$, (LEN(y$) - 1))
  1613.     British$ = d$ + "/" + m$ + "/" + y$
  1614.  
  1615.  
  1616. FUNCTION Checkint% (Value%, Lolim%, Hilim%)
  1617.     IF Value% < Lolim% OR Value% > Hilim% THEN
  1618.         SOUND 400, 1
  1619.         Checkint% = NO
  1620.     ELSE
  1621.         Checkint% = YES
  1622.     END IF
  1623.  
  1624. FUNCTION Checkreal% (Value!, Lolim!, Hilim!)
  1625.     IF Value! < Lolim! OR Value! > Hilim! THEN
  1626.         SOUND 400, 1
  1627.         Checkreal% = NO
  1628.     ELSE
  1629.         Checkreal% = YES
  1630.     END IF
  1631.  
  1632. FUNCTION Datestr$ (Inputdate&)
  1633.     'Converts a number of days since 30/12/1899 (Quattro pro ref) into a date
  1634.     'string. Output date string is DD/MM/YYYY
  1635.  
  1636.     Indate& = Inputdate& + 364
  1637.     DIM Numdays(12) AS INTEGER
  1638.     Numdays(1) = 31
  1639.     Numdays(2) = 28
  1640.     Numdays(3) = 31
  1641.     Numdays(4) = 30
  1642.     Numdays(5) = 31
  1643.     Numdays(6) = 30
  1644.     Numdays(7) = 31
  1645.     Numdays(8) = 31
  1646.     Numdays(9) = 30
  1647.     Numdays(10) = 31
  1648.     Numdays(11) = 30
  1649.     Numdays(12) = 31
  1650.  
  1651.     'Derive date from input number of days past reference
  1652.     Year% = 1899
  1653.     WHILE Indate& > 366
  1654.         IF Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0) THEN
  1655.             Indate& = Indate& - 366
  1656.         ELSE
  1657.             Indate& = Indate& - 365
  1658.         END IF
  1659.         Year% = Year% + 1
  1660.     WEND
  1661.     IF Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0) THEN
  1662.         Numdays(2) = 29
  1663.     ELSE
  1664.         IF Indate& = 366 THEN
  1665.             Indate& = 1
  1666.             Year% = Year% + 1
  1667.         END IF
  1668.     END IF
  1669.     Month% = 1
  1670.     WHILE Indate& > Numdays(Month%)
  1671.         Indate& = Indate& - Numdays(Month%)
  1672.         Month% = Month% + 1
  1673.     WEND
  1674.     Day% = Indate&
  1675.  
  1676.     'Construct date$
  1677.     d$ = STR$(Day%)
  1678.     d$ = RIGHT$(d$, (LEN(d$) - 1))
  1679.     IF LEN(d$) = 1 THEN d$ = "0" + d$
  1680.     m$ = STR$(Month%)
  1681.     m$ = RIGHT$(m$, (LEN(m$) - 1))
  1682.     IF LEN(m$) = 1 THEN m$ = "0" + m$
  1683.     y$ = STR$(Year%)
  1684.     y$ = RIGHT$(y$, (LEN(y$) - 1))
  1685.  
  1686.     Datestr$ = d$ + "/" + m$ + "/" + y$
  1687.  
  1688.  
  1689. FUNCTION Dateval& (Inputdate$)
  1690.     'Converts a date string into number of days since 30/12/1899 (Quattro-Pro ref)  1/1/1899
  1691.     'Input date string is DAY/MONTH/YEAR, DAY.MONTH.YEAR or DAY-MONTH-YEAR
  1692.     'where DAY and MONTH are 1 or 2 digits and YEAR is 2 or 4 digits
  1693.     'A 2-digit year is interpreted as being between 1951 and 2050. Dates outside
  1694.     'this range and invalid dates return error code (-1).
  1695.  
  1696.     Indate$ = Inputdate$
  1697.     DIM Numdays(12) AS INTEGER
  1698.     Numdays(1) = 31
  1699.     Numdays(2) = 28
  1700.     Numdays(3) = 31
  1701.     Numdays(4) = 30
  1702.     Numdays(5) = 31
  1703.     Numdays(6) = 30
  1704.     Numdays(7) = 31
  1705.     Numdays(8) = 31
  1706.     Numdays(9) = 30
  1707.     Numdays(10) = 31
  1708.     Numdays(11) = 30
  1709.     Numdays(12) = 31
  1710.  
  1711.     'Extract days, months and years from Indate$
  1712.     Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1713.     IF Delim > 0 THEN
  1714.         Day% = VAL(LEFT$(Indate$, (Delim - 1)))
  1715.         Indate$ = RIGHT$(Indate$, (LEN(Indate$) - Delim))
  1716.         Delim = INSTR(Indate$, "/") + INSTR(Indate$, ".") + INSTR(Indate$, "-")
  1717.         IF Delim > 0 THEN Month% = VAL(LEFT$(Indate$, (Delim - 1)))
  1718.         IF Delim > 0 THEN Year% = VAL(RIGHT$(Indate$, (LEN(Indate$) - Delim)))
  1719.         IF Year% < 100 THEN
  1720.             IF Year% < 51 THEN
  1721.                 Year% = Year% + 2000
  1722.             ELSE
  1723.                 Year% = Year% + 1900
  1724.             END IF
  1725.         END IF
  1726.     END IF
  1727.  
  1728.     'Convert date to number of days since reference
  1729.     Daycount& = 0
  1730.     IF Year% < 1951 OR Year% > 2050 OR Month% < 1 OR Month% > 12 THEN
  1731.         Daycount& = -1
  1732.     ELSE
  1733.         IF (Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0)) AND Month% = 2 THEN
  1734.             IF Day% > 29 THEN Daycount& = -1
  1735.         ELSE
  1736.             IF Day% > Numdays(Month%) THEN Daycount& = -1
  1737.         END IF
  1738.         IF Day% < 1 THEN Daycount& = -1
  1739.     END IF
  1740.     IF Daycount& = 0 THEN
  1741.         FOR I = 1899 TO Year% - 1
  1742.             Daycount& = Daycount& + 365
  1743.             IF I MOD 400 = 0 OR (I MOD 4 = 0 AND I MOD 100 <> 0) THEN
  1744.                 Daycount& = Daycount& + 1
  1745.             END IF
  1746.         NEXT I
  1747.         FOR I = 1 TO Month% - 1
  1748.             Daycount& = Daycount& + Numdays(I)
  1749.         NEXT I
  1750.         IF Year% MOD 400 = 0 OR (Year% MOD 4 = 0 AND Year% MOD 100 <> 0) THEN
  1751.             IF Month% > 2 THEN Daycount& = Daycount& + 1
  1752.         END IF
  1753.         Daycount& = Daycount& + Day%
  1754.     END IF
  1755.     IF Daycount& > 0 THEN
  1756.         Dateval& = Daycount& - 364
  1757.     ELSE
  1758.         Dateval& = -1
  1759.     END IF
  1760.  
  1761. FUNCTION Dosvalid% (Extension$)
  1762.     'Check whether (first 3 chars of) Extension$ is a valid DOS filename extension
  1763.     DIM C%(3)
  1764.     Check.ext$ = Extension$
  1765.     IF LEN(Extension$) < 3 THEN
  1766.         Check.ext$ = Check.ext$ + SPACE$(3 - LEN(Extension$))
  1767.     END IF
  1768.     Check.ext$ = LEFT$(Check.ext$, 3)
  1769.     C%(1) = ASC(Check.ext$)
  1770.     C%(2) = ASC(RIGHT$(Check.ext$, 2))
  1771.     C%(3) = ASC(RIGHT$(Check.ext$, 1))
  1772.     Valid% = YES
  1773.     FOR n% = 1 TO 3
  1774.         Validchar% = NO
  1775.         X% = C%(n%)
  1776.         IF X% = 33 OR (X% > 34 AND X% < 42) OR X% = 45 OR (X% > 47 AND X% < 58) THEN Validchar% = YES
  1777.         IF (X% > 63 AND X% < 91) OR (X% > 93 AND X% < 124) OR X% = 125 OR X% = 126 THEN Validchar% = YES
  1778.         IF n% > 1 AND X% = 32 THEN Validchar% = YES 'Allow trailing spaces
  1779.         IF Validchar% = NO THEN Valid% = NO
  1780.     NEXT n%
  1781.     'IF Valid% = NO THEN SOUND 400, 1
  1782.     Dosvalid% = Valid%
  1783.  
  1784. FUNCTION Noblanks$ (Instring$)
  1785.     ' Strip leading, trailing and all contained spaces and convert to upper case
  1786.     ' (see Plain$)
  1787.     Temp$ = LTRIM$(RTRIM$(UCASE$(Instring$)))
  1788.     Blanksin% = YES
  1789.     WHILE Blanksin% = YES
  1790.         Spacepos% = INSTR(Temp$, " ")
  1791.         IF Spacepos% THEN
  1792.             Leftbit$ = LEFT$(Temp$, Spacepos% - 1)
  1793.             Rightbit$ = RIGHT$(Temp$, LEN(Temp$) - Spacepos%)
  1794.             Temp$ = Leftbit$ + Rightbit$
  1795.         ELSE
  1796.             Blanksin% = NO
  1797.         END IF
  1798.     WEND
  1799.     Noblanks$ = Temp$
  1800.  
  1801. SUB Pause (T!)
  1802.     Start.time = TIMER
  1803.     WHILE TIMER < Start.time + T!
  1804.         IF TIMER < Start.time THEN Start.time = Start.time - 24 * 3600 'IF MIDNIGHT HAPPENS
  1805.     WEND
  1806.  
  1807. FUNCTION Plain$ (Instring$)
  1808.     ' Strip leading & trailing spaces and convert to upper case (see Noblanks$)
  1809.     Plain$ = LTRIM$(RTRIM$(UCASE$(Instring$)))
  1810.  
  1811. FUNCTION Qpwdate& (Intimedate!)
  1812.     'Derives a Quattro-pro date value from an HP Basic TIMEDATE value.
  1813.     Qpwdate& = INT(Intimedate! / 86400 - 2415019)
  1814.  
  1815.  
  1816. FUNCTION Qpwtime# (Intimedate#)
  1817.     'Derives a Quattro-pro time value from an HP Basic TIMEDATE value.
  1818.     Qpwtime# = (Intimedate# / 86400) - INT(Intimedate# / 86400)
  1819.  
  1820.  
  1821. FUNCTION Round! (Value!, Dec%)
  1822.     'Round Value! to Dec% DP, max 4 DP
  1823.     IF Dec% > 4 THEN Dec% = 4
  1824.     Power.ten! = 10 ^ Dec%
  1825.     Integer.part! = FIX(Value!)
  1826.     Decimal.part! = Value! - FIX(Value!)
  1827.     IF Power.ten! <> 0 THEN Decimal.part! = CINT(Decimal.part! * Power.ten!) / Power.ten!
  1828.     Round! = Integer.part! + Decimal.part!
  1829.  
  1830. SUB State (Prompt$)
  1831.     'Display single line prompt
  1832.     Linenum% = CSRLIN
  1833.     Colnum% = POS(0)
  1834.     COLOR 14, 1
  1835.     LOCATE 24, 1
  1836.     PRINT SPACE$(80);
  1837.     LOCATE 24, 1
  1838.     PRINT Prompt$;
  1839.     LOCATE Linenum%, Colnum%
  1840.     COLOR 15, 1
  1841.  
  1842. FUNCTION Timedate! (Inqpwdate&, Inqpwtime!)
  1843.     'Converts a Quattro-pro date and time value to the corresponding HP Basic
  1844.     'TIMEDATE value.
  1845.     Timedate! = (Inqpwdate& + 2415019 + Inqpwtime!) * 86400
  1846.  
  1847. FUNCTION Timestr$ (Inputtime#)
  1848.     'Converts a fraction of a day (Quattro pro format) into a time string.
  1849.     'Output time string is HH:MM:SS. Conversion accuracy +/- 1 Sec.
  1850.  
  1851.     Inputhours! = (Inputtime# - INT(Inputtime#)) * 24
  1852.     Hour% = INT(Inputhours!)
  1853.     Min% = INT((Inputhours! - Hour%) * 60)
  1854.     Sec% = INT(((Inputhours! - Hour%) * 60 - Min%) * 60)
  1855.  
  1856.     'Construct time$
  1857.     h$ = STR$(Hour%)
  1858.     h$ = RIGHT$(h$, (LEN(h$) - 1))
  1859.     IF LEN(h$) = 1 THEN h$ = "0" + h$
  1860.     m$ = STR$(Min%)
  1861.     m$ = RIGHT$(m$, (LEN(m$) - 1))
  1862.     IF LEN(m$) = 1 THEN m$ = "0" + m$
  1863.     s$ = STR$(Sec%)
  1864.     s$ = RIGHT$(s$, (LEN(s$) - 1))
  1865.     IF LEN(s$) = 1 THEN s$ = "0" + s$
  1866.  
  1867.     Timestr$ = h$ + ":" + m$ + ":" + s$
  1868.  
  1869. FUNCTION Toggle% (Inflag%)
  1870.     ' If inflag is logic (1 / 0) then its complement is returned.
  1871.  
  1872.     SELECT CASE Inflag%
  1873.         CASE 0
  1874.             Toggle% = 1
  1875.         CASE 1
  1876.             Toggle% = 0
  1877.         CASE ELSE
  1878.             Toggle% = Inflag%
  1879.     END SELECT
  1880.  
  1881.  
  1882. SUB Waitkey
  1883.     'Wait for keypress then continue
  1884.     Pause (.1) ' Delay to avoid keybounce
  1885.     DO
  1886.         K$ = INKEY$
  1887.     LOOP UNTIL K$ = "" ' Clear buffer
  1888.     DO
  1889.         K$ = INKEY$
  1890.     LOOP WHILE K$ = ""
  1891.     Pause (.1) ' Delay to avoid keybounce
  1892.  
  1893. SUB Warn (Prompt$)
  1894.     'Display single line prompt
  1895.     Linenum% = CSRLIN
  1896.     Colnum% = POS(0)
  1897.     LOCATE 24, 1
  1898.     PRINT SPACE$(80);
  1899.     LOCATE 24, 1
  1900.     COLOR 28, 1
  1901.     PRINT "WARNING - ";
  1902.     COLOR 12, 1
  1903.     PRINT Prompt$;
  1904.     SOUND 400, 1
  1905.     LOCATE Linenum%, Colnum%
  1906.     COLOR 15, 1
  1907.  
  1908.  

That DIM block was added in later I would bet actual money! ;-))

And so I compiled and ran next stop line 83 no file found, of course not look at line 83
Code: QB64: [Select]
  1. OPEN "LPT1" FOR OUTPUT AS #1
  2. ON ERROR GOTO Errhandler
  3.  
  4.  

Well I didn't want to print anything anyway! but apparently the error handler didn't work either! ;(

Wait aren't those supposed to be used before the line that might commit an error?
Never used error handlers much, rather avoid the error in first place.
« Last Edit: September 28, 2020, 01:59:43 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Compile old QB4.5 code help
« Reply #13 on: September 28, 2020, 02:02:02 pm »
OK I did this:
Code: QB64: [Select]
  1. 'OPEN "LPT1" FOR OUTPUT AS #1
  2. OPEN "Output to Printer.txt" AS #1
  3.  

and now we get a menu!
  [ You are not allowed to view this attachment ]  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Compile old QB4.5 code help
« Reply #14 on: September 28, 2020, 02:06:27 pm »
You know this allot like an adventure game you guys are always writing :)

Here is F1 keypress menu:
  [ You are not allowed to view this attachment ]  

Well I don't know what's supposed to happen so hard to continue checking code.

BTW My "Output to Printer.txt" file got made but nothing in it and the fan is running overtime so I am shutting down for lunch.
« Last Edit: September 28, 2020, 02:11:24 pm by bplus »