Re: Yeah, get rid of the loop

by Docfxit (Login Docfxit)
R

 
Why does this go past the EOF?
Why doesn't this input anything? junk$ is blank every time.
I'm stopping the program after 40 loops.

WHILE NOT EOF(wsFileNum)
IF LOF(wsFileNum) >0 THEN junk$ = INPUT$(LOF(wsFileNum), # wsFileNum)
WEND

Thanks,

Docfxit

**Please Note: Since no one has posted any ideas I am posting this on QB64.net

This code is what I am using for testing the above statements:

DIM SHARED debugflag$
DIM SHARED var1$
DIM SHARED var2$
DECLARE SUB openWsPort (portNum)
CONST theComPort = 1
CONST comMode$ = ":9600,N,8,1,CS6000,DS6000" ' change baud here if you change s12 setting
ON ERROR GOTO ErrorHandler
debugflag$ = "Onn3" 'For debugging either Onn or off
Ix = 5
openWsPort theComPort
END

ErrorHandler:
Ix = Ix + 1
SELECT CASE ERR
CASE 155: LastErrorLine = _ERRORLINE
CASE ELSE: PRINT "Error code "; ErrorCode; " on line "; _ERRORLINE
END
END
END SELECT
IF ERR = 155 THEN 'Debug
'** Print line and variable to screen
IF var2$ "999" THEN
COLOR 11, 0: LOCATE Ix, 1: PRINT "On Line "; LastErrorLine; var1$; var2$ ' for debugging only
ELSE
COLOR 11, 0: LOCATE Ix, 1: PRINT "On Line "; LastErrorLine; var1$ ' for debugging only
END IF
END IF
IF Ix > 40 THEN ' 47 tops
Ix = Ix + 1
COLOR 13, 0: LOCATE Ix, 1: PRINT "Too many debugs Program Ended "
END
END IF
RESUME NEXT
SUB openWsPort (portNum)
'** Open the specified serial port. Use global constant comMode for baud
IF debugflag$ = "Onn3" THEN
var1$ = "OpenWsPort start " 'For Debuging Only
var2$ = "999" 'For Debuging Only
ERROR 155 'For Debuging Only
var1$ = "FreeFile = " 'For Debuging Only
var2$ = STR$(FREEFILE) 'For Debuging Only
ERROR 155 'For Debuging Only
var1$ = "wsFileNum = " 'For Debuging Only
var2$ = STR$(wsFileNum) 'For Debuging Only
ERROR 155 'For Debuging Only
var1$ = "portNum = " 'For Debuging Only
var2$ = STR$(portNum) 'For Debuging Only
ERROR 155 'For Debuging Only
var1$ = "Fid = " 'For Debuging Only
var2$ = STR$(Fid) 'For Debuging Only
ERROR 155 'For Debuging Only
END IF
DO
IF wsFileNum = 0 THEN ' don't open if already open
wsFileNum = FREEFILE ' get an unused file number

'now open the serial port
ComPortOpen$ = "Yes"

IF debugflag$ = "Onn3" THEN
var1$ = "Open Com Port " 'For Debuging Only
var2$ = "999" 'For Debuging Only
ERROR 155 'For Debuging Only
var1$ = "wsFileNum = " 'For Debuging Only
var2$ = STR$(wsFileNum) 'For Debuging Only
ERROR 155 'For Debuging Only
var1$ = "portNum = " 'For Debuging Only
var2$ = STR$(portNum) 'For Debuging Only
ERROR 155 'For Debuging Only
var1$ = "comMode$ 2= " 'For Debuging Only
var2$ = comMode$ 'For Debuging Only
ERROR 155 'For Debuging Only
END IF
OPEN "COM" + STR$(portNum) + comMode$ FOR RANDOM AS #wsFileNum
IF errnum = 0 THEN
var1$ = "COM exists! " 'For Debuging Only
var2$ = "999" 'For Debuging Only
ERROR 155 'For Debuging Only
END IF
WHILE NOT EOF(wsFileNum)
IF debugflag$ = "Onn3" THEN
var1$ = " LOF(wsFileNum)2 = " 'For Debuging Only
var2$ = STR$(LOF(wsFileNum)) 'For Debuging Only
ERROR 155 'For Debuging Only
END IF
IF LOF(wsFileNum) > 0 THEN junk$ = INPUT$(LOF(wsFileNum), # wsFileNum)
IF debugflag$ = "Onn3" THEN
var1$ = " junk$ = " 'For Debuging Only
var2$ = junk$ 'For Debuging Only
ERROR 155 'For Debuging Only
END IF
WEND
END IF
LOOP
END SUB




    
This message has been edited by Docfxit on May 14, 2012 1:40 PM
This message has been edited by Docfxit on May 14, 2012 1:05 PM

Posted on May 13, 2012, 6:39 AM

Respond to this message   

Return to Index

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement