rjmccorkle
Programmer
I am writing a VB6 program to allow file transfers between a CNC machine and a computer. The From CNC To Commputer part doesn't work. The code I used in GWBasic that I can't replicate in VB is the subroutine at line 350:
270 PRINT
RINT" HIT INPUT KEY ON CNC NOW..."
280 OPEN BC$ AS #1:OPEN "O",2,F$
RINT#1,CHR$(13);
295 A$=INPUT$(1,#1)
RINT A$;:LINE INPUT#1,A$
RINT A$;:A$=INPUT$(1,#1)
300 IF EOF(1) THEN GOSUB 350
310 IF LOC(1)>128 THEN PAUSE=TRUE
RINT#1,XFF$;
320 A$=INPUT$(LOC(1),#1)
RINT#2,A$;
RINT A$;:IF LOC(1)>0 THEN 310
330 IF PAUSE THEN PAUSE=FALSE
RINT#1,XN$;
335 GOTO 300
350 FOR I=1 TO VF:IF NOT EOF(1) THEN I=999999!
352 IF LOC(1)>100 AND I<999999! THEN:A$=INPUT$(LOC(1),#1)
RINT#2,A$;
RINT A$;
355 NEXT I:IF I>999999! THEN RETURN
360 CLOSE:RETURN 20
Variable VF in the For/Next loop is a timing variable that is changed based on CPU speed.
In VB I have the MSComm1.EOFEnabled=True but it never is triggered, the CommEvent is always 2. Apparently the CNC sends over things that look like EOF but are not the actual EOF, hence the need for double checking in the 350 subroutine. When I run my VB code I get 2 good chunks of data about 300 bytes each, but at the end of the 3rd chunk, question marks start coming through. I'm using Xon/Xoff to try to control the flow (chr(17) & chr(19)). Here are some of the property values I am using:
MSComm1.NullDiscard = True
MSComm1.EOFEnable = True
MSComm1.Break = True
MSComm1.InputLen = 1
MSComm1.RThreshold = 1
MSComm1.InputMode = comInputModeText
I checked the SaxSoft comm control but it was a little too expensive as long as the GWBasic code works for us.
Any help would be appreciated.
Bob
270 PRINT
280 OPEN BC$ AS #1:OPEN "O",2,F$
295 A$=INPUT$(1,#1)
300 IF EOF(1) THEN GOSUB 350
310 IF LOC(1)>128 THEN PAUSE=TRUE
320 A$=INPUT$(LOC(1),#1)
330 IF PAUSE THEN PAUSE=FALSE
335 GOTO 300
350 FOR I=1 TO VF:IF NOT EOF(1) THEN I=999999!
352 IF LOC(1)>100 AND I<999999! THEN:A$=INPUT$(LOC(1),#1)
355 NEXT I:IF I>999999! THEN RETURN
360 CLOSE:RETURN 20
Variable VF in the For/Next loop is a timing variable that is changed based on CPU speed.
In VB I have the MSComm1.EOFEnabled=True but it never is triggered, the CommEvent is always 2. Apparently the CNC sends over things that look like EOF but are not the actual EOF, hence the need for double checking in the 350 subroutine. When I run my VB code I get 2 good chunks of data about 300 bytes each, but at the end of the 3rd chunk, question marks start coming through. I'm using Xon/Xoff to try to control the flow (chr(17) & chr(19)). Here are some of the property values I am using:
MSComm1.NullDiscard = True
MSComm1.EOFEnable = True
MSComm1.Break = True
MSComm1.InputLen = 1
MSComm1.RThreshold = 1
MSComm1.InputMode = comInputModeText
I checked the SaxSoft comm control but it was a little too expensive as long as the GWBasic code works for us.
Any help would be appreciated.
Bob