home *** CD-ROM | disk | FTP | other *** search
/ Merciful 3 / Merciful_Release_3.bin / software / b / blacksedv1.0.lha / BED / Rexx / ShowAG.bed < prev    next >
Text File  |  1996-01-28  |  2KB  |  106 lines

  1. /*
  2. ** $VER: ShowAG.bed 1.0 (03.01.96)
  3. **
  4. ** If a block is selected, save this block as an AmigaGuide database,
  5. ** and display it.
  6. **
  7. ** If no block is selected, determine if the cursor is currently within
  8. ** an AmigaGuide node. If so, create an AmigaGuide database containing only
  9. ** this node, and display it.
  10. **
  11. ** If no block is selected, and the cursor is not currently within an
  12. ** AmigaGuide node, display the whole document as an AmigaGuide database.
  13. */
  14.  
  15. OPTIONS RESULTS
  16. OPTIONS FAILAT 21
  17.  
  18. SetDisplayLock ON
  19. SetInputLock ON
  20.  
  21. TaskID = Pragma('ID')
  22. tempname = 'T:ShowAG-' || TaskID
  23. oldclip = 'T:OldClip-' || TaskID
  24.  
  25. GetCursorPos
  26. PARSE VAR RESULT cursorLine cursorColumn .
  27.  
  28. GetBlkInfo
  29. PARSE VAR RESULT blockActive . blockLine blockColumn .
  30.  
  31. GetFileInfo
  32. PARSE VAR RESULT . . '"'nodeName'"' .
  33.  
  34. IF blockActive = OFF THEN DO
  35.     SaveClip QUIET NOICON NOBACKUP oldclip
  36.  
  37.     GetPrefs FindBackward
  38.     back = RESULT
  39.     SetPrefs FindBackward ON
  40.  
  41.     Find "@node"
  42.     IF RC = 0 THEN DO
  43.         MoveDown
  44.         GetLine
  45.         PARSE VAR RESULT . '"' nodeName '"' .
  46.         MoveDown
  47.     END; ELSE DO
  48.         MoveSOF
  49.     END
  50.     MarkBlk
  51.  
  52.     SetPrefs FindBackward OFF
  53.  
  54.     Find "@endnode"
  55.     IF RC > 0 THEN DO
  56.         MoveBookmark 10
  57.     END
  58.  
  59.     IF Open(file, tempname, WRITE) THEN DO
  60.         WriteLn(file,'@database "'nodeName'"');
  61.         WriteLn(file,'@node Main "'nodeName'"');
  62.         Close(file);
  63.     END
  64.  
  65.     CopyBlk
  66.     SaveClip QUIET NOICON NOBACKUP APPEND tempname
  67.  
  68.     SetPrefs FindBackward back
  69.     OpenClip oldclip
  70.  
  71.     IF Open(file, tempname, APPEND) THEN DO
  72.         WriteLn(file,"@endnode");
  73.         Close(file);
  74.     END
  75.  
  76. END; ELSE DO
  77.     GetBlk lines
  78.  
  79.     IF Open(file, tempname, WRITE) THEN DO
  80.         WriteLn(file,'@database "'nodeName'"');
  81.         WriteLn(file,'@node Main "'nodeName'"');
  82.  
  83.         DO i = 1 TO lines.0
  84.             WriteCh(file,lines.i)
  85.         END
  86.         WriteLn(file,"")
  87.         WriteLn(file,"@endnode");
  88.         Close(file)
  89.         DROP lines.
  90.     END
  91. END
  92.  
  93. SetDisplayLock OFF
  94. SetInputLock OFF
  95.  
  96. Help FILE tempname
  97.  
  98. IF ~Show(L,'rexxsupport.library') THEN DO
  99.     AddLib('rexxsupport.library',0,-30)
  100. END;
  101.  
  102. ADDRESS COMMAND 'Wait 10'
  103.  
  104. Delete(tempname)
  105. Delete(oldclip)
  106.