Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Capturing output from 'help

 [1/4] from: tim:johnsons-web at: 30-Jul-2001 16:14


Hello All: Typing >> help next at the shell prompt gives me the following: USAGE: NEXT series DESCRIPTION: Returns the series at its next position. NEXT is an action value. ARGUMENTS: series -- (Type: series port) Now how can I capture that output as a block or other data structure? TIA tj

 [2/4] from: being_doug:y:ahoo at: 30-Jul-2001 18:34


Hello! Here's one way. Echo to a temp file, then read the file back into a string. ;--start script--- REBOL [ Title: "Capture help" Date: 30-July-2001 Author: "doug edmunds" Purpose: "capture help output as a string." File: %capture_help.r ] temp_file: %temphelp.txt echo temp_file help next ; change 'next' to any help topic ; or part of word (i.e., help br) echo none help_string: read temp_file delete temp_file print "^/now printing help_string:" print help_string print "press any key" input ;--end script---- --doug edmunds --- Tim Johnson <[tim--johnsons-web--com]> wrote:

 [3/4] from: tim:johnsons-web at: 30-Jul-2001 18:53


On Mon, Jul 30, 2001 at 06:34:36PM -0700, doug edmunds wrote:
> Hello! > Here's one way. Echo to a temp file, then > read the file back into a string.
Cool! I have actually thought about using 'echo, but was curious if there was another way..... It will end up in a file eventually any way :>) thanks Doug!
> ;--start script--- > REBOL [
<<quoted lines omitted: 51>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.johnsons-web.com

 [4/4] from: dockimbel::free::fr at: 31-Jul-2001 12:06


Hi Tim, I think you'll find the following code usefull : --------------------------------------- REBOL [ Title: "Console capture" Author: "Nenad Rakocevic" Email: [dockimbel--free--fr] Date: 31-Jul-2001 File: %capture.r Version: 1.0.0 ] ctx-console-capture: context [ out: none sys-print: get in system/words 'print sys-prin: get in system/words 'prin set 'get-captured does [out] print-out: func [value][append out reform [reduce value newline]] prin-out: func [value][append out reform value] set 'capture func [flag [logic!]][ either flag [ out: make string! 1024 set 'print :print-out set 'prin :prin-out ][ set 'print :sys-print set 'prin :sys-prin ] ] ] ---------------------------------------
>> do %capture.r >> capture on >> help next >> capture off >> print get-captured
USAGE: NEXT series DESCRIPTION: Returns the series at its next position. NEXT is an action value. ARGUMENTS: series -- (Type: series port) HTH, DocKimbel. Tim Johnson wrote:

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted