proc getBufferValue {form idx column_name} {
return "[$form readInputField scroll($idx).$column_name]"
}
proc getAttributeValue {form idx} {
return "[$form readInputField attributes($idx).attribute]"
}
proc createPreviewTable { form } {
set scroll [GuidoFunction getComponentByName scroll $form]
set numcolumns [$form numberInputFields scroll(0) ]
set numrows [$form numberInputFields scroll ]
for {set col 1} {$col <= $numcolumns} {incr col} {
set fieldname "value$col"
GuidoField $fieldname {
-input false
-label "$col"
-display_length 8
}
upvar 0 value$col fieldvar
set fieldObject [$fieldvar getObject]
$scroll add $fieldObject
$scroll setInitialRows $numrows 1 $numrows
for {set idx 0} {$idx < $numrows} {incr idx} {
$fieldvar setCurrentValue $idx [getBufferValue $form $idx "value$col"]
}
}
set attribute [GuidoFunction getComponentByName attribute $form]
set attributes [GuidoFunction getComponentByName attributes $form]
set buffer [ GuidoExecServer GetAttributeValueList {} ]
set attributeNumber [ GuidoGetParamBufferValue $buffer "attributeNumber" ]
set attributeList ""
if {[expr $attributeNumber > 0} {
set attributeList [ GuidoGetParamBufferValue $buffer "attribute" ]
} else {
GuidoMessage warning "BM_NO_ATTS_FND"
}
set hiddenValue [$form readInputField hidden]
if {$hiddenValue == "1"} {
set attributeList [linsert $attributeList 0 x_size y_size z_size]
}
set attributeList [linsert $attributeList 0 x y z]
eval [concat {$attribute} {setValues} $attributeList ]
set numberOfRowsToAdd [expr $numcolumns - [$attributes getRowCount]];
if { $numberOfRowsToAdd > 0 } {
$attributes addRows $numberOfRowsToAdd
}
for {set idx 0} {$idx <= $numberOfRowsToAdd} {incr idx} {
$attribute setCurrentValue $idx "[getAttributeValue $form $idx]"
}
}
proc writeResults { form } {
set attribute [GuidoFunction getComponentByName attribute $form]
set attributes [GuidoFunction getComponentByName attributes $form]
if { [string compare [$form getStatus] "legacy preprocess apply"] ==  0 } {
set numrows [$attributes getRowCount]
$form writeOutputField "GuidoTableRowCounter.attributes" $numrows
for {set row 0} {$row < $numrows} {incr row} {
$form writeOutputField "attributes($row).attribute" [$attribute getCurrentValue $row]
}
$form finishedWritingFields
}
}
GuidoForm frm21407 {
-default_buttons
-help_id 655
-label "Define Attributes"
-action initial {[createPreviewTable $frm21407]}
-action stateChanged {[writeResults $frm21407 ]}
-layout BoxLayout Y_AXIS
-tip "21407_TIP_001"
GuidoPanel p2 {
-border etched true
-label "Preview of data from import file"
GuidoScrollPane scroll2 {
-height 10
-width 50
GuidoTable scroll {
-instances 1 1 100
-interactive true
}
}
}
GuidoFiller f1 {
-height 2
}
GuidoPanel p1 {
GuidoScrollPane scroll1 {
-height 10
GuidoTable attributes {
-instances 1 1 100
-interactive true
GuidoComboBox attribute {
-label "Attribute for column #"
-display_length 12
-tip "21407_TIP_002"
-no_mlt
-max_length BM_MAX_ATT_NAME_LEN
}
}
}
}
$frm21407 legacyProcessValues false
}
