DIRECTORY BuildFile, TiogaOps, TiogaExtraOps, FS, Rope USING [ROPE, Cat]; BuildFileImpl: CEDAR PROGRAM IMPORTS TiogaOps, TiogaExtraOps, FS, Rope EXPORTS BuildFile = BEGIN OPEN BuildFile; OpenTemplate: PUBLIC PROC[fileName: Rope.ROPE] RETURNS[Handle] = BEGIN handle: Handle; haveError: BOOL _ FALSE; handle.rootRef _ TiogaExtraOps.GetFile[fileName ! FS.Error => {haveError _ TRUE; CONTINUE}]; handle.valid _ ~haveError; RETURN[handle]; END; Substitute: PUBLIC PROC[hand: Handle, key: Rope.ROPE, value: Rope.ROPE] = BEGIN found: BOOL; pat: TiogaOps.Pattern _ TiogaOps.CreateSimplePattern[target: Rope.Cat["", key, ""], case: TRUE, literal: TRUE]; DO IF ~found THEN EXIT; ENDLOOP; END; WriteAndClose: PUBLIC PROC[hand: Handle, fileName: Rope.ROPE] = BEGIN TiogaExtraOps.PutFile[fileName, hand.rootRef]; TiogaExtraOps.FreeTree[hand.rootRef]; hand.rootRef _ NIL; hand.valid _ FALSE; END; END. File: BuildFileImpl.mesa Copyright c 1984 by Xerox Corporation. All rights reserved. Created by: August 16, 1984 6:43:29 pm PDT Last Edited by: Mayo, August 17, 1984 6:00:17 pm PDT -- Prepare a template from a Tioga file with key fields. -- valid = TRUE if successful -- Substitute all occurences of key with value [found, start, end] _ TiogaOps.NodeSearch[pattern: pat, whichDir: $anywhere, startLoc: , endLoc: TiogaOps.LastLocWithin[hand.rootRef]]; -- Write the resulting file, invalidating the handle. ΚΒ˜– "Cedar" stylešœ™Jšœ Οmœ1™