Author Topic: assistance with 'subscript out of range' error  (Read 3839 times)

0 Members and 1 Guest are viewing this topic.

Offline satan165

  • Newbie
  • Posts: 7
    • View Profile
assistance with 'subscript out of range' error
« on: April 25, 2021, 01:56:06 pm »
   Hello.  I am historian/archeologist in Chicago studying an abandoned coke plant (coke is a processed version of coal used in iron making). 

I have been exploring the laboratory and came across the hard copy of what I recognized as a BASIC program used to evaluate coal. 

I am far from a computer programmer but I figured out enough to input the whole thing into Notepad, then I got it to run on  QB45 on Dosbox.  I used that to debug my many typos.  Then I installed QB64 which is obviously much easier to work with.

The first issue I had was that the program was written to output it's results to a printer.  I don't have a printer and even if I did, that isn't efficient.  So after some experimentation I was able to make the changes so that it would output to a file instead.  That seems to be working well now.  The program does start up and it is starting to output to the file before it crashes.

I am getting another error and this one is a bit over my head.  I am getting a 'subscript out of range' error on the following lines:

   
Code: QB64: [Select]
  1. 210 E(1, 5) = E(1, 5) + A(N, 1) * B(N, 5) / 100
  2.    220 E(1, 1) = E(1, 1) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 1) / 100
  3.    230 E(1, 2) = E(1, 2) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 2) / 100
  4.    240 E(1, 3) = E(1, 3) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 3) / 100
  5.    250 E(1, 4) = E(1, 4) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 4) / 100
  6.    260 E(1, 21) = E(1, 21) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 21) / 100
  7.    270 E(1, 22) = E(1, 22) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 22) / 100

I suspect this is related to the way the 'E' variable is defined in the DIM statement on line 10:

Code: QB64: [Select]
  1. 10 Dim A(40, 40), E(20, 50), B(20, 50), Z(20, 20), C(20, 20), A$(50), B$(50)

I saw another post where someone got this error and the 'OPTION _EXPLICIT" command was recommended.  I tried that, but then other variables start to have issues.

I have attached the entire program and I plan on scanning the hard copy.  I don't see any typo here so hopefully it isn't something that dumb.

I am way outside my depth and quietly proud that I made it this far.  If anyone thought they'd like to help that would be much appreciated.  Thank you very much.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #1 on: April 25, 2021, 02:27:54 pm »
Are you able to provide the Looping statement ?

Offline satan165

  • Newbie
  • Posts: 7
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #2 on: April 25, 2021, 02:30:37 pm »
sorry i dont know what that means, but i did attach the entire program to my initial post

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #3 on: April 25, 2021, 03:23:12 pm »
Can you provide test data with known correct solution?

Offline satan165

  • Newbie
  • Posts: 7
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #4 on: April 25, 2021, 03:30:15 pm »
I’m not sure what you are looking for, I must not understand because if I had the “correct solution” I would not need any help.

I guess what I am asking is for someone to review the code, if there is a glaring error and can point me in that direction it would be helpful.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #5 on: April 25, 2021, 03:31:58 pm »
I’m not sure what you are looking for, I must not understand because if I had the “correct solution” I would not need any help.

I guess what I am asking is for someone to review the code, if there is a glaring error and can point me in that direction it would be helpful.

I am looking to not have to answer a million questions about coal which I know nothing about, just to check out some code for you.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #6 on: April 25, 2021, 03:42:17 pm »
Code: QB64: [Select]
  1. 109 Print "ENTER THE PREDICTED COKE STABILITY"
  2. 110 Input S
  3. 118 Print #1, "                         COAL YIELD EVALUATION                      "
  4. 119 Print #1,
  5. 123 Print #1,
  6. 124 Print #1, "                           COAL ANALYSIS                            "
  7. 127 Print #1,
  8. 129 Print #1, " ***************************DRY BASIS****************************** "
  9. 130 Print #1, "COAL  NAME   WET COAL   H20    F.C.    ASH     VOL. MAT    S     O2 "
  10. 140 Print #1, "IN BLEND      IN MIX     %      %       %          %       %     %  "
  11. 190 For N = 1 To S
  12.    200 A(10, 1) = A(10, 1) + A(N, 1)
  13.    210 E(1, 5) = E(1, 5) + A(N, 1) * B(N, 5) / 100
  14.    220 E(1, 1) = E(1, 1) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 1) / 100
  15.    230 E(1, 2) = E(1, 2) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 2) / 100
  16.    240 E(1, 3) = E(1, 3) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 3) / 100
  17.    250 E(1, 4) = E(1, 4) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 4) / 100
  18.    260 E(1, 21) = E(1, 21) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 21) / 100
  19.    270 E(1, 22) = E(1, 22) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 22) / 100
  20. 275 Next N
  21.  

If you input S too high or low, easy to get out of bounds error, what is safe S?

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #7 on: April 25, 2021, 03:43:08 pm »
The Loops in the program are in a For:Next. I was just wondering, where the coding is calling for an input (ie Coal Blends input = C then the Loop Statement is For n= 1 to c, the c being the number just inputted - or The Coal Stability = S and the loop statement for this input is For N= 1 to S) I was thinking the out of range error could be associated with the value being inputted for S.

Offline satan165

  • Newbie
  • Posts: 7
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #8 on: April 25, 2021, 04:14:06 pm »
Quote
I am looking to not have to answer a million questions about coal which I know nothing about, just to check out some code for you.

I apologize - I thought you were referring to the code itself. 

I was remiss not to have offered this data initially....in my mind it didn't matter, it seemed that the program would crash regardless of what I entered.

For the first question the program asks for the number of coals in the blend.  Answer '2'.

The following question asks for nine values regarding the coal quality.  Here are some suitable values (these are based on real world values, so I assume the code will accept these):
5,50,10,50,15,16,3,15,12000

the unit of measurement for 'S' is not given by the program, but typically this is expressed as a % (coal stability factor) so 50 should work

Quote
If you input S too high or low, easy to get out of bounds error, what is safe S?
what do you see as a safe value based on the code?

Quote
I was thinking the out of range error could be associated with the value being inputted for S
i tried a number of different values but the program crashed regardless.  i did not consider that my input is what was crashing it, i assumed it was a problem with the code but you may be right.  What range do you see is acceptable based on the code?

I am not at home right now to continue to test but I will later today for sure.  if you are able to get the program to run beyond line 44 let me know what values you used.

Thank you both so much!


Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #9 on: April 25, 2021, 05:46:58 pm »
Satan, I am, like bplus, out of my depth when comes to my knowledge in coal. Hope you can help with one observation on the algorythm. If you look at lines 45 and 50.
Line 45 :The question is asking for 10 data items (1-Cost per Ton, 2-%wet Petcoke, 3-%coal H2O ... 10-BTU/LB)
Line 50 : The arrays being filled - 1 Cost/ton at C(n1), 2 - %Wet Petcoke at A(N,1), 3- %coal H2O at (B(n,5) but as you go along there are only 9 array items. I'm not sure where the BTU's per pound is being used. Likely there but it's not jumping out for me.

The looping control for this data input is generated by the answer to ENTER THE NUMBER of COALS IN THE BLEND? The the qualifying remarks indicate the program can deal with 7 coals plus petcoke. That would seem to imply a total of 8? But 8 can't be the upper limit of your B array which is taking the bulk of the inputted data - the B array is dimensioned (20,50). If answer to "the number of coals in the blend" can exceed 20 you should generate the range error limit.

The Coal Stability is similar. The A array is (40,40). an S greater than 40, (which might be the % Wet Petcoke in Blend) could generate the error
                                        - the E array is (20,50) but seems this array is not affected by the value of S,
                                         - then the B array, which we just addressed is (20,50) so S greater than 20 should generate the range error.

I have no idea if this is helpful or not as I'm a Pepsi drinker.


Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #10 on: April 25, 2021, 05:49:31 pm »
Hi evil165
ops satan165

I think that the error you got depends from your input.
Why? Because this old fashion BASIC program doesn't check the input given from user.
Changing the input I have got different errors at runtime at different lines of code.
Cause it is a simpler huge math task, you can port those calculations into a spreedsheet like excel or similar.
But if you like play with OLD BASIC the first suggestion is
give a readable name at those orrible variable with one character as name!  :-)
2 write a check input data entry routine with manage the 10-20 variables taken by a single INPUT command.
3 kill all those GOTOs
Here a screenshot of that I have got typing value for all  variables asked
  [ You are not allowed to view this attachment ]  
good luck for your archeologist study
Programming isn't difficult, only it's  consuming time and coffee

Offline satan165

  • Newbie
  • Posts: 7
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #11 on: April 25, 2021, 05:59:19 pm »
Quote
Line 45 :The question is asking for 10 data items (1-Cost per Ton, 2-%wet Petcoke, 3-%coal H2O ... 10-BTU/LB)
Line 50 : The arrays being filled - 1 Cost/ton at C(n1), 2 - %Wet Petcoke at A(N,1), 3- %coal H2O at (B(n,5) but as you go along there are only 9 array items. I'm not sure where the BTU's per pound is being used. Likely there but it's not jumping out for me.

There are nine.  I added numbers to each to illustrate

(1) COST/TON, (2) %WET COAL IN BLEND, (3) %COAL H20, AND (DRY BASIS) (4) %FIXED CARBON, (5) %ASH, (6) %VOLATILE MATTER, (7) %SULFUR, (8) %OXYGEN, (9) BTU/LB

The "And (Dry Basis)" is distinguishing the remaining 5 variables as being measured while dry.  Superfluous comment for sure.

Quote
If answer to "the number of coals in the blend" can exceed 20 you should generate the range error limit.
In reality, I think it is doubtful that anyone would have a coal blend of more than 4-5 types.

You may be right that there is a small window of acceptable answers for 'S' I perhaps I just need to continue to experiment with that

Quote
Because this old fashion BASIC program doesn't check the input given from user.
Changing the input I have got different errors at runtime at different lines of code.
Cause it is a simpler huge math task, you can port those calculations into a spreedsheet like excel or similar.

I agree completely.  As far as recreating the program in Excel, I have done this once before already.  I found some documentation that described a 'program' but I did not have the code, but it was simpler so I just built it in Google Sheets https://docs.google.com/spreadsheets/d/12MwtYzWKHrRA_lldHyX30KwqV4_MCTDckFx7eApC8wg/edit?usp=sharing

I think I may be out of my depth in trying to institute the changes you described but perhaps I will try.  If I can get this program to output finished data one time, I will be satisfied.

I actually found a second version of this program (another hard copy), but that one is a bit better because rather than asking you to input the nine variables, it simply lets you type the name of the coal, the program already has the nine variables for a variety of coals so no need to input manually.  However, that hard copy was not printed correctly, so some of the longer lines are cut off.  I may try to input it anyways and figure out what the rest of the missing line is.

Thank you all for your patience and help, if anyone can output a file and get the program to run all the way through, or can just help in specifying with the lower/upper limits for the input on these variables is please share.

Thank you all so much.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #12 on: April 25, 2021, 06:04:31 pm »
Thanks for S.
Code: QB64: [Select]
  1. 190 For N = 1 To S
  2.     '' dimmed   A(40, 40), E(20, 50), B(20, 50), Z(20, 20), C(20, 20), A$(50), B$(50)
  3.  
  4.     ' where you see N that is where S is going to go
  5.     ' A(N, )  A has top limit of 40 so S at 50 is going out of bounds
  6.     ' B(N, )  B has top limit of 20 so B is going to beat A for going out of bounds
  7.  
  8.  
  9.     200 A(10, 1) = A(10, 1) + A(N, 1)
  10.    210 E(1, 5) = E(1, 5) + A(N, 1) * B(N, 5) / 100
  11.    220 E(1, 1) = E(1, 1) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 1) / 100
  12.    230 E(1, 2) = E(1, 2) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 2) / 100
  13.    240 E(1, 3) = E(1, 3) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 3) / 100
  14.    250 E(1, 4) = E(1, 4) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 4) / 100
  15.    260 E(1, 21) = E(1, 21) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 21) / 100
  16.    270 E(1, 22) = E(1, 22) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 22) / 100
  17. 275 Next N
  18.  


The use of S as percentage looks fishy to me, unless S never is expected to exceed 20 (20%).

EDIT Oh we cross posted sorry.
« Last Edit: April 25, 2021, 06:05:44 pm by bplus »

Offline satan165

  • Newbie
  • Posts: 7
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #13 on: April 25, 2021, 06:54:13 pm »
Just got home and immediately went back to just inputting data.  Honestly, sorry for wasting everyone's time on checking code when I just didn't spend enough time trying different input values.

I got it to output on the first try

number of coals = 2
coal quality data = 5,50,10,50,15,16,3,15,12000
petcoke = no
predicted coke stability = 4

so as I just said an hour ago, if I can get the program to calculate and output the data, I am satisfied.  now I can have some fun fixing the formatting and messing around and trying to understand the upper/lower limits for these values

I think I will work on the second set of code I found, I may return with some questions on the missing bits there

you guys are awesome - thanks for humoring an idiot like me.  If you are interested in the iron making industry, or urban exploration, or chicago history you can check out my site www.acmecoke.com . ill be putting up a post about this program in the next week or so and ill be sure to give the forum a shout out.

thanks again, so much! made my day. 

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: assistance with 'subscript out of range' error
« Reply #14 on: April 25, 2021, 08:57:09 pm »
The program is almost entirely linear in execution, with just a couple of GOTO jumps. which I circumvented with IF...END IF blocks and then striped out the old line numbers and REMs. I did that to get rid of the clutter of old style programming which makes it hard for me to see issues sometimes. It's hard to believe I used to bash my head against such things back in my Applesoft daze.

I can't see much that jumps out at me as a problem, and like you I got it to give output entering your numbers, but one line looks like a possible typo. I left the old line number in to help locate it:

Code: QB64: [Select]
  1. 107 A$(I) = A$(N)  
  2.  

I say it looks like a typo because I don't see any declaration or assignment for 'I' prior to that line, and all the rest of the string array is referenced by literals. Maybe I just don't understand what the original programmer was trying to accomplish. In fact, I'm sure I don't. ;)

I include my changes to the original code below, it shows the 'I' in lower case, which was what caught my eye. I also added some comments that highlight those lines that are to be changed if altering the 1986 standards. Happy bug hunting...

Code: QB64: [Select]
  1. OPEN "OUTPUT", 1, "#1"
  2. PRINT "                                         COAL EVALUATION PROGRAM"
  3. PRINT "NOTE: PROGRAM USES NOVEMBER 1986 STANDARDS FOR BY-PRODUCT VALUES, FIXED AND VARIABLE CONVERSION COSTS AND BULK DENSITY OIL USAGE."
  4. PRINT "UPDATING REQUIRES CHANGES IN LINES 1410, 1420, 1430, 1440, 4150, 4160, 4170, 4410, 4690 AND 4720."
  5. DIM A(40, 40), E(20, 50), B(20, 50), Z(20, 20), C(20, 20), A$(50), B$(50)
  6. PRINT "THIS PROGRAM IS DESIGNED FOR A BLEND CONTAINING UP TO SEVEN COALS PLUS PETCOKE.  ENTER THE NUMBER OF COALS IN THE BLEND."
  7. FOR N = 1 TO C
  8.     PRINT
  9.     PRINT "ENTER NAME OF COAL"
  10.     INPUT A$(N)
  11.     PRINT
  12.     PRINT "ENTER DATA IN THIS ORDER: COST/TON, %WET COAL IN BLEND, %COAL H20, AND (DRY BASIS) %FIXED CARBON, %ASH, %VOLATILE MATTER, %SULFUR, %OXYGEN, BTU/LB                               "
  13.     INPUT C(N, 1), A(N, 1), B(N, 5), B(N, 1), B(N, 2), B(N, 3), B(N, 4), B(N, 21), B(N, 22)
  14. N = C
  15. PRINT "DOES THE BLEND CONTAIN PETCOKE? ENTER YES OR NO "
  16. INPUT D$: D$ = UCASE$(MID$(D$, 1, 1))
  17. A$(8) = "PETCOKE"
  18. IF D$ <> "N" THEN
  19.     PRINT
  20.     PRINT "ENTER DATA IN THIS ORDER: COST/TON, %WET PETCOKE IN BLEND, %PETCOKE H20, AND (DRY BASIS) %FIXED CARBON, %ASH, %VOLATILE MATTER, %SULFUR, %OXYGEN, BTU/LB"
  21.     INPUT C(8, 1), A(8, 1), B(8, 5), B(8, 1), B(8, 2), B(8, 3), B(8, 4), B(8, 21), B(8, 22)
  22. A$(9) = "COAL PORTION"
  23. A$(10) = "BLEND"
  24. A$(12) = "FCE COKE"
  25. A$(i) = A$(N)
  26. PRINT "ENTER THE PREDICTED COKE STABILITY"
  27. PRINT #1, "                         COAL YIELD EVALUATION                      "
  28. PRINT #1,
  29. PRINT #1,
  30. PRINT #1, "                           COAL ANALYSIS                            "
  31. PRINT #1,
  32. PRINT #1, " ***************************DRY BASIS****************************** "
  33. PRINT #1, "COAL  NAME   WET COAL   H20    F.C.    ASH     VOL. MAT    S     O2 "
  34. PRINT #1, "IN BLEND      IN MIX     %      %       %          %       %     %  "
  35. FOR N = 1 TO S
  36.     A(10, 1) = A(10, 1) + A(N, 1)
  37.     E(1, 5) = E(1, 5) + A(N, 1) * B(N, 5) / 100
  38.     E(1, 1) = E(1, 1) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 1) / 100
  39.     E(1, 2) = E(1, 2) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 2) / 100
  40.     E(1, 3) = E(1, 3) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 3) / 100
  41.     E(1, 4) = E(1, 4) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 4) / 100
  42.     E(1, 21) = E(1, 21) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 21) / 100
  43.     E(1, 22) = E(1, 22) + A(N, 1) * ((100 - B(N, 5)) / 100) * B(N, 22) / 100
  44. FOR N = 1 TO C
  45.     P$ = "\                             \###,##   ##,###   ##,###   ##,###        ##,###   ##,###   ##,###   "
  46.     PRINT #1, USING P$; A$(N); A(N, 1); B(N, 5); B(N, 1); B(N, 2); B(N, 3); B(N, 4); B(N, 21)
  47. IF D$ <> "N" THEN
  48.     PRINT #1, USING P$; A$(8); A(8, 1); B(8, 5); B(8, 1); B(8, 2); B(8, 3); B(8, 4); B(8, 21)
  49. N = C
  50. PRINT #1,
  51. PRINT #1,
  52. PRINT #1, "                                 BLEND ANALYSIS"
  53. PRINT #1,
  54. ' COAL BLEND LESS PETCOKE ANALYSIS
  55. A(9, 1) = A(10, 1) - A(8, 1)
  56. E(11, 5) = (E(1, 5) - A(8, 1) * B(8, 5) / 100) * 100 / A(9, 1)
  57. E(11, 1) = (E(1, 1) - A(8, 1) * B(8, 1) / 100) * 100 / A(9, 1)
  58. E(11, 2) = (E(1, 2) - A(8, 1) * B(8, 2) / 100) * 100 / A(9, 1)
  59. E(11, 3) = (E(1, 3) - A(8, 1) * B(8, 3) / 100) * 100 / A(9, 1)
  60. E(11, 4) = (E(1, 4) - A(8, 1) * B(8, 4) / 100) * 100 / A(9, 1)
  61. E(11, 21) = (E(1, 21) - A(8, 1) * B(8, 21) / 100) * 100 / A(9, 1)
  62. E(11, 22) = (E(1, 22) - A(8, 1) * B(8, 22) / 100) * 100 / A(9, 1)
  63. E(8, 1) = B(8, 1) * (100 - B(8, 5)) / 100
  64. E(8, 2) = B(8, 2) * (100 - B(8, 5)) / 100
  65. E(8, 3) = B(8, 3) * (100 - B(8, 5)) / 100
  66. E(8, 4) = B(8, 4) * (100 - B(8, 5)) / 100
  67. E(8, 21) = B(8, 21) * (100 - B(8, 5)) / 100
  68. PRINT #1, "                                 **************************WET BASIS****************               "
  69. PRINT #1, "                 WET COAL       H20      F.C.      ASH          VOL.MAT.              S        O2  "
  70. PRINT #1, "                 IN MIX%         %        %         %               %                 %        %   "
  71. Y = E(11, 4)
  72. X = E(11, 21)
  73. PRINT #1, USING P$; A$(9); A(9, 1); E(11, 5); E(11, 1); E(11, 2); E(11, 3); Y; X
  74. Y = E(8, 4)
  75. X = E(11, 21)
  76. PRINT #1, USING P$; A$(8); A(8, 1); E(8, 5); E(8, 1); E(8, 2); E(8, 3); Y; X
  77. Y = E(1, 4)
  78. X = E(1, 21)
  79. PRINT #1, USING P$; A$(10); A(10, 1); E(10, 5); E(10, 1); E(10, 2); E(10, 3); Y; X
  80. PRINT #1,
  81. ' PRODUCED COKE (COKE PUSHED FROM THE OVENS)=COAL+PETCOKE
  82. Z(4, 1) = E(11, 1) + E(11, 2) + 9.000001E-02 * E(11, 3) + 1.18 * (100 - E(11, 5)) / 100
  83. Z(4, 1) = (Z(4, 1) / 100) * 2000 * (A(9, 1) / 100)
  84. Z(4, 2) = (B(8, 1) + B(8, 2)) * ((100 - B(8, 5)) / 100)
  85. Z(4, 2) = (Z(4, 2) / 100) * 2000 * (A(8, 1) / 100)
  86. Z(4, 3) = Z(4, 1) + Z(4, 2)
  87. Z(5, 1) = E(11, 1) + E(11, 2)
  88. Z(6, 1) = E(11, 3) - E(11, 21)
  89. ' T IS THE COKING TEMPERATURE IN KELVIN
  90. T = 1323
  91. Z(6, 1) = (Z(6, 1) ^ (1.26 * (T / 1000) ^ 1.4)) / (9.5 * (T / 1000) ^ 7.3)
  92. Z(5, 1) = Z(5, 1) + Z(6, 1)
  93. Z(5, 1) = (Z(5, 1) / 100) * 2000 * (A(9, 1) / 100)
  94. Z(5, 2) = (B(8, 1) + B(8, 2)) * ((100 - B(8, 5)) / 100)
  95. Z(5, 2) = (Z(5, 2) / 100) * 2000 * (A(8, 1) / 100)
  96. Z(5, 3) = Z(5, 1) + Z(5, 2)
  97. Z(6, 1) = (1 / 2) * (Z(4, 1) + Z(5, 1))
  98. Z(6, 2) = (1 / 2) * (Z(4, 2) + Z(5, 2))
  99. Z(6, 3) = (1 / 2) * (Z(4, 3) + Z(5, 3))
  100. ' TAR YIELD
  101. Z(1, 1) = 8.399999 * (E(11, 3) - E(11, 21)) ^ 2 / T
  102. Z(1, 1) = (Z(1, 1) / 100) * (A(9, 1) / 100) * 2000
  103. Z(1, 2) = .95 * B(8, 3) * ((100 - B(8, 5)) / 100)
  104. Z(1, 2) = (Z(1, 2) / 100) * (A(8, 1) / 100) * 2000
  105. Z(1, 3) = Z(1, 1) + Z(1, 2)
  106. ' LIGHT OIL YIELD
  107. Z(2, 1) = -.284 + .0384 * E(11, 3)
  108. Z(2, 1) = (Z(2, 1) / 100) * (A(9, 1) / 100) * 2000
  109. Z(2, 2) = 0
  110. Z(2, 3) = Z(2, 1) + Z(2, 2)
  111. ' COKE OVEN GAS YIELD
  112. Z(3, 1) = 14500 * E(11, 1) / 100
  113. Z(3, 1) = .105 * (E(11, 22) - Z(3, 1))
  114. Z(3, 1) = Z(3, 1) * (T / E(11, 3)) ^ (1 / 2)
  115. Z(3, 1) = Z(3, 1) * 2000 / (500 * 35.6)
  116. Z(3, 1) = E(3, 1) * (A(9, 1) / 100)
  117. Z(3, 2) = .05 * B(8, 3) * (100 - B(8, 5)) / 100
  118. Z(3, 2) = (Z(3, 2) / 100) * 2000
  119. Z(3, 2) = Z(3, 2) * (A(8, 1) / 100)
  120. Z(3, 3) = Z(3, 1) + Z(3, 2)
  121. ' DETERMINE COKE FC, ASH, VM AND S ANALYSIS ON A DRY WT BASIS
  122. A(12, 1) = (Z(6, 3) / 2000) * 100
  123. E(12, 2) = (E(1, 2) / A(12, 1)) * 100
  124. E(12, 3) = .9
  125. E(12, 4) = .6 * (A(9, 1) / 100) * E(11, 4)
  126. E(12, 4) = E(12, 4) + .8 * (A(8, 1) / 100) * E(8, 4)
  127. E(12, 4) = (E(12, 4) / A(12, 1)) * 100
  128. E(12, 1) = 100 - E(12, 2) - E(12, 3)
  129. X = E(12, 4)
  130. Q$ = "THE OXYGEN CONTENT OF THE WET COAL OPRTION OF THE BLEND IS BY WT ##,###%"
  131. PRINT #1, USING Q$; E(11, 21)
  132. R$ = "THE HEATING VALUE OF THE WET COAL PORTION OF THE BLEND IN BTU/LB IS #####"
  133. PRINT #1, USING R$; E(11, 22)
  134. ' COKE OVEN GAS FOR UNDERFIRING REQUIREMENT
  135. ' 1,022 BTU/LB OF DRY COAL; 1,710 BTU/LB OF WATER
  136. ' C.O.G. IS AT 35.6 CU FT/LB AND 500 BTU/LB OF WATER
  137. Z(3, 4) = 1022 * 2000 * ((100 - E(1, 5)) / 100)
  138. Z(3, 4) = E(3, 4) + 1710 * 2000 * (E(1, 5) / 100)
  139. Z(3, 4) = Z(3, 4) / (500 * 35.6)
  140. 'PRODUCED COKE TO FURNACE COKE, BREEZE AND BUCKWHEAT
  141. 'L=L(2,1); M=E(2,2); S=E(1,17); N=L(1,1)
  142. 'BREEZE; PRODUCED COKE ASH; STABILITY; FURNACE COKE
  143. M = E(12, 2)
  144. L = .79 + (1.824 * M - .152 * S)
  145. Z(7, 3) = Z(6, 3) * (L / 100)
  146. Z(7, 5) = Z(7, 3)
  147. Z(8, 3) = Z(6, 3) - Z(7, 3)
  148. FOR i = 1 TO 8
  149.     Z(i, 5) = Z(i, 3) - Z(i, 4)
  150. 'PRODUCTS PER NT OF DRY FURNACE COKE
  151. FOR i = 1 TO 8
  152.     Z(i, 6) = Z(i, 5) * (2000 / Z(8, 5))
  153. 'UNIT VALUES
  154. Z(1, 7) = .38 / 9.68 '                                              1410
  155. Z(2, 7) = .5 / 7.41 '                                               1420
  156. Z(3, 7) = (2.94 / 1000000!) * 500 * 35.6 '                          1430
  157. Z(7, 7) = 39.7 / (2000 * (100 - 12) / 100) '                        1440
  158. 'DETERMINE VALUE PER NT OF FURNACE COKE
  159. FOR i = 1 TO 8
  160.     Z(i, 8) = Z(i, 6) * Z(i, 7)
  161. PRINT #1,
  162. PRINT #1,
  163. PRINT #1,
  164. PRINT #1, "                                               PRODUCTS OF COKING "
  165. PRINT #1,
  166. B$(1) = "COAL"
  167. B$(2) = "PETCOKE"
  168. B$(3) = "BLEND"
  169. B$(4) = "USED"
  170. B$(5) = "PRODUCT"
  171. B$(6) = "/NT COKE"
  172. B$(7) = "$/LB"
  173. B$(8) = "$/NT COKE"
  174. PRINT #1, "ITEM                  TAR       L.OIL     COKE OVEN      COKE     COKE     FURNACE"
  175. PRINT #1, "LB/NT                                        GAS         TOTAL    BREEZE     COKE "
  176. FOR i = 1 TO 6
  177.     S$ = "\                     \    ###.####  ###.####  ###.####  ###.####  ###.####  ###.####"
  178.     PRINT #1, USING S$; B$(i); Z(1, i); Z(2, i); Z(3, i); Z(6, i); Z(7, i); Z(8, 1)
  179. PRINT #1,
  180. PRINT #1,
  181. PRINT #1, "   COKE PRODUCED FROM COAL ONLY    TOTAL COKE     BREEZE &     FURNACE"
  182. PRINT #1, "   FORMULA 1   FORMULA 2 AVERAGE    PRODUCED      BUCKWHEAT      COKE "
  183. T$ = "    ####.##   ####.##   ####.##   ####.##   ####.##   ####.##"
  184. PRINT #1, USING T$; Z(4, 1); Z(5, 1); Z(6, 1); Z(6, 3); Z(7, 3); Z(8, 3)
  185. 'COAL COST
  186. C(9, 2) = 2000 / Z(8, 5)
  187. FOR i = 1 TO 8
  188.     C(i, 2) = C(9, 2) * A(i, 1) / 100
  189.     C(i, 3) = C(i, 2) * (100 - B(i, 5)) / 100
  190.     C(i, 4) = C(i, 1) * C(i, 2)
  191.     C(9, 3) = C(9, 3) + C(i, 3)
  192.     C(9, 4) = C(9, 4) + C(i, 4)
  193. C(9, 1) = C(9, 4) / C(9, 2)
  194. PRINT #1,
  195. PRINT #1,
  196. PRINT #1,
  197. PRINT #1, "  COAL NAME       UNIT WET     WET COAL NT/        DRY COAL NT/       COAL COST   "
  198. PRINT #1, "   IN BLEND       COAL COST      NT DRY              NT DRY          $/NT OF DRY  "
  199. PRINT #1, "                    $/NT         FURNACE COKE      FURNACE COKE     FURNACE COKE  "
  200. FOR i = 1 TO N
  201.     U$ = "\                \  ##.##            ##.##             ##.##               ###.###"
  202.     PRINT #1, USING U$; A$(i); C(i, 1); C(i, 2); C(i, 3); C(i, 4)
  203. IF D$ <> "N" THEN
  204.     PRINT #1, USING U$; A$(8); C(8, 1); C(8, 2); C(8, 3); C(8, 4)
  205. PRINT #1,
  206. PRINT #1, USING U$; A$(10); C(9, 1); C(9, 2); C(9, 3); C(9, 4)
  207. PRINT #1,
  208. PRINT #1,
  209. 'WET COAL BLEND, DRY COAL BLEND AND COKE ANALYSIS
  210. 'WET COAL BLEND ANALYSIS
  211. A = A(10, 1)
  212. B = E(1, 5)
  213. C = E(1, 1)
  214. D = E(1, 2)
  215. E = E(1, 3)
  216. F = E(1, 4)
  217. A$ = "WET BLEND"
  218. PRINT #1, USING P$; A$; A; B; C; D; E; F; E(1, 21)
  219. 'DRY COAL BLEND ANALYSIS
  220. A = A(10, 1) - E(1, 5)
  221. C = E(1, 1) * 100 / A
  222. D = E(1, 2) * 100 / A
  223. E = E(1, 3) * 100 / A
  224. F = E(1, 4) * 100 / A
  225. G = E(1, 21) * 100 / A
  226. H = E(1, 22) * 100 / A
  227. A$ = "DRY BLEND"
  228. E(1, 5) = 0!
  229. PRINT #1, USING P$; A$; A(10, 1); E(1, 5); C; D; E; F; G
  230. PRINT #1,
  231. PRINT #1,
  232. V$ = "THE HEATING VALUE OF THE WET BLEND IN BTU/LB IS #####"
  233. PRINT #1, USING V$; E(1, 22)
  234. W$ = "THE HEATING VALUE OF THE DRY BLEND IN BTU/LB IS #####"
  235. PRINT #1, USING W$; H
  236. PRINT #1,
  237. PRINT #1,
  238. A$(12) = "FURNACE COKE"
  239. A$(13) = "TOTAL COKE"
  240. PRINT #1, "           DRY COKE    H20     F.C.    ASH     VOL. MAT.    S "
  241. PRINT #1, '           YIELD%       %       %       %           %       % "
  242. PRINT #1, USING P$; A$(13); A(12, 1); E(12, 5); E(12, 1); E(12, 2); E(12, 3); X
  243. Y = (Z(8, 3) / 2000) * 100
  244. PRINT #1, USING P$; A$(12); Y; E(12, 5); E(12, 1); E(12, 2); E(12, 3); X
  245. PRINT #1,
  246. PRINT #1,
  247. PRINT #1, " DESCRIPTION                                   $NT DRY          $NT DRY   "
  248. PRINT #1, "                                             FURNACE COKE    FURNACE COKE "
  249. PRINT #1, " RAW MATERIAL COST"
  250. PRINT #1, "            COAL  "
  251. X$ = "                                                    ###.###"
  252. PRINT #1, USING X$; C(9, 4)
  253. PRINT #1, "         BULK DENSITY OIL"
  254. PRINT #1, "         1.53 GAL/NT   FCE COKE" '                           4150
  255. PRINT #1, "         AT $0.50/GALLON       " '                           4160
  256. PRINT #1, "                                               0.770 " '     4170
  257. PRINT #1, "             INVENTORY COST AT 1%"
  258. C(11, 4) = Z(3, 8) * Z(3, 4) / Z(3, 5)
  259. PRINT #1, USING X$; C(10, 4)
  260. PRINT #1, "       COG FOR UNDERFIRING"
  261. C(11, 4) = Z(3, 8) * Z(3, 4) / Z(3, 5)
  262. PRINT #1, USING X$; C(11, 4)
  263. PRINT #1, "           SUBTOTAL RAW MATERIALS"
  264. C(12, 4) = C(9, 4) + .77 + C(10, 4) + C(11, 4) '                        4410
  265. Y$ = "                                                       ###.###            ###.###"
  266. PRINT #1, USING Y$; C(12, 4); C(12, 4)
  267. PRINT #1,
  268. PRINT #1, " BY-PRODUCT CREDITS"
  269. PRINT #1, "     EXCESS COKE OVEN GAS"
  270. PRINT #1, USING X$; Z(3, 8) * (-1)
  271. PRINT #1, "       COG FOR UNDERFIRING"
  272. A = Z(3, 8) * Z(3, 4) / Z(3, 5) * (-1)
  273. PRINT #1, USING X$; A
  274. PRINT #1, "      TOTAL COKE OVEN GAS"
  275. T = Z(3, 8) * Z(3, 3) / Z(3, 5) * (-1)
  276. PRINT #1, USING X$; T
  277. PRINT #1,
  278. PRINT #1, "       TAR"
  279. PRINT #1, USING X$; Z(1, 8) * (-1)
  280. PRINT #1, "       LIGHT OIL"
  281. PRINT #1, USING X$; Z(2, 8) * (-1)
  282. PRINT #1, "              COKE BREEZE AND BUCKWHEAT"
  283. PRINT #1, USING X$; Z(7, 8) * (-1)
  284. B = T - Z(1, 8) - Z(2, 8) - Z(7, 8)
  285. PRINT #1, "               TOTAL BY-PRODUCTS CREDITS"
  286. PRINT #1, USING Y$; B; B
  287. PRINT #1,
  288. PRINT #1, " CONVERSION COST  "
  289. PRINT #1,
  290. PRINT #1, "              CONVERSION - VARIABLE"
  291. C = 16.23 '                                                         4690
  292. PRINT #1, USING X$; C
  293. PRINT #1, "             CONVERSION - FIXED"
  294. D = 193073! / (7 * 100 * 18 * (Z(8, 5) / 2000)) '                   4720
  295. PRINT #1, USING X$; D
  296. PRINT #1, "             TOTAL CONVERSION"
  297. E = C + D
  298. PRINT #1, USING Y$; E; E
  299. PRINT #1,
  300. PRINT #1, "  TOTAL PRODUCTION COST"
  301. PRINT #1, " $/NT DRY FURNACE COKE"
  302. G = C(12, 4) + B + E
  303. PRINT #1, USING Y$; G; G
  304. PRINT #1,
  305. PRINT #1,
  306. PRINT #1,
  307. PRINT #1,
  308. PRINT #1,
  309. PRINT #1, "END OF RUN"
  310. CLOSE COM1
  311.