Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLCSFMN2

HLCSFMN2.m

Go to the documentation of this file.
  1. HLCSFMN2 ;ALB/JRP - FILER MONITOR UTILITIES;13-FEB-95 ;10/15/99 07:16
  1. ;;1.6;HEALTH LEVEL SEVEN;**57**;Oct 13, 1995
  1. ;
  1. SELECT(INARR,ENTITY) ;SELECTION UTILITY
  1. ;INPUT : INARR - Array whose first subscript denotes the list of
  1. ; selectable numbers (full global reference)
  1. ; - $O(INARR(x)) yields all selectable numbers
  1. ; ENTITY - What's being selected
  1. ; - Defaults to 'Entry' (prompt is 'Select Entry')
  1. ;OUTPUT : X - Number selected
  1. ; 0 - Nothing selected
  1. ; -1 - Bad input / nothing to select from
  1. ; -2 - Timeout / abort
  1. ;NOTES : User does not have to select an entry
  1. ; : Number selected will be validated (must be in INARR). This
  1. ; allows gaps to exist in INARR(x).
  1. ; : Only whole numbers greater than zero are selectable
  1. ;
  1. ;CHECK INPUT
  1. Q:($G(INARR)="") -1
  1. Q:('$O(@INARR@(0))) -1
  1. S:($G(ENTITY)="") ENTITY="Entry"
  1. ;DECLARE VARIABLES
  1. N DIR,X,Y,DTOUT,DUOUT,DIRUT,FRSTENT,LSTENT,LOOP,DONE
  1. ;DETERMINE FIRST AND LAST ENTRY NUMBERS
  1. S FRSTENT=+$O(@INARR@(""))
  1. S LSTENT=+$O(@INARR@(""),-1)
  1. ;ONLY ONE ITEM - AUTO SELECT
  1. Q:(FRSTENT=LSTENT) FRSTENT
  1. ;PROMPT USER FOR VALID SELECTION
  1. F DONE=0:0 D Q:(DONE)
  1. .K DIR,DTOUT,DUOUT,DIRUT,X,Y
  1. .S DIR(0)="NAO^"_FRSTENT_":"_LSTENT_":0"
  1. .S DIR("A")="Select "_ENTITY_" ("_FRSTENT_"-"_LSTENT_"): "
  1. .S DIR("?",1)="Response must be a number between "_FRSTENT_" and "_LSTENT
  1. .S DIR("?")="Enter '??' to see a list of valid selections"
  1. .S DIR("??")="^W !!,""Valid Selections: "" S LOOP=0 F S LOOP=+$O(@INARR@(LOOP)) Q:('LOOP) W:(LOOP'=FRSTENT) "","" W:(($X+$L(LOOP)+1)>79) !,?18 W LOOP"
  1. .D ^DIR
  1. .;TIMEOUT/ABORT
  1. .I (($D(DTOUT))!($D(DUOUT))) S Y=-2,DONE=1 Q
  1. .;NOTHING SELECTED
  1. .I ($D(DIRUT)) S Y=0,DONE=1 Q
  1. .;VALIDATE SELECTION
  1. .I ($D(@INARR@(Y))) S DONE=1 Q
  1. .;INVALID SELECTION
  1. .W $C(7),!!,Y," is not a valid selection"
  1. .W !,"Enter '??' to see a list of valid selections"
  1. .W !
  1. ;DONE
  1. Q Y