How can I show the data with comma(,) in drop down box on window? - openedge

I have written the program to show all the data on window but stuck in the case for showi a single record with comma(,) in drop down box. Let me share codes what i tried.
DEFINE TEMP-TABLE tt_seq_report
FIELD npai_output_expression AS CHARACTER FORMAT "X(50)".
/* Followings are written inside the drop down box using progress app builder */
/* ON VALUE CHANGED OF coCombo-4 Part Type(Label Name) */
DO:
DEFINE VARIABLE cPartTyp AS CHARACTER NO-UNDO.
CREATE tt_seq_report.
ASSIGN
tt_seq_report.npai_attribute_expression = "22+++,56-".
coCombo-4:ADD-LAST(tt_seq_report.npai_attribute_expression).
END.
When I run the window and select the drop down box then i can see the value upto before comma(,) i.e 22+++ but it should show the full value like 22+++,56-. May I get any help regarding this?

You can set the combo-box'es DELIMITER property to any other character. Comma is just a default.
"Delimiter character can have any ASCII value from 1 to 127. The default delimiter is a comma."

Related

How do you let user input a lengthy string into a variable?

How do you let user input a lengthy string into a variable?
I know this is trivial but I haven't been able to achieve it yet.
Here is what I've tried :
DEF VAR filter AS CHAR NO-UNDO.
UPDATE filter.
The value was always truncated to only a few characters. So, I've tried adding a format like so.
UPDATE filter FORMAT "X(318)":U.
Which give error
FILL-IN filter will not fit in FRAME
This program is only used by power user, so it doesn't have a frame to make thing pretty.
The basic console is all that is needed.
318 characters would have been better than nothing, but it would still not be ideal because user may copy-paste a longer string. Note that user wouldn't not paste any string that exceed 32000 characters.
Here is what the user input would looks like.
value1,value2,value3,value4,value5,value6,value7,value8,value9,value10,value11
I occasionally use something along these lines:
/* editlong.p
*
*/
define variable longText as character no-undo format "x(1000)"
view-as fill-in size 40 by 1
label "Long Text"
.
update longText "...".
The format "x(1000)" could just as easily be format "x(32000)". But whatever it is, it will be the hard limit on what someone can enter.
You could also do multi-line entry like this:
define variable longText as character no-undo format "x(1000)"
view-as editor inner-chars 30 inner-lines 5
large no-word-wrap
label "Long Text"
.
update longText "...".

How to pass a temp-table to a window from a procedure file

I'm using a window(.w) that has a button that passes a variable to a procedure(.p), does its magic and then needs to return the results in a temp-table back to the window for display.
The .w file
Definitions
DEFINE TEMP-TABLE Return_Results
FIELD tt_var1Return AS CHARACTER FORMAT "x(20)"
FIELD tt_var2Return AS CHARACTER FORMAT "x(30)"
FIELD tt_var3Return AS CHARACTER FORMAT "x(30)"
FIELD tt_var4Return AS CHARACTER FORMAT "x(30)"
.
Button code
ON CHOOSE OF RecordFinder IN FRAME Dialog-Frame
DO:
DEFINE VARIABLE varInput AS CHARACTER NO-UNDO
DEFINE VARIABLE Return_Results REFERENCE-ONLY. /* <--- I'm pretty sure this is the problem */
varInput = Fill-In:SCREEN-VALUE.
RUN RecordFinder.p(INPUT varInput, OUTPUT Return_Results).
FOR EACH Return_Results:
Display Return_Results.
END.
END.
The .p file
i'm omitting some stuff that i think may not be necessary, but it basically takes the input variable, matches it and generates a temp-table from the results and assign those records to a new temp-table that will get passed back.
Definitions
DEFINE INPUT PARAMETER windowInput AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER Results_Output
DEFINE TEMP-TABLE Original_tt
FIELD tt_var1Original AS CHARACTER FORMAT "x(20)"
FIELD tt_var2Origianl AS CHARACTER FORMAT "x(30)"
FIELD tt_var3Original AS CHARACTER FORMAT "x(30)"
FIELD tt_var4Original AS CHARACTER FORMAT "x(30)"
.
DEFINE TEMP-TABLE Return_tt
FIELD tt_var1Return AS CHARACTER FORMAT "x(20)"
FIELD tt_var2Return AS CHARACTER FORMAT "x(30)"
FIELD tt_var3Return AS CHARACTER FORMAT "x(30)"
FIELD tt_var4Return AS CHARACTER FORMAT "x(30)"
.
*additional code that works*
The next bit of code is for sorting the result of the temp table where it matches the input variable
FOR EACH Original_tt WHERE Original_tt.Var1 = windowInput:
CREATE Return_tt.
BUFFER-COPY Original_tt TO Results_tt
Return_tt.tt_var1Return = Original_tt.tt_var1Original.
Return_tt.tt_var2Return = Original_tt.tt_var2Original.
Return_tt.tt_var3Return = Original_tt.tt_var3Original.
Return_tt.tt_var4Return = Original_tt.tt_var4Original.
/* This is where I know I'm wrong */
/* I figured you could assign the Return_tt to the output variable */
Results_Output = Return_tt.
END.
I hope this not too convoluted.
The doc at https://docs.progress.com/bundle/abl-reference/page/Parameter-passing-syntax.html has detail on the parameter passing syntax (though no decent example).
In the called program (.p) you need to define the parameters
DEFINE INPUT PARAMETER windowInput AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER TABLE FOR Return_tt.
In the caller (.w), you say the following
RUN RecordFinder.p(INPUT varInput, OUTPUT TABLE Return_Results).
Now you have the data in your caller.
It's a deep copy (so the .W gets its very own copy in memory). This may cause you performance problems (since a copy must be made), although there are reasons for making deep copies too.
You can turn the deep (by value) call into a shallow (by reference) call quite easily.
RUN RecordFinder.p(INPUT varInput, OUTPUT TABLE Return_Results BY-REFERENCE).
Some further doc at https://docs.progress.com/bundle/develop-abl/page/Passing-a-temp-table-by-reference.html . You don't need to define the temp-table as REFERENCE-ONLY in the caller.

How to converts a character to decimal on progress 4GL?

DEFINE VARIABLE cDateTime AS CHARACTER NO-UNDO.
DEFINE TEMP-TABLE tt_data NO-UNDO
FIELD DateTime AS DECIMAL FORMAT "->>,>>9.99".
ASSIGN
cDateTime = "20191604121566".
CREATE tt_data.
ASSIGN
tt_data.DateTime = DECIMAL(cDateTime) /* Message Date and Time */
But it says:
"Value cannot be displayed using ->>>,>>>,>>9.999999".
Could you please help this case and tell me what is wrong here?
The code that you show does not result in the error that you are reporting.
I'm guessing that you have a DISPLAY statement somewhere in your real code.
The reported error simply means that that DISPLAY format is not wide enough for the data. By default DISPLAY will use whatever format you specified in the definition of a data element. If you did not specify anything then every datatype also has a default. For decimals the default is "->>,>>>.99".
You can either increase the format in the definition or override it in the display statement like so:
display tt_data.DateTime format ">>>>>>>>>>>>>>>9".
Note: the display format has no influence on the values that you can store in a field. You can always "overstuff" more data into a variable than you can display. The format is only for output display purposes -- it has nothing to do with storage.
The assignment works fine, however the display not.
So ...
DISPLAY tt_data.DateTime.
... does not work because it uses format "->>,>>9.99".
You can change the format in the definition, for example "99999999999999", or do:
DISPLAY tt_data.DateTime FORMAT "99999999999999".

How to format Credit card text edit widget?

I am trying to make a custom format for my credit card widget. The first 4 numbers should be followed by a dash '-', then after 3 numbers, another dash and then 2 more numbers.
Example: 1234-678-52.
How can I custom format a text edit so that it has '-' already present and follows the format described above?
The built-in date widget has something similar: having '/' as a delimiter.
If you are using QLineEdit the option is to use the inputMask property:
your_qlineedit->setInputMask("999-9999-99");
You can use three input fields. Place them in one line, draw the '-' in between and add the input masks and some logic.
Input masks: 999, 9999, 99
Logic 1: Go to next input field as soon the input is accepted
Logic 2: Go to previous field as soon all characters are deleted (optional)
The user should now be able to type in the whole number without pressing TAB or '-'.

Progress ABL - strip and add to temp table

I'm coming from a Java/.NET background and trying to learn ABL but the difference in structure and the limited information on the internet is making it hard. What I want to do is import data from a text file which is in the following format:
john smith 52 ceo
...
line by line, and take the different parts based on the position of the character. For example, positions 1-10 are for the first name, 10-20 second name and so on... Do I have to use entry for that? If so can someone more experienced give an example how to do it cause I'm quite confused. Then I need to add a record for each line to a temp-table I have created called tt-employee. How do I go about doing that?
I apologise if my question is a bit vague but as I said, I am new to this so I'm still figuring things out.
If space is a delimiter you can use the IMPORT statement.
DEFINE TEMP-TABLE tt-employee NO-UNDO
FIELD firstname AS CHARACTER
FIELD lastname AS CHARACTER
FIELD age AS INTEGER
FIELD empTitle AS CHARACTER.
INPUT FROM c:\temp\indata.dat.
REPEAT:
CREATE tt-employee.
IMPORT DELIMITER " " tt-employee.
END.
INPUT CLOSE.
However if there isn't a delimiter but rather a fixed record with (as you mention) you can do something like this (error checking and correct record lengths needs to be applied).
/* Skipping temp-table definition - copy-paste from above */
DEFINE VARIABLE cRow AS CHARACTER NO-UNDO.
INPUT FROM c:\temp\indata.dat.
REPEAT:
IMPORT UNFORMATTED cRow.
/* You could replace 0 with a higher number that qualifies a record so
SUBSTRING doesn't return an error if reading past end of line */
IF LENGTH(cRow) > 0 THEN DO:
CREATE tt-employee.
ASSIGN
tt-employee.firstname = SUBSTRING(cRow, 1, 10)
tt-employee.lastname = SUBSTRING(cRow, 11, 10)
tt-employee.age = INTEGER(SUBSTRING(cRow, 21, 2))
tt-employee.empTitle = SUBSTRING(cRow, 23, 10) NO-ERROR.
END.
END.
INPUT CLOSE.
There are several places on the web to look for OpenEdge information:
Official knowledgebase - http://knowledgebase.progress.com/
Official community - https://community.progress.com/?Redirected=true
More communities - http://www.progresstalk.com/ and http://oehive.org/

Resources