#============================================================================== # Called by Onenote, this operation sets up the windows for user input. # Taking the labels and the predicates of the zones of the current roster, # it calculates the length of the longest prompt and right justifies the # prompts accordingly. #============================================================================== writeprompts IS OP headdata { labelsize := 0; FOR j WITH grid headdata DO labelsize := max labelsize (tally (string (j Ilabels reach headdata) link string (j Ipredicates reach headdata))); ENDFOR; width := labelsize + 1; ITERATE writescreen ' ' ' To enter data, hit key.' ' '; FOR j WITH grid headdata DO blanks := (labelsize - tally (string (j Ilabels reach headdata) link string (j Ipredicates reach headdata))) reshape ' '; writescreen (' (' link (string (j Ipredicates reach headdata)) link ')' link blanks link (string (j Ilabels reach headdata)) link ' : '); ENDFOR; width } #============================================================================== # This operation is called by Createint, Addblock, and AddNint. It is # the user interface to gather data about each zone for one note. # Each data entry is changed to its proper type by applying the # converter function to the entry. A fault is returned if the entry # cannot be changed to the appropriate data type. #============================================================================== onenote IS OP headdata notedata { clearwindow; outerwindow := window; outerrow := 0 0 reach outerwindow; outercol := 0 1 reach outerwindow; newdata := null; labelsize := writeprompts headdata; innercol := outercol + labelsize + 6; colours := 2 3 choose window; innerwindow := ((outerrow + 3) innercol)((1 0 reach outerwindow - 3) (1 1 reach outerwindow - labelsize - 6)) link (colours); setwindow innerwindow; IF notedata = null THEN userinput := editwindow null; ELSE strings := EACH string EACH display notedata; userinput := editwindow (strings)(0 0)(0 0); ENDIF; IF tally headdata >= tally first userinput THEN newuserinput := first userinput; IF tally headdata > tally newuserinput THEN FOR i WITH tell (tally headdata - tally first userinput) DO newuserinput := newuserinput append null; ENDFOR; ENDIF; mainwindow 'PROCESSING STRINGS...'; FOR j WITH grid newuserinput DO IF empty (j pick newuserinput) THEN data := fault 'noexpr'; ELSEIF notedata = null THEN data := apply (j Iconverters reach headdata) (trimblanks (j pick newuserinput)); ELSE data := execute trimblanks (j pick newuserinput); ENDIF; IF NOT ((apply (j Ipredicates reach headdata) data) OR isfault data OR isfault first data) THEN newdata := fault ('Unit_conflict - ' link string (trimblanks (j pick newuserinput))); exit newdata; ELSE newdata := newdata link [data]; ENDIF; ENDFOR; newdata ELSEIF tally headdata < tally first userinput THEN newdata := fault ('Length_conflict') ENDIF }