;+ ; ; FILE OPSYS_LGCL.PRO - OPerating SYStem LoGiCaL ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; PRO OPSYS_EVENT, EVENT ; ; The event handler for PRO OPSYS_LGCL ; Only two actions will be handled here. Either the user clicked ; on the button CANCEL or entered input to TEXT widget (which should ; be the data location) ; ; calls to : none ; COMMON opslog : variable DESIGNATE is returned with user's input ; variable OK is a success/failure flag ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- pro opsys_event, event ; event handler common opslog, designate, ok widget_control, event.id, get_uvalue=input ; user's name for widget ok = 0 ; assume something fails type = strmid(tag_names(event, /structure_name), 7, 1000) ; type of widget case type of ; (BUTTON, LIST...) 'BUTTON' : begin ; the only BUTTON is CANCEL ok = 0 ; can't continue without input end 'TEXT' : begin ; the only TEXT widget is user's input widget_control, event.id, get_value=value, set_value='' ; get ; user ; input designate = value(0) ; assign user's input ok = 1 ; continue with happy thoughts end else : print,'PROGRAM ERROR - OPSYS_LGCL.PRO Invalid type of widget '+type endcase widget_control, event.top, /destroy ; kill this widget after either event return end ;=========================================================================== ;+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; PRO OPSYS_LGCL, PART1=PART1, DISCERN=DISCERN, PART2=PART2, SEPARATE=SEPARATE,$ ; DATAPLACE=DATAPLACE, INSTRUCTME=INSTRUCTME, $ ; CANCELLED=CANCELLED ; ; Test for logical/environment name based on provide keywords. ; If the provide logical/environent name is not defined for the ; current session then create a widget to query the user for the ; data location. ; ; INPUT ; PART1 : string naming part 1 of logical/environment name ; ; PART2 : string naming part 2 of logical/environment name ; ; DISCERN : 0 if not to discern two parts of logical/environment name ; 1 if user wants to discern the two parts of a ; logical/environment name (ex: part1$part2, part1_part2) ; -or- ; string containing the discerning value to be used ; ; SEPARATE : 0 if not to separate location from filename ; 1 if user wants program to separate location from filename ; (ex: vms=":", unix="/") ; ; INSTRUCTME : string array containing directions written to widget ; ; OUTPUT ; DATAPLACE : returns whatever the user input to text widget ; ; STATUS : 0 if no input is obtained from DATAPLACE ; 1 if input was provided to DATAPLACE ; ; COMMON opslog : variables DESIGNATE and OK are returned by event handler ; ; MODIFICATION HISTORY ; JAN 1993 - Elaine Einfalt (HSTX) ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- pro opsys_lgcl, part1=part1, discern=discern, part2=part2, $ separate=separate, instructme=instructme, $ dataplace=dataplace, ok=status common opslog, designate, ok if n_elements(part1) eq 0 then part1='' if n_elements(part2) eq 0 then part2='' if n_elements(discern) eq 0 then begin ; was undefined discern=0 ; don't want one discerner='' ; so assign a null endif else begin type = size(discern) ; what kind of data type if type(1) eq 7 then begin ; a string was passed discerner = discern ; user wants this discerner discern = 0 ; so don't use defaults endif else discerner = '' ; use system standard endelse if n_elements(separate) eq 0 then separate=0 ; don't want one if n_elements(instructme) eq 0 then instructme='No instructions provided.' if discern then $ ; if user wants a deefault discerner case !version.os of ; provide conventional character 'vms' : discerner = '$' ; between two parts of a 'ultrix' : discerner = '_' ; logical/environment name 'IRIX' : discerner = '_' else : discerner = '_' ; assume UNIX-like endcase designate = part1 + discerner + part2 ; put together the log/env name ; from the parts the user gave logtest = getenv(designate) ; is log/env defined for user if logtest ne '' then begin ; logical/environment name is defined ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; A logical or environment name was present with the constructed name ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; designate = logtest ; the value of the log/env name ok = 1 ; all is right with the world endif else begin ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; If the logical/environment name was not defined so create a widget ; so the user may enter the data location manually. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; query = widget_base(title='Data designation', /column, $ xpad=20, ypad=20, space=30) lab = widget_base(query, /column) for i = 0, n_elements(instructme)-1 do $ ; write out instructions lab1 = widget_label(lab, value=instructme(i)) querinp = widget_text(query, /editable, xsize=70) cancel = widget_button(query, value='CANCEL') widget_control, query, /realize xmanager,'opsys', query, /modal endelse if separate then begin ; if the user wants the default separator after ; the disk location but before a filename case !version.os of 'vms' : if strpos(designate, ']') lt 0 then $ ; if no directory in designate = designate + ':' ; name then a ; searator is added 'ultrix' : designate = designate + '/' ; all cases need "/" 'IRIX' : designate = designate + '/' ; all cases need "/" else : designate = designate + '/' ; assume UNIX-like endcase endif dataplace = designate ; assign data location status = ok return end