0
votes

My requirement is to develop an application in power builder, which receives Scanned barcodes and decodes it

The application should also be able to reveal hidden ASCII codes in the scanned barcodes. Like:-

ASCII Codes TAB - 9 BS Backspace - 8 EOT End of Transmission - 4 FF Form Feed - 12

Etc.

When scanned codes arrives at datawindow, rich text input, single line edit it comes as one character at a time So my logic would be is to take that character before it is written in Datawindow or rich text input and find its ascii value and if it is less the 32 (which means it is a hidden character) I can give brackets around it and show in display screen. so that hidden characters are not missed out.

Eg Scanned code abcdefgh

Decoded code will be abc[09]def[12]gh

So I tried with EditChanged, itemchanged , KeyDown events but I am unable to get the character before it is written in datawindow. Because once it is been written in datawindow hidden characters will be missed out.

Is there any event in powerbuilder will give me the scannedcode after it has been scanned but before it has been written in data window or rich text control, Something like PreviewTextInput Event, which will preview the text before writing it into the data window.

Sample barcode Image uploaded

Thanks and regards,

1

1 Answers

1
votes

The Event ID pbm_dwnchanging might work for you. Try creating an event on the DataWindow control that uses pbm_dwnchanging - this appears to capture the characters as they're being entered, but before they're put into the edit control (like you would think pbm_dwnkey should).

// "prototype" in the window object's datawindow control declaration:
event onpbmdwnchanging pbm_dwnchanging

Here is the pbm_dwnchanging event extension's code - basically, it calls a method that builds the "representation" of the data being entered and logs it (i.e.: appends a Multi-line Edit control in the window).

event onpbmdwnchanging;

string dataRepresentation
// get the representation of the data
dataRepresentation = getDataRepresentation(data)

// log it to the window's MLE
addLogMessage("onpbmdwnchanging - row: " + string(row) + " data: '" + 
dataRepresentation + "'")

return
end event

Lastly, the function that builds the "representation" of the data:

protected function string getDataRepresentation (string as_input);
string dataRep
char dataChars[]
string currentChar
long ll_datalength, ll_index

dataChars = as_input  // cast the string into a character array

ll_datalength = upperbound(dataChars)
for ll_index = 1 to ll_datalength
    currentChar = dataChars[ll_index]
    if Asc(currentChar) < 32 then
        // "hidden" character
        dataRep += "[" + string(Asc(currentChar)) + "]"
    else
        dataRep += string(currentChar)
    end if
next

return dataRep

end function

note: tested and works in PB 12.6