Barcode content to be scanned in 2 seperate fields - barcode

I have put 2 fields into a barcode and an additional delimiter also. The barcode content will be for example 123456789|abcdefg where pipe is the delimiter.
Now i have to sacn this barcode once and then make the first part appear in one field and 2nd part ie whatever is after the | in the seconf field in progress 4gl? How can i do it??

You can create the first field formatted as it can handle all the code. Then, into the RETURN event of the field (assuming that you using an SmartWindow and your barcode reader do a CR/LF at the end of barcode reading) you use the content of the first field and split it into two fields. Something like this :
DEF VAR cField1 AS CHAR NO-UNDO FORMAT 'x(50)'.
DEF VAR cField2 AS CHAR NO-UNDO FORMAT 'x(50)'.
UPDATE cField1 WITH WIDTH 333. /* Here you 'bip' your barcode */
ASSIGN cField2 = ENTRY(2,cField1,'|')
cField1 = ENTRY(1,cField1,'|').
DISP cField1 cField2.
Hope it helps.

Related

Adding leading Zeros into Day and Month Value

I have a simple table that has a column with a date in this format:
MM/DD/YYYY.
Unfortunately, there are some folks who are working without leading zeros.
Therefore I would like to add a leading zero into the Month and Day element using Power Query to have a common format.
But how? Does someone have any function to share?
Again, not sure why you want to do this, but
Assuming all of the entries are text that looks like dates, you can use the following M-Code:
Split the string on the delimiter
Change each entry in the list to a number
Add 2000 to the last number
Change the numbers back to text with a "00" format
Recombine with the delimiter
let
Source = Excel.CurrentWorkbook(){[Name="Table29"]}[Content],
//set type = Text
#"Changed Type" = Table.TransformColumnTypes(Source,{{"TextDate", type text}}),
xform = Table.TransformColumns(#"Changed Type",
{"TextDate", each
let
x = Text.Split(_,"/"),
y = List.Transform(x,each Number.From(_)),
z = List.ReplaceRange(y,2,1, {2000+y{2}}),
a= List.Transform(z,each Number.ToText(_,"00")),
b = Text.Combine(a,"/")
in b})
in
xform
I am thinking a better solution might be to set up your data entry method so that all dates are entered as dates rather than text

golang screen printing formatted data with color attributes

Want to print a row/column table that is formatted as in a typical
fmt.Printf("%5s %5s %5s\n",col1, col2, col3)
Works fine of course if the strings are plain text, but if a string has display attributes
like color, bold, font - even though the visible data is the same length as the plain text,
and would be fine in %5s; doing len(col1) is much longer it skews the table alignment.
Is there a way for Printf to accomplish this, or another std Go package?
Want:
Item Item Item
===== ===== ====
abc defgh xyz
x abc d
vv xxxxx zz <=== this happens if string xxxxx has display attributes from
fatih,gchalk, etc. to set foreground/background color
`
//
package main
import (
"fmt"
"github.com/jwalton/gchalk"
"github.com/fatih/color"
)
func main() {
var colorWithGchalk = gchalk.Red
var data = []string{"one", "ten", "twenty"}
gchalk.SetLevel(gchalk.LevelAnsi16m) // seems needed for gitbash
// note output columns framed by <> just to see actual width
fmt.Println("desired formatted output")
fmt.Printf("<%-10s> <%-10s> <%-10s>\n\n", data[0],data[1],data[2])
/*
** gchalk
*/
// first try using gchalk for color
// colorize second column - column width ignored?
fmt.Println("colorized field loses its 10 character width, so subsequent fields now misaligned")
fmt.Printf("<%-10s> <%-10s> <%-10s>\n", data[0], colorWithGchalk(data[1]), data[2])
// same as above but eliminate gchalk function and just apply colorizing directly - same result
fmt.Printf("<%-10s> <%-10s> <%-10s>\n", data[0], gchalk.Red(data[1]), data[2])
/*
** fatih
*/
fmt.Println("\nwith fatih")
var colorWithFatih = color.New(color.FgRed).SprintFunc()
fmt.Printf("<%-10s> <%-10s> <%-10s>\n", data[0], colorWithFatih(data[1]), data[2])
}
`
Output:
`
desired formatted output
colorized field loses its 10 character width,
so subsequent fields now misaligned
with fatih
`
On screen the above 3 lines display the word "ten" in red as desired, but the field is no longer 10 wide.
Is there a way for Printf to accomplish this,
No
or another std Go package?
No
(What you call "display attributes" are part of the output stream of bytes, they are not "attributes", this is "inline data" interpreted by the terminal emulator. What you can do is filter out this inline data before printing.)
You could use https://github.com/olekukonko/tablewriter as an example for how to output tables or just use the package.
With the advice of Jason Walton the porter of chalk to gchalk. I got fmt.Printf %s to satisfy my need, although their may be issues if the field widths (%s) were narrow.
I wanted to concatenate at least two strings together to provide to one %s.
The first string was plain text (sgCharToPrint) the next string was colorized so it was the actual screen text (missedRaw) (missed was the color string e.g. missedRaw wrapped with ansi formatting characters.
myLen = len(sgCharToPrint) + len(missedRaw)
padded = sgCharToPrint + missed + strings.Repeat(" ", 30 - olen)
fmt.Printf("%30s %4d %10s \n",padded, value, tail)
Now the "table" display stays in alignment.

JDBC Import into sheets, how to keep leading zeros on fields?

I have so much trouble with leading zeros in general. Importing into Sheets using JDBC connection, I haven't figured out a way to keep the zeros. The column types are varchar() for values of varied length, and char() for static length.
In the past with other data I have added a leading ' to values, or chosen to getDisplayValue() to keep them. What would work here?
while (results.next()){
var tmpArr = [];
var rowString = '';
for (var col = 0; col < numCols; col++) {
rowString += results.getString(col + 1) + '\t';
tmpArr.push(results.getString(col + 1));
}
valArr.push(tmpArr);
}
sheet.getRange(3, 1 , valArr.length, numCols).setValues(valArr);
Data Exmaple varchar column:
0110205361
0201206352
140875852
LFCP01367
LGLM00017
You are retrieving data into a Google Sheet from a MySQL database table using Jdbc. One of the database columns is formatted as "varchar" and includes some all-numeric values that have one or more leading zeros. When you update the database values to your Google Sheet, the leading zeros are not displayed.
Why
The reason for this is that the all-numeric values are displayed without the leading zeros is that the cells are formatted as Number, Automatic (or otherwise as a number). This means that they are 'interpreted' by Google Sheets as a number and, by default, all leading zeros are dropped.
On the other hand, if the cells are formatted as Number, Plain Text, then the all-numeric values are 'interpreted' as strings, and any leading zeros are retained.
The effect of formatting can be clearly seen in the following images, which also include istext and isnumber formula to confirm how they are interpreted under each format type.
Formatted as Number - Plain Text - treated as strings
Formatted as Number - Automatic - treated as numbers
Formatting on the fly
An alternative to pre-formatting (which wasn't successful in the OP's case) is to set the format as a part of the setValues() method using setNumberFormat
For example:
sheet.getRange(3, 1 , valArr.length, numCols).setNumberFormat('#STRING#').setValues(valArr);
There is a useful discussion of this methid in Format a Google Sheets cell in plaintext via Apps Script

padding the middle of a string

I have a Textbox field that takes in a string with a character limit of 10. I would like to implement a short hand version because there are a lot of zeros in the string that have to be entered. so an example of the string is T000028999. but id like to key in T28999 and have the zeros padded between the "T" and the "28999" and show up as the T000028999 string in the Textbox field.
Is this even possible?
I've tried searching examples on google and have only found ways to pad the beginning and end of the string.
You want to keep the first character, so you can use oldString.Chars(0) to get that.
You want the remainder of the string: oldString.Substring(1), and you can pad it to the width you require with a character of your choice with PadLeft, like this:
Dim newString = oldString.Chars(0) & oldString.Substring(1).PadLeft(9, "0"c)
It would be a good idea to check that oldString is at least 1 character long before doing that otherwise the .Chars(0) will give an error.
Alternatively you could insert a new string of the required quantity of "0"s:
Dim newString = oldString.Insert(1, New String("0"c, 10 - oldString.Length))
A good place to perform the formatting would be in the control's Validating event handler. (The TextChanged event handler would not be a good place because it would interfere with the user's typing.)
Refs:
String.Chars[Int32] Property
String.Substring Method
String.PadLeft Method
String.Insert(Int32, String) Method
String Constructors

How to split input by ASCII control codes with Progress 4GL?

how can I split this barcode by group separator with Progress? I've tried chr(29) without any luck.
Barcode scanned into Notepad++: http://i.imgur.com/8DmPZ.png
Barcode scanned into input field: 2409271405202120330017100282
Thanks.
def var c as char no-undo.
def var i as int no-undo.
update c format "x(50)".
do i = 1 to length(c):
message substr(c, i, 1) = chr(29).
end.
The problem is that GS is an undefined control code. So you need to make it be recognized.
Add the following to your terminal's entry in protermcap to define GS as F13:
:(F13)=\035:\
(The octal code for GS is \035 and F13 is an undefined function key -- so the combination should work. I don't have a scanner to test with but this works for the control codes that I can type into my keyboard...)
Then use code like this:
define variable bc as character no-undo format "X(50)".
update bc editing:
if lastkey = 313 then
apply ".". /* 313 is the code for F13 */
else
apply lastkey.
end.
This should cause "." to be inserted instead of GS. Which will allow you to parse the string using "." rather than GS.
It's a wild guess, but I'm thinking ENTRY(entry-num, barcode-string, "group-separator-string")?
This works for me:
/* create a test file (otherwise not needed...)
*/
output to "barcode.dat".
put control "240927140520" chr(29) "2120330017" chr(29) "100282".
output close.
/* if you already have barcode.dat start here
*/
define variable m as memptr no-undo.
define variable bc as character no-undo.
set-size( m ) = 100.
input from "barcode.dat" binary no-convert.
import unformatted m.
input close.
bc = get-string( m, 1 ).
display
entry( 1, bc, chr(29)) format "x(12)" skip
entry( 2, bc, chr(29)) format "x(12)" skip
entry( 3, bc, chr(29)) format "x(12)" skip
.

Resources