Weekly Qbasic and Qb64 Lesson Topics
January 22, 2018, 03:58:05 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Fundamental Problem with QB64


Pages: [1]
  Print  
Author Topic: Fundamental Problem with QB64  (Read 13 times)
Luke
Newbie
*
Posts: 3


« on: December 18, 2017, 03:06:58 pm »

When one opens a com port to read a serial data buffer the open command automatically sets the EOF, LOC, and LOF to no message state.
I.E. the statement OPEN "COM3: 9600,n,8,1" for INPUT AS #1 will set EOF=-1. When attempt is made to obtain data from the com buffer with the INPUT statement you get an INPUT PAST END error because EOF=-1.
When you open the com port with the FOR RANDOM option then an attempt to obtain data with a GET statement you get a BAD RECORD LENGTH error due to LOF=0.
I have yet to find a way around this problem.

I have an A/D converter connected to a 1.2 V battery that has placed the message:   Voltage = 1.2* in the buffer. If I open FOR INPUT and upon the INPUT PAST END OF FILE error a DO YOU WANT TO CONTINUE dialog box appears. IF I select YES I get Vlae=12. That is every other character in the buffer. I altered the A/D output spacing to shift things by one space at the beginning and I get otg.2* . I.E the missing letters. Although not correct by any means it gives me confidence that the correct message is sitting in the buffer. I just can't read it because of the above defined problem.
Has anyone else encountered this problem? Is it due to my particular version compiler? Is there a "work around?"

I discovered a QB64 work around for the Fundamental Problem. just above the Z$=input (LOC(2),#2) statement i added line ON ERROR GOTO EHandler. Then at the end of the program I put
EHandler: 
errfile$ = _INCLERRORFILE$
RESUME NEXT

I used LOC for length of input record b/c LOF always =0. The EOF=-1 always generates an INPUT PAST END OF FILE error. This way the program steps over the error and continues.
It may not be the best way but it works for me.







« Last Edit: January 03, 2018, 11:24:26 am by Luke » Report Spam   Logged

Social Buttons

Luke
Newbie
*
Posts: 3


« Reply #1 on: January 03, 2018, 11:29:36 am »

I discovered a QB64 work around for the Fundamental Problem. just above the Z$=input (LOC(2),#2) statement i added line ON ERROR GOTO EHandler. Then at the end of the program I put
EHandler: 
errfile$ = _INCLERRORFILE$
RESUME NEXT

I used LOC for length of input record b/c LOF always =0. The EOF=-1 always generates an INPUT PAST END OF FILE error. This way the program steps over the error and continues.
It may not be the best way but it works for me.
As for the every other letter read. I jury rigged the output message of the A/D with spaces to output the characters in the position captured by the input command. Weird but it works and I am continuing with my project not really understanding why it's that way.
Report Spam   Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines