use CHECKED attribute on dynamic checkboxes

Serge

New Member
Hi all,

I have a .w file where I dynamically create checkboxes. While creating them, I store them into a temp-table to check afterwards if they are checked or not! This is my code:

DEF TEMP-TABLE ttWidgets
FIELD ttId AS INT
FIELD ttWidget AS HANDLE.

DEF VAR cServers AS CHAR NO-UNDO
INIT "server1 (BE), server2 (FR), server3 (PL), server4 (IE), server5 (EN)".
DEF VAR hdlToggle AS HANDLE NO-UNDO.
DEF VAR hdlFrame AS HANDLE NO-UNDO.
DEF VAR i AS INT NO-UNDO.
DEF VAR intRow AS INT NO-UNDO INIT 5.
DEF VAR intCol AS INT NO-UNDO INIT 10.

ASSIGN hdlFrame = FRAME {&FRAME-NAME}:HANDLE.

DO i = 1 TO NUM-ENTRIES(cServers) BY 1:

CREATE TOGGLE-BOX hdlToggle
ASSIGN
ROW = intRow
COLUMN = intCol
LABEL = ENTRY(i,cServers)
FRAME = hdlFrame
CHECKED = FALSE
VISIBLE = TRUE
SENSITIVE = TRUE.

CREATE ttWidgets.
ASSIGN
ttWidgets.ttId = i
ttWidgets.ttWidget = hdlToggle.

intRow = intRow + 1.

IF i = 5 THEN ASSIGN intCol = 30.
IF i = 5 THEN ASSIGN intRow = 5.
END.

Now, when I press a button I want to loop through all dynamic checkboxes to verify if they are checked or not, if checked then display the checkbox' label.
(Next procedure is NOT running but I just pasted here to make my point).

PROCEDURE (Press Button):
DEF VAR hBuffer AS HANDLE NO-UNDO.
DEF VAR bttWidgets AS HANDLE NO-UNDO.
DEF VAR qttWidgets AS HANDLE NO-UNDO.

bttWidgets = TEMP-TABLE ttWidgets: DEFAULT-BUFFER-HANDLE.
CREATE QUERY qttWidgets.
qttWidgets:SET-BUFFERS(TEMP-TABLE ttWidgets: DEFAULT-BUFFER-HANDLE).
qttWidgets:QUERY-PREPARE("for each " + TEMP-TABLE ttWidgets:NAME).
qttWidgets:QUERY-OPEN().
hBuffer = qttWidgets:GET-BUFFER-HANDLE(1).
qttWidgets:GET-FIRST().
DO WHILE NOT qttWidgets:QUERY-OFF-END:
IF hBuffer:BUFFER-FIELD(1):CHECKED THEN
MESSAGE STRING(hBuffer:BUFFER-FIELD("ttWidgets"):LABEL)) VIEW-AS ALERT-BOX.
qttWidgets:GET-NEXT().
END.
END.
END PROCEDURE.

I think I'm making it too complicated ... Does somebody know how it should be syntaxed?

Thx in advance!
 

parul

Member
Try this in you procedure:

FOR EACH ttWidgets NO-LOCK:
MESSAGE ttWidgets.ttWidget:CHECKED
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.


-Parul.
 

Casper

ProgressTalk.com Moderator
Staff member
Well,

the dynamic stuff isn't making it easier.
But the problem I think is that you ask if the buffer-field is checked.
But you want to know if the handle (which is the value of the buffer-field) is checked.

So more like:
Code:
.....
IF hBuffer::ttwidgets:CHECKED THEN
MESSAGE hBuffer::ttWidgets:LABEL VIEW-AS ALERT-BOX.
.........

I dont' kow if your on version 10 otherwise the shortcuts (bufferhandle::fieldname) doesn't work. Then you have to write it out.
(buffer-handle:buffer-field(field-name):buffer-value)
And I also don;t know if it is possbile to concatenate this all in one statement.

If not then you have to assign the handle first:
Code:
assign hTog = hBuffer::ttwidgets.
MESSAGE hTog:LABEL VIEW-AS ALERT-BOX.
.........

HTH,

Casper.
 

Serge

New Member
Parul's solution is just what I need - it's that simple - like I was telling I felt I was making it too complicated because of that handle in the temp-table!

Casper's solution worked also but he continued on my unnecessary complicated code.

Cheerz!

- Serge
 
Top