How to access controls? - openedge

I have just created a window, containing a fill-in field (TestField) and a checkbox (chk_TestField):
DEFINE VARIABLE TestField AS INTEGER VIEW-AS FILL-IN.
DEFINE VARIABLE chk_TestField AS LOGICAL VIEW_AS TOGGLE-BOX.
It is very simple to change the value of the fill-in field, based on the checking of the checkbox, something like:
ON VALUE-CHANGED OF chk_TestField IN FRAME DEFAULT-FRAME
DO:
TestField = 5.
END.
However, I'm interested in changing an attribute of the Fill-in field itself, not the integer it represents (I would like to make the fill-in field read-only), how to I do this?
I've tried:
ON VALUE-CHANGED OF chk_TestField IN FRAME DEFAULT-FRAME
DO:
TestField.Read-Only = NOT(chk_TestField).
END.
This, obviously, does not work.

ASSIGN TestField:READ-ONLY IN FRAME {&FRAME-NAME} = TRUE.
or
ASSIGN Table.TestField:READ-ONLY IN FRAME {&FRAME-NAME} = TRUE.

Related

Finding a "whole string" within a string with Index (or another way)?

I am reading in a list of constituent attributes (tags) and only want to keep a subset of them. Here is how I attempted to do that.
DEFINE VARIABLE tagsToKeep AS CHARACTER.
tagsToKeep = "Business Contact,Celebrate 2015,Celebrate 2017,Celebrate 2019,Certificate - Former Holder,Non-MB Church".
/*do a bunch of stuff to get the cRecord which is one tag, often with spaces or other characters in it.*/
IF INDEX(tagsToKeep, cRecord) > 0 THEN
DO:
CREATE ttTag.
ASSIGN
ttTag.tag-code = cRecord
ttTag.constituent-id = ttAccount.pin-string.
ttTag.tag-name = cRecord.
END.
The trouble is that one of the tags is "Certificate" which is a substring of one of the strings in the TagsToKeep string -- "Certificate - Former Holder" gets included and created as a Tag. I only want to match on the strings that are essentially "whole word only".
Is there a (better) way to do what I want to do?
In your code, use LOOKUP instead of INDEX
IF LOOKUP (cRecord, tagsToKeep) > 0 THEN
(comma-) delimited lists are a key concept in the ABL.
If cRecord is a single tag, then it may be useful to take the list of to-keep tags and put those tags into a separate temp-table
DEFINE VARIABLE loop AS INTEGER NO-UNDO.
DEFINE VARIABLE cnt AS INTEGER NO-UNDO.
// Define and populate temp-table
DEFINE TEMP-TABLE ttTagsToKeep NO-UNDO
FIELD TagName AS CHARACTER
INDEX idx1 AS PRIMARY UNIQUE TagName.
cnt = NUM-ENTRIES(cTagsToKeep).
DO loop = 1 to cnt:
CREATE ttTagsToKeep.
ASSIGN ttTagsToKeep.TagName = TRIM(ENTRY(loop, cTagsToKeep)).
END.
Now you can look for a matching record. Whether you clean up cRecord or do multiple CAN-FINDs is up to you.
IF CAN-FIND(ttTagsToKeep WHERE ttTagsToKeep.TagName EQ cRecord) THEN
DO:
// create ttTag record
END.

javascript for Array how many and min

I am trying to create a form in Acrobat. I want it to do some calculations. I got almost all of them done aside from 2.
I have an array of cells DF1 to DF78 so I need a calculation script that will give me the minimum value in that array not counting the blank ones.
In the same array of cells DF1 to DF78 I need a calculation script to find how many fields in that array have value and bring me up the number.
I already tried using the min option on the acrobat DC and selecting the fields. Ii want to look at DF1 to DF78. However, it always shows 0 because it's counting the empty fields as well.
I tried looking online, but all the scripts that they show are very confusing. I can't find where to put the array in there.
I wish I had a script to put it in here... sorry.
I have fields DF1 to DF78 so a total of 78 fields, and I need to find the minimum value in that array not including the fields that are blank.
Another script for the same fields DF1 to DF78 needs to count how many of the fields actually have data ex: DF1, DF2, DF3 had data on it and the rest are empty so it should display the number 3 because 3 of the 78 fields have data in them.
I hope somebody can help me with this.
This should work... Add it to the calculate action of a new hidden field you want the numbers to show up. Fix the names on the last two lines first.
valueArray = [];
for (var i = 1; i <= 78 ; i++) {
//Get the fieldvalue by assembling the name with the prefix and the number increment
var fieldVal = this.getField("DF"+i).value;
//Acrobat field values are never null. The value of a blank field is an empty string
if (fieldVal != "") {
//Add non-empty field values to an Array.
valueArray.push(fieldValue);
}
}
// Get the minimum value in the array.
var minValue = Math.min.apply(null, valueArray);
// Get the number of non-blank fields.
var nonBlankFields = valueArray.length;
this.getField("RESULT FOR YOUR 1st QUESTION FIELD NAME HERE").value = minValue;
this.getField("RESULT FOR YOUR 2nd QUESTION FIELD NAME HERE").value = nonBlankFields;

Editable ALV with no limitation of lines

I need to create a report that displays an empty ALV with 4 columns and that is editable (the user can input on the fields of the ALV).
The ALV is going to be used as an input for the user and the data is then going to be read from the ALV.
What would be the best approach for this?
When youre setting the fieldcatalog, you need to declare "editable". For example
wa_fieldcat-fieldname = 'REMARKS'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-outputlen = 10.
wa_fieldcat-editable = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
Then you need to declare in your process after input(PAI) the check changed data of the alv.
alv->checked_changed_data

Which event should be applied to the combo-box in prorgress 10.2b, so that it drop down

Which event should be applied to the combo-box in prorgress 10.2b, so that it drop down. By default, this is the cursor down, but I need it to open by a space, and I just can not figure out how to do it.
I've managed to do it by creating a selection list that's a copy of the list-items in your combo-box.
Here's some code. Assume the combo is called c and the frame is called f. This works even if you have a widget directly under your combo.
def var hSL as handle no-undo. /* Mandatory variable definition in your program */
on ' ' of c do:
create selection-list hSL
assign frame = frame f:handle
col = c:col in frame f
row = c:row in frame f + 1
list-items = c:list-items in frame f
visible = yes
sensitive = true
triggers:
on return persistent run piChoose.
on leave persistent run piLeave.
end triggers.
apply 'entry' to hSL.
end.
procedure piChoose:
assign c:screen-value in frame f = hSL:Screen-value.
assign c.
apply 'leave' to self.
end procedure.
procedure piLeave:
delete object hSL no-error.
end procedure.
Note if you're using list-item-pairs, then the LIST-ITEM-PAIRS attribute should be used where I'm using list-items.
Hope that helps!

Populate a temp-table with widget-handle in progress abl

I am trying to create dynamically a group of buttons, using this code:
DEFINE VAR temp-hand AS WIDGET-HANDLE.
DEFINE INPUT PARAMETER ipc AS CHARACTER NO-UNDO.
&global-define X VALUE(v + ipc )
CREATE BUTTON temp-hand
ASSIGN
FRAME = FRAME btn-frame:HANDLE
ROW = vdeInicio
COLUMN = 10
WIDTH = 19
LABEL = ipc
SENSITIVE = TRUE
VISIBLE = TRUE
TRIGGERS:
ON CHOOSE PERSISTENT RUN btn-mess IN THIS-PROCEDURE.
END TRIGGERS.
temp-hand:LOAD-IMAGE("imagenes/Entradas").
vdeInicio = vdeInicio + 3.57.
This works when I address a single button widget, also if a write a loop and call a procedure with this code in it, it creates multiple buttons but points to one handle, some told me than creating a temp table and saving there the widget handle may work, but I donĀ“t know how to populate the table with the widget-handle, can you help me with this,
Something like this:
define temp-table tt_buttonList no-undo
field buttonId as integer
field buttonHandle as widget-handle
.
define variable i as integer no-undo.
do i = i to 5:
create tt_buttonList.
tt_buttonList.buttonId = i.
CREATE BUTTON tt_buttonList.buttonHandle
ASSIGN FRAME = FRAME btn-frame:HANDLE /* this is undefined in your example -- I have no idea where it came from */
ROW = i * 4
COLUMN = 10
WIDTH = 19
LABEL = string( i )
SENSITIVE = TRUE
VISIBLE = TRUE
.
end.
I've no idea why you would run code like this from a trigger procedure. While it might "work", mixing UI into db access code like that is really asking for serious trouble.

Resources