Looping through elements in a selection set

Bacis2 and API programming
Post Reply
drutiss
Posts: 5
Joined: Tue Apr 16, 2002 9:39 am
Location: Columbia, SC

Looping through elements in a selection set

Post by drutiss » Fri May 09, 2003 4:05 pm

Hello,

Does anyone have a sample of a routine that
creates a selection set based on an element type,
then loops through those elements to extract text/
data, that is loaded into a dialog box for user selection?

Example:

We have clumps that contain a spl text type.
I would like to loop through all clumps, containing
the spl text type, and extract all other text contained in
the clump. then present this data in a list (multiple choice -maybe) for users to select. Once selected in the
list box, the clump is selected in the drawing.

Thanks in advance,

Steve

DK
Posts: 19
Joined: Thu Oct 31, 2002 2:52 am
Location: Tokyo Japan
Contact:

Looping through elements in a selection set

Post by DK » Mon May 12, 2003 12:42 am

Hello Steve,

How about this sample?

UID
----------------------------------------------------
ex_btn.class:ui_action_button
.parent:user_tooltray
.icon:"DUMMY"
.x:1
.y:2
.activate:ex_p_dia_open

ex_dia.class:ui_dialog_box
.parent:main

ex_dia_t.class:ui_table
.parent:ex_dia

ex_dia_mc1.class:ui_multi_choice_list
.parent:ex_dia_t
.visible_lines:20
.x:1
.y:1

ex_dia_mc2.class:ui_multi_choice_list
.parent:ex_dia_t
.x:1
.y:1
.visible:false

ex_dia_b1.class:ui_action_button
.parent:ex_dia
.label:"Select"
.activate:ex_p_dia_select
.x:1
.y:1

ex_dia_b2.class:ui_action_button
.parent:ex_dia
.label:"Close"
.activate:ex_p_dia_close
.x:2
.y:1

BAD
------------------------------------------
define_constant(!ex_p_dia_open, proc()

lab:- []
id:- []

loop for tex over m2d_scan(cndb_cb(!type,!eq,"ST1"))
lab:-lab>< [integer_string(tex!id)]
endloop

ui!ex_dia!ex_dia_t!ex_dia_mc1!labels:-lab
ui!ex_dia!ex_dia_t!ex_dia_mc2!labels:-id

ui!ex_dia!visible:-true

endproc)

------------------------------------------
define_constant(!ex_p_dia_close, proc()
ui!ex_dia!visible:-false
endproc)

------------------------------------------
define_constant(!ex_p_dia_select, proc()

sel:-ui!ex_dia!ex_dia_t!ex_dia_mc1!selections
ids:-ui!ex_dia!ex_dia_t!ex_dia_mc2!labels

sset:-m2d_selection_create()
sta:-m2d_goto(!first)

loop for selNo over elements_of(sel)
id:-mui_string_to_integer(ids[selNo])
tex:-m2d_goto(!next,cndb_cb(!id,!eq,id))
clmp:-m2d_goto(!owner,tex)
m2d_selection_add(sset,clmp)
endloop
mui_select(!selection_set,sset)

endproc)


This sample has no error handling.

DK.

Post Reply