Creating a check box dynamically - openedge

Can we create a checkbox dynamically on a window in progress? Actually i have created combo-box,frame,fill-in dynamically but not getting the idea how can I Create checkbox dynamically.

display "Example" skip(2) with frame a width 80.
define variable h as handle no-undo.
create toggle-box h assign
row = 2
column = 1
label = "hi there"
frame = frame a:handle
sensitive = true
visible = true
.
wait-for window-close of current-window.

Related

How add only required fields from table to dynamic temp table? - PROGRESS 4GL

I am new to progress 4gl and below is the query used to add all fields from a table to dynamic temp table except few fields but I am not sure how to add only required fields to dynamic temp table. Please help to modify the query I shared.
/* p-ttdyn2.p - a join of 2 tables */
DEFINE VARIABLE tth4 AS HANDLE.
DEFINE VARIABLE btth4 AS HANDLE.
DEFINE VARIABLE qh4 AS HANDLE.
DEFINE VARIABLE bCust AS HANDLE.
DEFINE VARIABLE bOrder AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE fldh AS HANDLE EXTENT 15.
bCust = BUFFER customer:HANDLE.
bOrder = BUFFER order:HANDLE.
CREATE TEMP-TABLE tth4.
tth4:ADD-FIELDS-FROM(bCust,"address,address2,phone,city,comments").
tth4:ADD-FIELDS-FROM(bOrder,"cust-num,carrier,instructions,PO,terms").
tth4:TEMP-TABLE-PREPARE("CustOrdJoinTT").
btth4 = tth4:DEFAULT-BUFFER-HANDLE.
FOR EACH customer WHERE cust.cust-num < 6, EACH order OF customer:
btth4:BUFFER-CREATE.
btth4:BUFFER-COPY(bCust).
btth4:BUFFER-COPY(bOrder).
END.
/* Create Query */
CREATE QUERY qh4.
qh4:SET-BUFFERS(btth4).
qh4:QUERY-PREPARE("for each CustOrdJoinTT").
qh4:QUERY-OPEN.
REPEAT WITH FRAME zz DOWN:
qh4:GET-NEXT.
IF qh4:QUERY-OFF-END THEN LEAVE.
REPEAT i = 1 TO 15:
fldh[i] = btth4:BUFFER-FIELD(i).
DISPLAY fldh[i]:NAME FORMAT "x(15)"
fldh[i]:BUFFER-VALUE FORMAT "x(20)".
END.
END.
btth4:BUFFER-RELEASE.
DELETE OBJECT tth4.
DELETE OBJECT qh4.
ADD-FIELDS-FROM only supports excluding fields that are not needed. Instead you can use ADD-LIKE-FIELD multiple times:
CREATE TEMP-TABLE tth4.
tth4:ADD-LIKE-FIELD("address", "customer.address").
tth4:ADD-LIKE-FIELD("address2", "customer.address2").
tth4:ADD-LIKE-FIELD("phone", customer.phone").
...
tth4:ADD-LIKE-FIELD("cust-num", "Order.cust-num").
...
tth4:TEMP-TABLE-PREPARE("CustOrdJoinTT").
btth4 = tth4:DEFAULT-BUFFER-HANDLE.
Depending on your use case, you can also invert the required field list to an except field list:
var handle ht,hb.
var longchar lcjson.
function invertFields returns character (
i_hb as handle,
i_crequired as char
):
var char cexcept,cfield.
var int ic.
do ic = 1 to i_hb:num-fields:
cfield = i_hb:buffer-field( ic ):name.
if lookup( cfield, i_crequired ) = 0 then
cexcept = cexcept + ',' + cfield.
end.
return substring( cexcept, 2 ).
end function.
create temp-table ht.
ht:add-fields-from(
buffer customer:handle,
invertFields( buffer customer:handle, "CustNum,Name" )
).
ht:temp-table-prepare( 'tt' ).
hb = ht:default-buffer-handle.
hb:buffer-create().
assign
hb::CustNum = 1
hb::Name = 'test'
.
hb:write-json( 'longchar', lcjson, true ).
message string( lcjson ).
https://abldojo.services.progress.com/?shareId=624993253fb02369b25437c4

Display dynamic number of fields

I'm new to progress and I'm trying to learn dynamic queries. As a Task I gave to myself I want to read a csv file and create a table based on the contents of said file. So far everything works but I can't really seem to find a way to display the contents properly.
I have a temp-table created based on a csv input with the first line being the columns or fields of the table and everything after being the records.
Field1,Field2,Field3,Field4,Fieldn...
Value1.1,Value2.1,Value3.1,Value4.1,Valuen.1...
Value1.2,Value2.2,Value3.2,Value4.2,Valuen.1...
Value1.3,Value2.3,Value3.3,Value4.3,Valuen.1...
Value1.4,Value2.4,Value3.4,Value4.4,Valuen.1...
etc...
How can I display a dynamic number of fields and their names properly?
The following things are unknown:
Number of fields
Name of fields
Values of records
The following works and shows the data in the desired format (but it's hard coded):
DO WHILE qMyTable:GET-NEXT():
DISPLAY
bMyTable:BUFFER-FIELD(1):BUFFER-VALUE LABEL 'PK'
bMyTable:BUFFER-FIELD(2):BUFFER-VALUE LABEL 'Field1'
bMyTable:BUFFER-FIELD(3):BUFFER-VALUE LABEL 'Field2'
bMyTable:BUFFER-FIELD(4):BUFFER-VALUE LABEL 'Field3'
bMyTable:BUFFER-FIELD(5):BUFFER-VALUE LABEL 'Field4'
WITH FRAME f DOWN.
DOWN WITH FRAME f.
END.
I'm trying to loop over the buffer fields but I can't find a way to do it without redefining the DISPLAY command every iteration. Also I don't know how to display the labels of the fields in as a header row.
I'm looking for something like this :
/*
This doesn't work
*/
DO WHILE qMyTable:GET-NEXT():
DO i = 1 to iNumFields:
DISPLAY bMyTable:BUFFER-FIELD(i):BUFFER-VALUE LABEL cTitlerow[i].
END.
END.
This would be the full code:
/*
Variables
*/
DEF VAR i AS INTEGER INITIAL 0 NO-UNDO. //Counter
DEF VAR iEntry AS INTEGER INITIAL 0 NO-UNDO. //Counter2
DEF VAR cTitleRow AS CHARACTER NO-UNDO. //Fields csv
DEF VAR cDataRow AS CHARACTER NO-UNDO. //Entries csv
DEF VAR cFieldName AS CHARACTER NO-UNDO. //Field
DEF VAR iNumFields AS INTEGER NO-UNDO. //Amount of Fields
DEF VAR iNumLines AS INTEGER NO-UNDO. //Amount of records
DEF VAR cTitleArray AS CHARACTER EXTENT NO-UNDO. //Fields Array
/*
Handles
*/
DEF VAR ttMyTable AS HANDLE NO-UNDO. //Temp table
DEF VAR bMyTable AS HANDLE NO-UNDO. //Buffer
DEF VAR qMyTable AS HANDLE NO-UNDO. //Query
INPUT FROM 'C:\Path\To\CSV\mycsv.csv'.
/*
Get first row for fields and field names
*/
IMPORT UNFORMATTED cTitleRow.
iNumFields = NUM-ENTRIES(cTitleRow) + 1. //Additional field for PK
EXTENT(cTitleArray) = iNumFields.
/*
Dynamic table creation
*/
CREATE TEMP-TABLE ttMyTable.
ttMyTable:ADD-NEW-FIELD('PK', 'integer').
cTitleArray[1] = 'PK'.
DO i = 2 to iNumFields:
iEntry = i - 1.
cFieldName = ENTRY(iEntry,cTitleRow).
ttMyTable:ADD-NEW-FIELD(cFieldName, 'character').
cTitleArray[i] = cFieldName.
END.
/*
Adding and defining indexes
*/
ttMyTable:ADD-NEW-INDEX('idx', TRUE, TRUE).
ttMyTable:ADD-INDEX-FIELD('idx', 'PK', 'asc').
ttMyTable:TEMP-TABLE-PREPARE('myTable').
/*
Creating buffer
*/
bMyTable = ttMyTable:DEFAULT-BUFFER-HANDLE.
/*
Populating data
*/
REPEAT:
IMPORT UNFORMATTED cDataRow.
bMyTable:BUFFER-CREATE.
bMyTable::pk = iNumLines.
DO i = 2 to iNumFields:
iEntry = i - 1.
bMyTable:BUFFER-FIELD(i):BUFFER-VALUE = ENTRY(iEntry,cDataRow).
bMyTable:BUFFER-FIELD(i):COLUMN-LABEL = cTitleArray[i].
bMyTable:BUFFER-FIELD(i):LABEL = cTitleArray[i].
END.
iNumLines = iNumLines + 1.
END.
/*
Creating query
*/
CREATE QUERY qMyTable.
qMyTable:SET-BUFFERS(bMyTable).
qMyTable:QUERY-PREPARE('for each myTable').
qMyTable:QUERY-OPEN().
/*
/*
This doesn't work
*/
DO WHILE qMyTable:GET-NEXT():
DO i = 1 to iNumFields:
DISPLAY bMyTable:BUFFER-FIELD(i):BUFFER-VALUE.
END.
END.
*/
DO WHILE qMyTable:GET-NEXT():
DISPLAY
bMyTable:BUFFER-FIELD(1):BUFFER-VALUE LABEL 'PK'
bMyTable:BUFFER-FIELD(2):BUFFER-VALUE LABEL 'Field1'
bMyTable:BUFFER-FIELD(3):BUFFER-VALUE LABEL 'Field2'
bMyTable:BUFFER-FIELD(4):BUFFER-VALUE LABEL 'Field3'
bMyTable:BUFFER-FIELD(5):BUFFER-VALUE LABEL 'Field4'
WITH FRAME f DOWN.
DOWN WITH FRAME f.
END.
qMyTable:QUERY-CLOSE().
DELETE OBJECT qMyTable.
I think you only might have some frame issues. Your code should basically work.
This minor change with display your data but for it will display them all in one column.
DO WHILE qMyTable:GET-NEXT():
DO i = 1 to iNumFields:
DISPLAY bMyTable:BUFFER-FIELD(i):BUFFER-VALUE WITH FRAME f2 DOWN TITLE "Dynamic" .
DOWN WITH FRAME f2 .
END.
END.
So output will basically be
row1column1
row1column2
row1column3
...
row1columnN
row2column1
row2column2
row2column3
...
row2columnN
etc
Instead of
row1column1 row1column2 row1column3 ... row1columnN
row2column1 row2column2 row2column3 ... row2columnN
One idea to get the same result is to create a frame widget dynamically as well...
I'd do it this way. It would show the field value next to its name, and one record at a time. I hope this helps:
DO WHILE qMyTable:GET-NEXT():
DO i = 1 to iNumFields:
DISPLAY bMyTable:BUFFER-FIELD(i):NAME
bMyTable:BUFFER-FIELD(i):BUFFER-VALUE LABEL cTitlerow[i] WITH FRAME f DOWN.
DOWN WITH FRAME f.
END.
CLEAR FRAME f ALL.
END.
This should get you started on creating a frame and a "text" widgets dynamically:
define variable f as handle no-undo.
define variable t as handle no-undo.
define variable r as integer no-undo initial 1.
define variable c as integer no-undo initial 1.
create frame f.
assign
f:row = 4
f:column = 1
f:width-chars = 132
f:box = no
f:top-only = false
f:overlay = true
f:name = "something"
no-error.
create text t.
assign
t:frame = f
t:name = "text1"
t:format = substitute( "x(&1)", max( 1, 20, length( t:name )))
t:row = r
t:col = c
t:screen-value = "value1"
f:height-chars = max( r, f:height-chars )
.
f:visible = yes.
In your case you would probably want to create the frame just once at the top and then create 2 text widgets for each field - one for the label and one for the data values.

Adding dynamic tags to telegraf input

We're using telegraf to collect CloudWatch data from AWS and output it to InfluxDB.
We need to add dynamic tags to the input, s.t if "instancId == 12345", add tag "user = 3"
Is there a way to do this?
Take a look at the processors. If you have just a set of known values that you want to work with, I think enum would be the best option. Here is the example updated for your case:
[[processors.enum]]
[[processors.enum.mapping]]
## Name of the field to map
field = "instancId"
## Destination field to be used for the mapped value. By default the source
## field is used, overwriting the original value.
dest = "user"
## Default value to be used for all values not contained in the mapping
## table. When unset, the unmodified value for the field will be used if no
## match is found.
default = 0
## Table of mappings
[processors.enum.mapping.value_mappings]
123 = 1
1234 = 2
12345 = 3
See the CONFIGURATION.md docs:
[[inputs.cpu]]
percpu = false
totalcpu = true
[inputs.cpu.tags]
tag1 = "foo"
tag2 = "bar"

Peoplesoft rowset

I'm new to peoplesoft. I need a help in understanding the rowset and I have a requirement where i have 3 levels.
On level 1 i have a checkbox and when I open a component the value of the checkbox on level 1 should be passed and display to the level 2 grid for all rows.
For example
level0 - record1
level1 - record2 (Scroll Area)
level2 - record3 (grid)
When i access the page it should have values like this
Record2.field1 = Y => Row1 Record3.field1 = Y
Row2 Record3.field1 = Y
Record2.field1 = N => Row1 Record3.field1 = N
I have written the code at level2 record.field rowinit peoplecode event. but the problem is the same record field is used in level 0 as well. Is there a way where I can avoid using for loop as there could be n number of rows in the grid which might create a performance issue during page opening.
Thanks in advance,
Rowinit will fire for each rows in the scroll. So if you have a loop in the rowinit, loop will execute for each row.
If you want the check box to be set only during the component load, you can add the peoplecode in Component PostBuild.
&rsLevel1 = GetLevel0()(1).GetRowSet(Scroll.Level1);
for &nCnt1 = 1 to &rsLevel1.activerowcount
&rsLevel2 = &rsLevel1(&nCnt1).GetRowset(Scroll.Level2);
for &nCnt2 = 1 to &rsLevel2.activerowcount
&rsLevel2(&nCnt2).Level2.Check_box.value = &rsLevel1(&nCnt1).Level1.Check_box.value
end-for;
end-for;

Create Pivot table by using Autoit

Am trying to create pivot table by using Auto it tool, can anyone help to complete this code,need to add field in Columns , Rows and Value
below code just adding field in Filters
$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.WorkBooks.Open ("C:\AR\Deptwise AR-20.03.2017.xlsx")
$test = $oExcel.ActiveWorkbook.PivotCaches.Create(1,"A1:Y11795",1)
$oExcel.Sheets.Add
$test2 = $oExcel.Range("A1:Y11795")
$oExcel.ActiveSheet.PivotTables.Add($test,$test2,"GCI")
$oExcel.Application.ActiveSheet.PivotTables("GCI").PivotFields("GCI").Orientation = 3
$oExcel.ActiveSheet.PivotTables ("PivotTable5" ).PivotCache.Refresh

Resources