/* ** $VER: ShowAG.bed 1.0 (03.01.96) ** ** If a block is selected, save this block as an AmigaGuide database, ** and display it. ** ** If no block is selected, determine if the cursor is currently within ** an AmigaGuide node. If so, create an AmigaGuide database containing only ** this node, and display it. ** ** If no block is selected, and the cursor is not currently within an ** AmigaGuide node, display the whole document as an AmigaGuide database. */ OPTIONS RESULTS OPTIONS FAILAT 21 SetDisplayLock ON SetInputLock ON TaskID = Pragma('ID') tempname = 'T:ShowAG-' || TaskID oldclip = 'T:OldClip-' || TaskID GetCursorPos PARSE VAR RESULT cursorLine cursorColumn . GetBlkInfo PARSE VAR RESULT blockActive . blockLine blockColumn . GetFileInfo PARSE VAR RESULT . . '"'nodeName'"' . IF blockActive = OFF THEN DO SaveClip QUIET NOICON NOBACKUP oldclip GetPrefs FindBackward back = RESULT SetPrefs FindBackward ON Find "@node" IF RC = 0 THEN DO MoveDown GetLine PARSE VAR RESULT . '"' nodeName '"' . MoveDown END; ELSE DO MoveSOF END MarkBlk SetPrefs FindBackward OFF Find "@endnode" IF RC > 0 THEN DO MoveBookmark 10 END IF Open(file, tempname, WRITE) THEN DO WriteLn(file,'@database "'nodeName'"'); WriteLn(file,'@node Main "'nodeName'"'); Close(file); END CopyBlk SaveClip QUIET NOICON NOBACKUP APPEND tempname SetPrefs FindBackward back OpenClip oldclip IF Open(file, tempname, APPEND) THEN DO WriteLn(file,"@endnode"); Close(file); END END; ELSE DO GetBlk lines IF Open(file, tempname, WRITE) THEN DO WriteLn(file,'@database "'nodeName'"'); WriteLn(file,'@node Main "'nodeName'"'); DO i = 1 TO lines.0 WriteCh(file,lines.i) END WriteLn(file,"") WriteLn(file,"@endnode"); Close(file) DROP lines. END END SetDisplayLock OFF SetInputLock OFF Help FILE tempname IF ~Show(L,'rexxsupport.library') THEN DO AddLib('rexxsupport.library',0,-30) END; ADDRESS COMMAND 'Wait 10' Delete(tempname) Delete(oldclip)