General information
Category:
Coding, syntax & commands
Snipped a bit. Comments inline.
>I ended up implementing it by just dropping the ActiveX control on a form. I didn't use vfpcom/bindevents. Here is what the code looks like in my oncomm event:
>
>*** ActiveX Control Event ***
>
>***section one - this works
>thisform.fpc_ScanData=this.input
>if chr(13) $ thisform.fpc_Scandata
> thisform.fpc_ScanData=substr(thisform.fpc_scandata, 1, len(thisform.fpc_scandata)-1)
>else
> *wait wind 'there was no chr(13)'
>endif
>this.parent.txtbarcodedata.value=thisform.fpc_ScanData
>this.parent.txtbarcodedata.refresh()
>oBCinput.ProcessBCInputData(thisform.fpc_ScanData)
>go bottom in messagequeue
>go bottom in curtasksstarted
>go bottom in taskscompleted
>this.parent.txtbarcodedata.value=''
>thisform.refresh()
>***end section one
>
>*** section two - this did not work
>if .f.
>local lcNextChar
>lcNextChar = this.input
>
*** Problem right here. What if there is more than 1 character in this.input???
Try:
IF chr(13)&lcNextChar vs.
>if lcNextChar=chr(13)
Any time you do your this.input, the entire buffer is read. If RThreshold=1, there should only be 1 character in this.input. I would NOT bet my life on that being the case. I would rather take a look at
.inbuffercount and test how many characters are really in the buffer before reading with this.input. Just my personal preference.
> this.parent.txtbarcodedata.value=thisform.fpc_ScanData
> this.parent.txtbarcodedata.refresh()
> oBCinput.ProcessBCInputData(thisform.fpc_ScanData)
> go bottom in messagequeue
> go bottom in curtasksstarted
> go bottom in taskscompleted
> thisform.refresh()
>else
> thisform.fpc_ScanData=thisform.fpc_ScanData+lcNextChar
>endif
>
>endif
>****************
>Please note the following about the code above:
>
>1)The code I originally wrote is in 'section two' (now commented out with if .f.). This code didn't work. Before I tested, I was under the impression that the oncomm event would fire each time a character was added to the input buffer, and that therefore I could build the string one character at a time, until I received a chr(13). But it turned out that the oncomm event only fired once, and stored my whole string to the input buffer.
>
>Note that I don't have the doevents statement anywhere in here. Do I need it?
Maybe. Put one in and check the result :>)
>
>2) So, I recoded it as per 'section one', where I store this.input only once. But please note that I also have the following code:
>if chr(13) $ thisform.fpc_Scandata
> thisform.fpc_ScanData=substr(thisform.fpc_scandata, 1, len(thisform.fpc_scandata)-1)
>else
> *wait wind 'there was no chr(13)'
>endif
>
>I put in this code to account for a behaviour that doesn't make sense to me. When the form is active (the cursor is in the txtbarcodedata text box, which is a read only textbox), i.e., the form has the focus, a chr(13) is stored to the input string. But, oddly, if the form is minimized, and/or the vfp application itself is minimized, the chr(13) doesn't get stored to the input string.
>
How are you calling the form? From a startup.prg or ?
If from a prg, try:
SET DELETED ON
SET EXCLUSIVE OFF
ON SHUTDOWN QUIT
DO FORM yourcommform
READ EVENTS
CLEAR ALL
RELEASE ALL
or something similar. With your form set as a top level, this will work fine maximized or minimized and events will fire fine. With no DOEVENTS.
>One of the main reasons I wanted to go this route, was so that I could have an application that didn't rely on the cursor being in a textbox.
>
>I don't understand why the state of the form should have any relationship whatsoever to what is stored to the input buffer.
>
>I must be missing something here!
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only