Author Topic: Help with program  (Read 2528 times)

0 Members and 1 Guest are viewing this topic.

Offline Aeveus

  • Newbie
  • Posts: 5
Help with program
« on: March 13, 2020, 02:32:56 pm »
Hi I'm taking a class where we are learning with qb64 and I can't seem to get this program to run and I just can't figure out why. Any help is very much appreciated!
Code: QB64: [Select]
  1. '*************************** Program Mainline ******************************
  2. GOSUB InitializeVariables
  3. GOSUB PrintHeadings
  4. GOSUB ProcessDetail
  5. GOSUB PrintOutput
  6. '*************************** Initialize Variables ************************
  7. IntitializeVariables:
  8. T1$ = "     MODEL CARS"
  9. H1$ = "Manufacturer#   Yr  Make    Model       Description         Price"
  10. D1$ = "\          \  ##  \     \  \    \   \                          \    ##.##"
  11. TL$ = "TOTAL PRICE                                                  ###.##"
  12. '************************** Print Headings *******************************
  13. PrintHeadings:
  14. PRINT T1$
  15. PRINT H1$
  16. '***************************  Process Detail *****************************
  17. ProcessDetail:
  18. GOSUB ReadData
  19. DO UNTIL Manufacturer$ = "END"
  20.     GOSUB CalculateAnswer
  21.     GOSUB PrintDetail
  22.     GOSUB ReadData
  23. '***************************** Read Data *********************************
  24. ReadData:
  25. READ Manufacturer$, Year, Make$, Model$, Description$, Price
  26. DATA BMR-R79,49,FIAT,500B,GILLETE RAZOR,7.99
  27. DATA HOTWELS-34,57,CHEVY,NOMAD,4/DR STATION WAGON,12.95
  28. DATA MATCHBX-878,73,FORD,BRONC,3/DR 4X4 RED SPARE WHL,25.99
  29. DATA MATCHBX-72,69,BUIK,CENTY,YELLOW TAXI,1.49
  30. DATA BRM-R88,34,BUGAT,TY575,RACER BLACK,35.00
  31. DATA MATCHBX-25,80,LINCO,MRKIV,WHITE LIMOUSINE,14.99
  32. DATA LESNEY-Y42,82,CHEVY,MALBU,4/DR GREEN PASSENGER,1.99
  33. DATA HASBRO-119,75,AMC,GRMLN,2/DR SEDAN YELLOW,1.69
  34. DATA TABY-6332,71,TOYOT,CELIC,2/DR SEDAN BLUE,2.99
  35. DATA BMR-SY238,36,ROLRY,SYLVC,4/DR SEDAN SILVER-GRAY,60.00
  36. DATA "END",0,0,0,0,0
  37. '**************************** Calculate Answer ************************
  38. CalculateAnswer:
  39. TotalPrice = TotalPrice + PRICE
  40. '*************************** Print Detail *******************************
  41. PrintDetail:
  42. PRINT USING D1$; Manufacturer$, Year, Make$, Model$, Description$, Price
  43. '**************************** Print Output ********************************
  44. PrintOutput:
  45. PRINT USING TL$; TotalPrice
  46. '

Marked as best answer by Aeveus on March 13, 2020, 10:54:55 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Help with program
« Reply #1 on: March 13, 2020, 02:37:13 pm »
Type-O line #3 spelling not same as sub

Looks good after that (well you could fix up alignments of header labels with data columns).
Model Cars.PNG
* Model Cars.PNG (Filesize: 14.51 KB, Dimensions: 643x359, Views: 292)
« Last Edit: March 13, 2020, 02:46:29 pm by bplus »

Offline Aeveus

  • Newbie
  • Posts: 5
Re: Help with program
« Reply #2 on: March 13, 2020, 02:56:44 pm »
Type-O line #3 spelling not same as sub

Looks good after that (well you could fix up alignments of header labels with data columns).

Thank you so much, lol! I swear I was staring at my screen for an hour looking for typos but I just kept glossing past it I guess.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Help with program
« Reply #3 on: March 13, 2020, 02:59:54 pm »
Yeah a time for another pair of eyes to look at it!

Welcome to forum :)

I confess I could not see the difference either, like an optical illusion!

I just copy/pasted the sub name on the red-lined GOSUB line.
« Last Edit: March 13, 2020, 03:23:14 pm by bplus »