Debugging pause

Discussion in 'Rebol' started by swhite, Aug 8, 2012.

  1. swhite

    swhite Member

    Using an idea I found somewhere, possibly here, I have made a little function that I can use to break out of program logic to enter a primitive "debugging mode" where I can enter REBOL commands to examine the internal items of a program. When used in a view program, the debugging module opens a console window where I enter the debugging commands. It works well.

    The question is, if I use this debugging pause in a view program to open a console window, I would like to be able to close the console window ONLY and resume normal operations. As it is now, when I resume normal operations, the console window remains. If I try to close the console window, the main window closes also. This is not a big problem since I can minimize it, but I thought it might be a nice touch to close the console window completely. Does anyone know if there is a command to do this?

    Thank you. Demo script follows.

    REBOL [
    ]

    ;; Accept a REBOL command from a console window and try to run it.
    ;; If the command entered is empty (just the "enter" key was pressed),
    ;; then exit the function.

    GLB-PAUSE: func [GLB-PAUSE-PROMPT /local GLB-PAUSE-INPUT][
    GLB-PAUSE-INPUT: "none"
    while ["" <> trim/lines GLB-PAUSE-INPUT][
    GLB-PAUSE-INPUT: ask join GLB-PAUSE-PROMPT " >> "
    attempt [probe do GLB-PAUSE-INPUT]
    ]
    ]

    ;; Here are some data items we could display in the debugging window.

    DATA-ITEM-1: "Test string 1"
    DATA-ITEM-2: now

    ;; Here is a basic window with a button to activate the debugging pause.

    view layout [
    across
    vh1 "Test of the debugging pause"
    return
    button "Debug" [GLB-PAUSE "Enter debugging command"]
    button "Quit" [quit]
    ]
  2. Graham

    Graham Developer Staff Member

    You will need to open a view window, and interpret each line. A console is linked to the app and can't be closed without closing the main app.
  3. MaxV

    MaxV Member

    I believe that the best solution is the following:
    • the script to test is read line by line
    • the script is launched from the beginning to line 1
    • wait enter
    • the script is launched from the beginning to line 2
    • wait enter
    • the script is launched from the beginning to line 3
    • wait enter
    • and so on ...
    You can create a separate window that shows all variables values.

Share This Page