home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION PICKIT (top, left, bottom, right, in_array, ;
- out_array, new_color)
- *****************************************************************
-
- * Allow selection of elements from an array
-
- * Copyright(c) 1991 - James Occhiogrosso
-
- #include "box.ch"
-
- LOCAL choice :=1, counter :=1, new_array[0], ;
- num_elems := LEN(in_array), old_screen, old_color, ;
- pad_len := (right-1) - (left+1)
-
- * Check the display array for all character elements
- IF .NOT. ARTYPE(in_array, 'C')
- RETURN(-1)
- ENDIF
-
- * Save old screen
- old_screen = SCRNSAVE(top, left, bottom, right)
-
- * Test the color argument
- IF VALTYPE(new_color) = 'C' .AND. .NOT. EMPTY(new_color)
- * Color was passed, use it
- old_color = SETCOLOR(new_color)
-
- ELSEIF new_color = NIL
- * No argument passed, use default color
- old_color = SETCOLOR(colwindow)
-
- ELSE
- * Use current color
- old_color = SETCOLOR()
-
- ENDIF
-
- * Box display area
- @ top, left, bottom, right BOX B_SINGLE + SPACE(1)
-
- FOR counter = 1 TO num_elems
-
- * Pad elements of in_array to same length for viewing
- in_array[counter] = ;
- PADR(' ' + in_array[counter], pad_len)
-
- * Pad return array for marking
- out_array[counter] = SPACE(1) + out_array[counter]
-
- NEXT
-
-
- DO WHILE choice != 0
-
- * Wait in ACHOICE for an operator selection
- choice = ACHOICE(top+1, left+1, bottom-1, right-1,;
- in_array, '', '', choice)
-
- IF choice > 0
- * Mark/unmark array elements
-
- IF SUBSTR(in_array[choice],2,1) = '√'
-
- * If element is already marked, unmark it
- in_array[choice] = ' ' + ;
- SUBSTR(in_array[choice],4)
- out_array[choice] = ' ' + ;
- SUBSTR(out_array[choice],2)
- ELSE
-
- * Otherwise, mark selected element
- in_array[choice] = ' √ ' + ;
- SUBSTR(in_array[choice],4)
- out_array[choice] = '√' + ;
- SUBSTR(out_array[choice],2)
- ENDIF
- ENDIF
- ENDDO
-
-
-
- FOR counter = 1 TO num_elems
-
- IF SUBSTR(out_array[counter],1,1) = '√'
-
- * If element is marked, strip mark
- * and add the element to new_array
-
- AADD(new_array, SUBSTR(out_array[counter],2))
-
- ENDIF
-
- * Restore input array to original state
- in_array[counter] = SUBSTR(in_array[counter],4)
-
- NEXT
-
- * Copy new array to return array.
-
- ASIZE(out_array, LEN(new_array))
- ACOPY(new_array, out_array)
-
- * Clean up and return number of selections
-
- SETCOLOR(old_color)
- SCRNREST(old_screen)
-
- RETURN LEN(new_array)
-
-
-