Microsoft KB Archive/169502: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 71: | Line 71: | ||
== MORE INFORMATION == | == MORE INFORMATION == | ||
The Microsoft Communication Control truncates all characters following, and including, a CHR(0) or NULL that is passed to its Input. This occurs when the | The Microsoft Communication Control truncates all characters following, and including, a CHR(0) or NULL that is passed to its Input. This occurs when the "NullDiscard" of the Microsoft Communication control set to ".F." | ||
=== Steps to Reproduce Behavior === | === Steps to Reproduce Behavior === | ||
Line 80: | Line 80: | ||
<p><span class="kbd userinput"> </span></p> | <p><span class="kbd userinput"> </span></p> | ||
<pre class="codesample"> OUTFORM = CreateObject( | <pre class="codesample"> OUTFORM = CreateObject("comtst1") | ||
OUTFORM.Show | OUTFORM.Show | ||
READ EVENTS | READ EVENTS | ||
Line 90: | Line 90: | ||
Width = 288 | Width = 288 | ||
DOCREATE = .T. | DOCREATE = .T. | ||
Caption = | Caption = "Form1" | ||
Name = | Name = "Form1" | ||
OUTVAL = .F. | OUTVAL = .F. | ||
ADD OBJECT TEXT1 AS TEXTBOX WITH ; | ADD OBJECT TEXT1 AS TEXTBOX WITH ; | ||
Line 98: | Line 98: | ||
TOP = 84, ; | TOP = 84, ; | ||
WIDTH = 229, ; | WIDTH = 229, ; | ||
Name = | Name = "Text1" | ||
ADD OBJECT Olecontrol1 AS Olecontrol WITH ; | ADD OBJECT Olecontrol1 AS Olecontrol WITH ; | ||
OLECLASS= | OLECLASS="MSCOMMLib.MSComm.1",; | ||
TOP = 12, ; | TOP = 12, ; | ||
LEFT = 0, ; | LEFT = 0, ; | ||
Line 106: | Line 106: | ||
WIDTH = 100, ; | WIDTH = 100, ; | ||
NULLDISCARD = .F., ; | NULLDISCARD = .F., ; | ||
Name = | Name = "Olecontrol1" | ||
ADD OBJECT Command1 AS CommandBUTTON WITH ; | ADD OBJECT Command1 AS CommandBUTTON WITH ; | ||
TOP = 37, ; | TOP = 37, ; | ||
Line 112: | Line 112: | ||
HEIGHT = 27, ; | HEIGHT = 27, ; | ||
WIDTH = 84, ; | WIDTH = 84, ; | ||
CAPTION = | CAPTION = "Open Port", ; | ||
TABINDEX = 2, ; | TABINDEX = 2, ; | ||
Name = | Name = "Command1" | ||
ADD OBJECT Command2 AS CommandBUTTON WITH ; | ADD OBJECT Command2 AS CommandBUTTON WITH ; | ||
TOP = 133, ; | TOP = 133, ; | ||
Line 120: | Line 120: | ||
HEIGHT = 27, ; | HEIGHT = 27, ; | ||
WIDTH = 84, ; | WIDTH = 84, ; | ||
CAPTION = | CAPTION = "Send", ; | ||
Name = | Name = "Command2" | ||
ADD OBJECT Command3 AS CommandBUTTON WITH ; | ADD OBJECT Command3 AS CommandBUTTON WITH ; | ||
TOP = 193, ; | TOP = 193, ; | ||
Line 127: | Line 127: | ||
HEIGHT = 27, ; | HEIGHT = 27, ; | ||
WIDTH = 84, ; | WIDTH = 84, ; | ||
CAPTION = | CAPTION = "Exit", ; | ||
Name = | Name = "Command3" | ||
PROCEDURE Command1.Click | PROCEDURE Command1.Click | ||
IF This.CAPTION= | IF This.CAPTION="Open Port" | ||
ThisForm.Olecontrol1.PORTOPEN=.T. | ThisForm.Olecontrol1.PORTOPEN=.T. | ||
This.Caption = | This.Caption = "Close Port" | ||
Else | Else | ||
ThisForm.Olecontrol1.PORTOPEN=.F. | ThisForm.Olecontrol1.PORTOPEN=.F. | ||
This.Caption = | This.Caption = "Open Port" | ||
EndIf | EndIf | ||
ENDPROC | ENDPROC | ||
Line 143: | Line 143: | ||
*** Send CHR() representation of numbers entered *** | *** Send CHR() representation of numbers entered *** | ||
OVAL1 = ALLTRIM(ThisForm.TEXT1.Value) | OVAL1 = ALLTRIM(ThisForm.TEXT1.Value) | ||
OVAL2 = | OVAL2 = "chr(" + STRTRAN(OVAL1, " ", ")+chr(") + ")" | ||
ThisForm.Olecontrol1.OUTPUT=&OVAL2 | ThisForm.Olecontrol1.OUTPUT=&OVAL2 | ||
ENDPROC | ENDPROC | ||
Line 160: | Line 160: | ||
<p><span class="kbd userinput"> </span></p> | <p><span class="kbd userinput"> </span></p> | ||
<pre class="codesample"> INFORM = CREATEOBJECT( | <pre class="codesample"> INFORM = CREATEOBJECT("comtst2") | ||
INFORM.SHOW | INFORM.SHOW | ||
READ EVENTS | READ EVENTS | ||
Line 170: | Line 170: | ||
Width = 410 | Width = 410 | ||
DoCreate = .T. | DoCreate = .T. | ||
Caption = | Caption = "Form1" | ||
Name = | Name = "Form1" | ||
inval1 = .F. | inval1 = .F. | ||
inval2 = .F. | inval2 = .F. | ||
ADD OBJECT Olecontrol1 AS OleCONTROL WITH ; | ADD OBJECT Olecontrol1 AS OleCONTROL WITH ; | ||
OleCLASS= | OleCLASS="MSCOMMLib.MSComm.1",; | ||
TOP = 12, ; | TOP = 12, ; | ||
LEFT = 12, ; | LEFT = 12, ; | ||
HEIGHT = 100, ; | HEIGHT = 100, ; | ||
WIDTH = 100, ; | WIDTH = 100, ; | ||
NAME = | NAME = "Olecontrol1", ; | ||
NullDiscard = .F., ; | NullDiscard = .F., ; | ||
RThreshold = 10 | RThreshold = 10 | ||
Line 188: | Line 188: | ||
HEIGHT = 27, ; | HEIGHT = 27, ; | ||
WIDTH = 84, ; | WIDTH = 84, ; | ||
CAPTION = | CAPTION = "Open Port", ; | ||
NAME = | NAME = "Command1" | ||
ADD OBJECT Edit1 AS EditBOX WITH ; | ADD OBJECT Edit1 AS EditBOX WITH ; | ||
FONTNAME = | FONTNAME = "Arial", ; | ||
HEIGHT = 64, ; | HEIGHT = 64, ; | ||
LEFT = 24, ; | LEFT = 24, ; | ||
TOP = 72, ; | TOP = 72, ; | ||
WIDTH = 252, ; | WIDTH = 252, ; | ||
NAME = | NAME = "Edit1" | ||
ADD OBJECT Command2 AS CommandBUTTON WITH ; | ADD OBJECT Command2 AS CommandBUTTON WITH ; | ||
TOP = 108, ; | TOP = 108, ; | ||
Line 202: | Line 202: | ||
HEIGHT = 27, ; | HEIGHT = 27, ; | ||
WIDTH = 84, ; | WIDTH = 84, ; | ||
CAPTION = | CAPTION = "Clear Text", ; | ||
NAME = | NAME = "Command2" | ||
ADD OBJECT Command3 AS CommandBUTTON WITH ; | ADD OBJECT Command3 AS CommandBUTTON WITH ; | ||
TOP = 72, ; | TOP = 72, ; | ||
Line 209: | Line 209: | ||
HEIGHT = 27, ; | HEIGHT = 27, ; | ||
WIDTH = 84, ; | WIDTH = 84, ; | ||
CAPTION = | CAPTION = "View Input", ; | ||
ENABLED = .F., ; | ENABLED = .F., ; | ||
NAME = | NAME = "Command3" | ||
ADD OBJECT Command4 AS CommandBUTTON WITH ; | ADD OBJECT Command4 AS CommandBUTTON WITH ; | ||
TOP = 178, ; | TOP = 178, ; | ||
Line 217: | Line 217: | ||
HEIGHT = 27, ; | HEIGHT = 27, ; | ||
WIDTH = 84, ; | WIDTH = 84, ; | ||
CAPTION = | CAPTION = "Exit", ; | ||
NAME = | NAME = "Command4" | ||
PROCEDURE Command1.CLICK | PROCEDURE Command1.CLICK | ||
IF This.CAPTION= | IF This.CAPTION="Open Port" | ||
ThisForm.Olecontrol1.portopen=.T. | ThisForm.Olecontrol1.portopen=.T. | ||
This.CAPTION = | This.CAPTION = "Close Port" | ||
ThisForm.Command3.ENABLED=.T. | ThisForm.Command3.ENABLED=.T. | ||
ELSE | ELSE | ||
ThisForm.Olecontrol1.portopen=.F. | ThisForm.Olecontrol1.portopen=.F. | ||
This.CAPTION = | This.CAPTION = "Open Port" | ||
ThisForm.Command3.ENABLED=.F. | ThisForm.Command3.ENABLED=.F. | ||
ENDIF | ENDIF | ||
Line 233: | Line 233: | ||
PROCEDURE Command2.CLICK | PROCEDURE Command2.CLICK | ||
ThisForm.Edit1.VALUE = | ThisForm.Edit1.VALUE = "" | ||
ENDPROC | ENDPROC | ||
Line 241: | Line 241: | ||
ThisForm.inval2 = ASC(SUBSTR(ThisForm.inval1, i, 1)) | ThisForm.inval2 = ASC(SUBSTR(ThisForm.inval1, i, 1)) | ||
ThisForm.Edit1.VALUE=ThisForm.Edit1.VALUE+; | ThisForm.Edit1.VALUE=ThisForm.Edit1.VALUE+; | ||
" "+ALLTRIM(STR(ThisForm.inval2))+" " | |||
ENDFOR | ENDFOR | ||
ENDPROC | ENDPROC | ||
Line 270: | Line 270: | ||
NOTE: The characters sent by OutForm are displayed in the edit box of InForm. So, the characters are being received and recognized by MS Communication Control on the receiving end.</li> | NOTE: The characters sent by OutForm are displayed in the edit box of InForm. So, the characters are being received and recognized by MS Communication Control on the receiving end.</li> | ||
<li>Click Clear Text to clear the edit box.</li> | <li>Click Clear Text to clear the edit box.</li> | ||
<li>Go back to PC1 and insert a | <li>Go back to PC1 and insert a "0" between the second and third number in the edit box of OutForm so that the entries look like the following: | ||
<div class="indent"> | <div class="indent"> | ||
Line 281: | Line 281: | ||
<li>Switch to PC1 and click View Input. Look at the contents of the edit box.<br /> | <li>Switch to PC1 and click View Input. Look at the contents of the edit box.<br /> | ||
<br /> | <br /> | ||
NOTE: Only the first and the second numbers (15 255), sent by OutForm on PC1, are displayed in the edit box of InForm. The | NOTE: Only the first and the second numbers (15 255), sent by OutForm on PC1, are displayed in the edit box of InForm. The "0" and the numbers following it are not displayed. This illustrates that after a receiving CHR(0) or NULL that the MS Communication Control ignores that particular character and all characters following it.</li></ol> | ||
Revision as of 11:04, 21 July 2020
Article ID: 169502
Article Last Modified on 7/30/1999
APPLIES TO
- Microsoft Visual FoxPro 5.0 Standard Edition
- Microsoft Visual FoxPro 5.0a
This article was previously published under Q169502
SYMPTOMS
When an instance of the Microsoft Communication Control (MSComm Control) receives a CHR(0) it ignores that character and all characters that follow.
RESOLUTION
One of the following suggestions should resolve this problem:
- Set the InputLen property of the Microsoft Communication Control to 1 and read one character at a time.
- If possible, do not send CHR(0) or NULL to the Microsoft Communication control.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This has been corrected in Visual FoxPro 6.0.
MORE INFORMATION
The Microsoft Communication Control truncates all characters following, and including, a CHR(0) or NULL that is passed to its Input. This occurs when the "NullDiscard" of the Microsoft Communication control set to ".F."
Steps to Reproduce Behavior
- Connect two computers via a NULL Modem cable. For example, COM1 port of a computer (PC1) connected to the COM1 port of another computer (PC2) via a Null Modem Cable.
- On PC1, place the following commands into a Visual FoxPro program and then execute it, to create and run a form that sends serial output using the MS Communication Control:
OUTFORM = CreateObject("comtst1") OUTFORM.Show READ EVENTS DEFINE CLASS COMTST1 AS FORM Top = 7 Left = 88 Height = 239 Width = 288 DOCREATE = .T. Caption = "Form1" Name = "Form1" OUTVAL = .F. ADD OBJECT TEXT1 AS TEXTBOX WITH ; HEIGHT = 37, ; LEFT = 29, ; TOP = 84, ; WIDTH = 229, ; Name = "Text1" ADD OBJECT Olecontrol1 AS Olecontrol WITH ; OLECLASS="MSCOMMLib.MSComm.1",; TOP = 12, ; LEFT = 0, ; HEIGHT = 100, ; WIDTH = 100, ; NULLDISCARD = .F., ; Name = "Olecontrol1" ADD OBJECT Command1 AS CommandBUTTON WITH ; TOP = 37, ; LEFT = 104, ; HEIGHT = 27, ; WIDTH = 84, ; CAPTION = "Open Port", ; TABINDEX = 2, ; Name = "Command1" ADD OBJECT Command2 AS CommandBUTTON WITH ; TOP = 133, ; LEFT = 104, ; HEIGHT = 27, ; WIDTH = 84, ; CAPTION = "Send", ; Name = "Command2" ADD OBJECT Command3 AS CommandBUTTON WITH ; TOP = 193, ; LEFT = 104, ; HEIGHT = 27, ; WIDTH = 84, ; CAPTION = "Exit", ; Name = "Command3" PROCEDURE Command1.Click IF This.CAPTION="Open Port" ThisForm.Olecontrol1.PORTOPEN=.T. This.Caption = "Close Port" Else ThisForm.Olecontrol1.PORTOPEN=.F. This.Caption = "Open Port" EndIf ENDPROC PROCEDURE Command2.Click *** Send CHR() representation of numbers entered *** OVAL1 = ALLTRIM(ThisForm.TEXT1.Value) OVAL2 = "chr(" + STRTRAN(OVAL1, " ", ")+chr(") + ")" ThisForm.Olecontrol1.OUTPUT=&OVAL2 ENDPROC PROCEDURE Command3.Click ThisForm.Release CLEAR EVENTS ENDPROC ENDDEFINE
- Switch to PC2 and place the following code into a Visual FoxPro program and execute it to create and run a form that receives serial input using the MS Communication Control:
INFORM = CREATEOBJECT("comtst2") INFORM.SHOW READ EVENTS DEFINE CLASS comtst2 AS FORM Top = 5 Left = 1 Height = 216 Width = 410 DoCreate = .T. Caption = "Form1" Name = "Form1" inval1 = .F. inval2 = .F. ADD OBJECT Olecontrol1 AS OleCONTROL WITH ; OleCLASS="MSCOMMLib.MSComm.1",; TOP = 12, ; LEFT = 12, ; HEIGHT = 100, ; WIDTH = 100, ; NAME = "Olecontrol1", ; NullDiscard = .F., ; RThreshold = 10 ADD OBJECT Command1 AS CommandBUTTON WITH ; TOP = 24, ; LEFT = 150, ; HEIGHT = 27, ; WIDTH = 84, ; CAPTION = "Open Port", ; NAME = "Command1" ADD OBJECT Edit1 AS EditBOX WITH ; FONTNAME = "Arial", ; HEIGHT = 64, ; LEFT = 24, ; TOP = 72, ; WIDTH = 252, ; NAME = "Edit1" ADD OBJECT Command2 AS CommandBUTTON WITH ; TOP = 108, ; LEFT = 298, ; HEIGHT = 27, ; WIDTH = 84, ; CAPTION = "Clear Text", ; NAME = "Command2" ADD OBJECT Command3 AS CommandBUTTON WITH ; TOP = 72, ; LEFT = 298, ; HEIGHT = 27, ; WIDTH = 84, ; CAPTION = "View Input", ; ENABLED = .F., ; NAME = "Command3" ADD OBJECT Command4 AS CommandBUTTON WITH ; TOP = 178, ; LEFT = 150, ; HEIGHT = 27, ; WIDTH = 84, ; CAPTION = "Exit", ; NAME = "Command4" PROCEDURE Command1.CLICK IF This.CAPTION="Open Port" ThisForm.Olecontrol1.portopen=.T. This.CAPTION = "Close Port" ThisForm.Command3.ENABLED=.T. ELSE ThisForm.Olecontrol1.portopen=.F. This.CAPTION = "Open Port" ThisForm.Command3.ENABLED=.F. ENDIF ENDPROC PROCEDURE Command2.CLICK ThisForm.Edit1.VALUE = "" ENDPROC PROCEDURE Command3.CLICK ThisForm.inval1 = ThisForm.Olecontrol1.INPUT FOR i = 1 TO LEN(ThisForm.inval1) ThisForm.inval2 = ASC(SUBSTR(ThisForm.inval1, i, 1)) ThisForm.Edit1.VALUE=ThisForm.Edit1.VALUE+; " "+ALLTRIM(STR(ThisForm.inval2))+" " ENDFOR ENDPROC PROCEDURE Command4.CLICK ThisForm.RELEASE CLEAR EVENTS ENDPROC ENDDEFINE
- Click Open Port on the InForm form on PC2 to open the communication port on that computer.
- Switch to PC1 and click Open Port on the OutForm form on PC1 to open the communication port on that computer.
- Select the edit box on OutForm and enter the following numbers into the first line:
15 255 13 10 25
- Click SEND on OutForm to send the numbers.
- Switch to PC2 and click View Input on InForm. Look at the contents of the edit box.
NOTE: The characters sent by OutForm are displayed in the edit box of InForm. So, the characters are being received and recognized by MS Communication Control on the receiving end. - Click Clear Text to clear the edit box.
- Go back to PC1 and insert a "0" between the second and third number in the edit box of OutForm so that the entries look like the following:
15 255 0 13 10 25
- Click SEND on OutForm to send the numbers.
- Switch to PC1 and click View Input. Look at the contents of the edit box.
NOTE: Only the first and the second numbers (15 255), sent by OutForm on PC1, are displayed in the edit box of InForm. The "0" and the numbers following it are not displayed. This illustrates that after a receiving CHR(0) or NULL that the MS Communication Control ignores that particular character and all characters following it.
Keywords: kbbug kbfix kbinterop kbcode KB169502