Author Topic: Need Help converting program from old qbasic to qb64  (Read 4148 times)

0 Members and 1 Guest are viewing this topic.

Offline steinguy

  • Newbie
  • Posts: 4
    • View Profile
Need Help converting program from old qbasic to qb64
« on: March 07, 2021, 01:50:14 pm »



tlup:
OPEN "com1:1200,n,8,1" FOR RANDOM AS #1

PRINT #1, "D1973D1973D1973BBBBBBBBBB";
t = 3: GOSUB 3000
WHILE LOC(1) > 0
    jj$ = INPUT$(LOC(1), 1)
    GOSUB 3000
WEND
PRINT "Monitor mode initialized..."

PRINT "Waiting 3 minutes for warm up..."
tm = TIMER
WHILE TIMER - tm < 180
    IF INKEY$ <> "" THEN GOTO skip
WEND
skip:
PRINT "3 minutes has expired..."
FOR k = 1 TO 4
    FOR j = 1 TO 4
        SOUND 2000, 1
        FOR i = 1 TO 1000: NEXT i
    NEXT j
    FOR i = 1 TO 2000: NEXT i
NEXT k
PRINT "Remove RF jumper then..."
PRINT "Set LM723 output to 5.000V...": GOSUB 1000
PRINT "Set ADC reference voltage to 1.0900V...": GOSUB 1000
PRINT "Set RF voltage to -2.150 (this depends on probe)...": GOSUB 1000
PRINT "-> replace rf jumper"
PRINT "ADC test:  use hands to make diode voltage change..."
PRINT "--> hit key when through"
PRINT "Diode", "T0", "T1", "T2", "Zero"
GOSUB 2000
PRINT "Testing Balance Relay..."
PRINT "    Does it BUZZZZ?????"
PRINT "--> hit a key when ready to continue"
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = ""
    PRINT #1, "89";
WEND
PRINT "Waiting for buffer to empty..."
PRINT #1, "I";
INPUT #1, a$
PRINT #1, "D";
PRINT "DAC test in progress": GOSUB 1000
klup: PRINT "Keyboard test: hit 0 1 2 3 4 5 6 7 8 9 MODE PRINT and GO keys"
PRINT #1, "G"
PRINT #1, "H";
INPUT #1, a$
IF a$ = "0123456789-." THEN PRINT "Keyboard OK": GOTO kok
SOUND 440, 2
PRINT "Keyboard test failed-- retry(Y/N)?"
klup2: a$ = INKEY$
IF a$ = "Y" THEN GOTO klup
IF a$ = "y" THEN GOTO klup
IF a$ = "n" THEN GOTO kok
IF a$ = "N" THEN GOTO kok
GOTO klup2
kok:
PRINT "Testing Aux Module..."
OPEN "i", #2, "c:\sb900\auxlog"
PRINT #1, "ADFBFB";
WHILE NOT EOF(2)
    INPUT #2, b$
    tm = TIMER
    WHILE (TIMER - tm < 3) AND (LOC(1) < 1): WEND
    IF LOC(1) > 0 THEN INPUT #1, a$
    IF a$ <> b$ THEN GOTO mbad
WEND
t = 3: GOSUB 3000
IF LOC(1) > 0 THEN PRINT "Too Many entries": GOTO mbad
GOTO mok
mbad:
PRINT "############## Error in reading Aux Module!!!"
SOUND 880, 2
mok: PRINT "Aux Module test complete"
PRINT "Serial port handshaking check"
PRINT #1, "ADFBFB";
CLOSE
PRINT "-> Listing on LCD be 'frozen'"
PRINT "-> Unplug Aux Module"
PRINT "-> Unplug serial port and listing should finish"
PRINT
PRINT "-> Finish by doing the 'twist test'"
PRINT
PRINT "?? test another?? (Y/N)??"
dlup: a$ = INKEY$
IF a$ = "Y" THEN GOTO tlup
IF a$ = "y" THEN GOTO tlup
IF a$ = "n" THEN GOTO done
IF a$ = "N" THEN GOTO done
GOTO dlup
done:
END
1000 PRINT "--> Hit a key when ready to continue..."
WHILE INKEY$ <> "": WEND
WHILE INKEY$ = "": WEND
RETURN
2000 REM monitor diode voltage
WHILE INKEY$ <> "": WEND
posn = CSRLIN
PRINT #1, "R0";
WHILE INKEY$ = ""
    PRINT #1, "R0";
    INPUT #1, v0
    PRINT #1, "BR1";
    INPUT #1, v1
    PRINT #1, "BR2";
    INPUT #1, v2
    PRINT #1, "BR3";
    INPUT #1, v3
    PRINT #1, "BR4";
    INPUT #1, v4
    PRINT #1, "B";
    IF v0 > 50000 THEN v0 = v0 - 100000
    IF v1 > 50000 THEN v1 = v1 - 100000
    IF v2 > 50000 THEN v2 = v2 - 100000
    IF v3 > 50000 THEN v3 = v3 - 100000
    IF v4 > 50000 THEN v4 = v4 - 100000

    LOCATE posn, 1
    PRINT v0, v1, v2, v3, v4; "        ";
WEND
PRINT #1, "B";
PRINT
RETURN

3000 REM routine to wait t seconds
tm = TIMER
WHILE TIMER - tm < t: WEND
RETURN

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Need Help converting program from old qbasic to qb64
« Reply #1 on: March 07, 2021, 01:51:20 pm »
Just for readability, enclosing it in a code block:


Code: QB64: [Select]
  1. tlup:
  2. OPEN "com1:1200,n,8,1" FOR RANDOM AS #1
  3.  
  4. PRINT #1, "D1973D1973D1973BBBBBBBBBB";
  5. t = 3: GOSUB 3000
  6. WHILE LOC(1) > 0
  7.     jj$ = INPUT$(LOC(1), 1)
  8.     GOSUB 3000
  9. PRINT "Monitor mode initialized..."
  10.  
  11. PRINT "Waiting 3 minutes for warm up..."
  12. tm = TIMER
  13. WHILE TIMER - tm < 180
  14.     IF INKEY$ <> "" THEN GOTO skip
  15. skip:
  16. PRINT "3 minutes has expired..."
  17. FOR k = 1 TO 4
  18.     FOR j = 1 TO 4
  19.         SOUND 2000, 1
  20.         FOR i = 1 TO 1000: NEXT i
  21.     NEXT j
  22.     FOR i = 1 TO 2000: NEXT i
  23. PRINT "Remove RF jumper then..."
  24. PRINT "Set LM723 output to 5.000V...": GOSUB 1000
  25. PRINT "Set ADC reference voltage to 1.0900V...": GOSUB 1000
  26. PRINT "Set RF voltage to -2.150 (this depends on probe)...": GOSUB 1000
  27. PRINT "-> replace rf jumper"
  28. PRINT "ADC test:  use hands to make diode voltage change..."
  29. PRINT "--> hit key when through"
  30. PRINT "Diode", "T0", "T1", "T2", "Zero"
  31. GOSUB 2000
  32. PRINT "Testing Balance Relay..."
  33. PRINT "    Does it BUZZZZ?????"
  34. PRINT "--> hit a key when ready to continue"
  35.     PRINT #1, "89";
  36. PRINT "Waiting for buffer to empty..."
  37. PRINT #1, "I";
  38. INPUT #1, a$
  39. PRINT #1, "D";
  40. PRINT "DAC test in progress": GOSUB 1000
  41. klup: PRINT "Keyboard test: hit 0 1 2 3 4 5 6 7 8 9 MODE PRINT and GO keys"
  42. PRINT #1, "G"
  43. PRINT #1, "H";
  44. INPUT #1, a$
  45. IF a$ = "0123456789-." THEN PRINT "Keyboard OK": GOTO kok
  46. SOUND 440, 2
  47. PRINT "Keyboard test failed-- retry(Y/N)?"
  48. klup2: a$ = INKEY$
  49. IF a$ = "Y" THEN GOTO klup
  50. IF a$ = "y" THEN GOTO klup
  51. IF a$ = "n" THEN GOTO kok
  52. IF a$ = "N" THEN GOTO kok
  53. GOTO klup2
  54. kok:
  55. PRINT "Testing Aux Module..."
  56. OPEN "i", #2, "c:\sb900\auxlog"
  57. PRINT #1, "ADFBFB";
  58.     INPUT #2, b$
  59.     tm = TIMER
  60.     WHILE (TIMER - tm < 3) AND (LOC(1) < 1): WEND
  61.     IF LOC(1) > 0 THEN INPUT #1, a$
  62.     IF a$ <> b$ THEN GOTO mbad
  63. t = 3: GOSUB 3000
  64. IF LOC(1) > 0 THEN PRINT "Too Many entries": GOTO mbad
  65. GOTO mok
  66. mbad:
  67. PRINT "############## Error in reading Aux Module!!!"
  68. SOUND 880, 2
  69. mok: PRINT "Aux Module test complete"
  70. PRINT "Serial port handshaking check"
  71. PRINT #1, "ADFBFB";
  72. PRINT "-> Listing on LCD be 'frozen'"
  73. PRINT "-> Unplug Aux Module"
  74. PRINT "-> Unplug serial port and listing should finish"
  75. PRINT "-> Finish by doing the 'twist test'"
  76. PRINT "?? test another?? (Y/N)??"
  77. dlup: a$ = INKEY$
  78. IF a$ = "Y" THEN GOTO tlup
  79. IF a$ = "y" THEN GOTO tlup
  80. IF a$ = "n" THEN GOTO done
  81. IF a$ = "N" THEN GOTO done
  82. GOTO dlup
  83. done:
  84. 1000 PRINT "--> Hit a key when ready to continue..."
  85. 2000 REM monitor diode voltage
  86. posn = CSRLIN
  87. PRINT #1, "R0";
  88.     PRINT #1, "R0";
  89.     INPUT #1, v0
  90.     PRINT #1, "BR1";
  91.     INPUT #1, v1
  92.     PRINT #1, "BR2";
  93.     INPUT #1, v2
  94.     PRINT #1, "BR3";
  95.     INPUT #1, v3
  96.     PRINT #1, "BR4";
  97.     INPUT #1, v4
  98.     PRINT #1, "B";
  99.     IF v0 > 50000 THEN v0 = v0 - 100000
  100.     IF v1 > 50000 THEN v1 = v1 - 100000
  101.     IF v2 > 50000 THEN v2 = v2 - 100000
  102.     IF v3 > 50000 THEN v3 = v3 - 100000
  103.     IF v4 > 50000 THEN v4 = v4 - 100000
  104.  
  105.     LOCATE posn, 1
  106.     PRINT v0, v1, v2, v3, v4; "        ";
  107. PRINT #1, "B";
  108.  
  109. 3000 REM routine to wait t seconds
  110. tm = TIMER
  111. WHILE TIMER - tm < t: WEND
Shuwatch!

Offline steinguy

  • Newbie
  • Posts: 4
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #2 on: March 07, 2021, 01:53:03 pm »
thanks

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #3 on: March 07, 2021, 08:39:56 pm »
Appears that it should work as is, but it may overheat your CPU.

Loops that have no input (INKEY$ doesn't count) should contain a _LIMIT. 
Using FOR/NEXT as a delay will be so fast as to be useless - use _DELAY.
« Last Edit: March 07, 2021, 08:42:45 pm by Richard Frost »
It works better if you plug it in.

Offline steinguy

  • Newbie
  • Posts: 4
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #4 on: March 07, 2021, 09:22:15 pm »
Richard frost
Not much of a programmer to be honest. The error I'm getting is bad file mode at print# 1,  ,"d1973....." line. Its essentially not send that string to machine via serial port.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #5 on: March 07, 2021, 10:05:51 pm »
I looked for code I used long ago.  There are optional but sometimes necessary
parameters for a serial port.   Like:

OPEN "COM1:1200,n,8,1,CD,CS,DS,RS,RB4096" for random as #1

And rather than relying on handshaking to take care of it for you, don't be sending
so much data at once.   
It works better if you plug it in.

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #6 on: March 10, 2021, 05:41:01 am »
Program runs fine under QuickBasic 4.5 in 64-bit Windows 10, and QuickBasic 4.5 is what it looks like it was written in.

When I say "runs fine", I mean that it gets past the line in question OK, and prints to my laser printer.

Obviously, I don't possess whatever the device is, and so can't check that aspect of things.

Malcolm
« Last Edit: March 10, 2021, 05:42:14 am by MWheatley »

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #7 on: March 18, 2021, 04:06:52 am »
The serial ports must be used  using put and get, char by char, so you must create your own line function, like this to substitute the print command

Code: QB64: [Select]
  1. SUB PrintCOM (line$) STATIC
  2.   DIM car AS _BYTE 'STRING * 1
  3.   FOR i = 1 TO LEN(line$)
  4.     car = ASC(line$, i)
  5.     PUT #1, , car
  6.   NEXT i
  7.   car = 13 'Cr: End of line in Windows
  8.   PUT #1, , car
  9.  


Offline steinguy

  • Newbie
  • Posts: 4
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #8 on: March 18, 2021, 11:51:17 am »
@MWheatley ,
Can you possibly point me to a useable download link, I tried two different ones and Im getting an uncompatible error.

Thanks,

Steinguy

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #9 on: March 18, 2021, 01:50:53 pm »
I think you're asking for a link for QuickBasic 4.5?  You'll also need vDosPlus to run it under.

My recommendation would be prove to yourself it works, and then port it to QB64 using the advice in this thread.  Much simpler than using DOS-era code under a DOS emulator!

I bought my copy of QuickBasic 4.5 back in 1989, but you'll probably find it on an abandonware site -- I'd try Vetusware first.

You can get vDosPlus here: http://vdosplus.org/

That said, I'd click through to the link to Ed Mendelson's download page, and download it from there.

Malcolm

Offline Bert22306

  • Forum Regular
  • Posts: 206
    • View Profile
Re: Need Help converting program from old qbasic to qb64
« Reply #10 on: March 18, 2021, 04:21:25 pm »
Before stumbling onto QB64, I was using QB v7.1, which I got from this site:

https://www.qbasic.net/en/qbasic-downloads/compiler/qbasic-compiler.htm

As you can see, there are also an English and a German version of QB v4.5 available there. I used to run v7.1 over DOSbox, over Windows 7.

https://www.dosbox.com/download.php?main=1

There was a speed hit, but that aside, it worked fine. Also, you could get fonts for DOSbox, to expand the window of the QB IDE to more lines than the old, small default.