| Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 | 1. New console window #10962 Posted by: Jeff Glatt 2007-07-11 18:17:42 Last edited by: Jeff Glatt 2007-07-31 06:40:49 (Total edited 9 times) | The newest version of Reginald (and RPC, and REXX GUI) feature a replaced console window.
With the new console, you can create as many console windows as you like.
One of the consoles is the "default console". This is the window that the SAY and PULL instructions operate upon. It is automatically opened whenever you do a SAY or PULL. For example:SAY "Enter your name:"
PULL NAME
SAY NAME You can open other consoles yourself by first issuing a LIBRARY statement for rxconsole, and then using the function ConCreate() to create a new console window, ConSay() to output to it, and ConPull() to enter text from it. The first arg to ConCreate() is the quoted name of some variable of your choosing. This is filled in with a handle to the new console window. You then pass this as the first arg to ConSay or ConPull. To close the window, you can call ConDestroy (although all console windows are automatically closed when your script ends).LIBRARY rxconsole
concreate('Console1',,'NODEFAULT', 10 , 10 )
concreate('Console2',,'NODEFAULT', 50, 50)
consay(console1, "This is console 1")
consay(console2, "This is console 2")
line = conpull(console2) The good news: When you click on the close box for a console window, it simply goes away. You don't get some dialog saying that the program isn't responding and asking to terminate it. If you close a console window that is waiting for a PULL, this raises the SYNTAX condition in your script (which terminates your script if you don't CATCH SYNTAX). When you close the last console window that you've opened, this also raises SYNTAX. (When using consoles in a REXX GUI script, HALT is instead raised, but only if all your other REXX GUI windows are closed too).
More good news: The new console windows play nice with REXX GUI. You can now use them in REXX GUI scripts.
Even better news. You can embed multiple console windows right inside of a REXX GUI window, just like a control. You can change text colors and font too. Here's an example.
NOTE: Click on the "Do PULL" button and type some text to see how to PULL text from the console. To see how the PULL color can be changed, click on the "Change PULL color" button before you press the ENTER key to finish PULL input. (Note: you'll have to click back into the console window to make it active again. Then you can press ENTER).
LIBRARY rexxgui, rxconsole
guierr = "SYNTAX"
guiheading = 1
backcolor = 1
textcolor = 1
pullcolor = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
guigetmsg()
CATCH SYNTAX
CONDITION()
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_initdialog:
guigetctlplacement(guiwindow, , , "width", "height")
guigetctlplacement('TextColor', "SayX", "SayY", "SayWidth", "SayHeight")
sayy = sayy + sayheight
height = height - sayy
concreate(, guiwindow, "CHILD", , sayy, width, height)
RETURN ""
wm_click_say1:
consay(, "Button 1 was clicked")
RETURN
wm_click_say2:
consay(, "Button 2 was clicked")
RETURN
wm_click_clear:
conclear()
RETURN
wm_click_textcolor:
textcolor = textcolor + 1
IF textcolor > 3 THEN textcolor = 1
SELECT textcolor
WHEN 1 THEN DO
red = 180
green = 40
blue = 40
END
WHEN 2 THEN DO
red = 40
green = 180
blue = 40
END
OTHERWISE DO
red = 40
green = 40
blue = 180
END
END
consetcolor(, , red, green, blue)
RETURN
wm_click_pullcolor:
pullcolor = pullcolor + 1
IF pullcolor > 3 THEN pullcolor = 1
SELECT pullcolor
WHEN 1 THEN DO
red = 180
green = 40
blue = 40
END
WHEN 2 THEN DO
red = 40
green = 180
blue = 40
END
OTHERWISE DO
red = 40
green = 40
blue = 180
END
END
consetcolor(, "PULL", red, green, blue)
RETURN
wm_click_backcolor:
guigetctlvalue('BackColor')
SELECT backcolor
WHEN 1 THEN str = "BLACK"
WHEN 2 THEN str = "WHITE"
WHEN 3 THEN str = "LIGHTGRAY"
WHEN 4 THEN str = "DARKGRAY"
OTHERWISE str = "GRAY"
END
consetcolor(, "BACK", str)
RETURN
wm_click_pull:
consay(, "Enter some text, then press ENTER")
text = conpull()
consay(, text)
RETURN
wm_click_pull1:
consay(, "Press a key")
text = conpull(, 1)
consay(, "You pressed the ", "NOBREAK")
consay(, text, "NOBREAK")
consay(, " key")
RETURN
wm_click_changefont:
consetfont(, "")
RETURN
wm_click_setfont:
consetfont(, "Courier New", 16, "BOLD")
RETURN About ConSay... if you want to suppress the line feed, you can pass a third arg of "NOBREAK". For example:consay(, "My name is ", "NOBREAK")
consay(, "Jeff ", "NOBREAK")
consay(, "Glatt") displays "My name is Jeff Glatt" on one line, and then ends the line. | 2. #11021 Posted by: PeterJ 2007-07-13 01:05:37 Last edited by: Jeff Glatt 2007-07-12 21:51:19 (Total edited 4 times) | I tried to attach 2 console windows into your example, by adding:width = width/2
concreate('X1', guiwindow, "CHILD", , sayy, width, height)
concreate('x2', guiwindow, "CHILD", , sayx+width, sayy, width, height) But I get the error message:concreate reports "default console already open" Is something wrong with my definitions, or is REXX GUI not supposed to have more than one console window? | 3. #11026 Posted by: Jeff Glatt 2007-07-13 05:46:13 Last edited by: Jeff Glatt 2007-07-31 06:42:22 (Total edited 3 times) | Yes, you made a mistake. In my example, I do create a default console (which can be printed to either by a SAY statement or a ConSay call, and can be PULL'ed from by either a PULL statement or a ConPull call).
But you can't create more than one of those. For all your other console windows, when you create them, you need to specify the "NODEFAULT" option to ConCreate. So your second call to ConCreate should be:concreate('x2', guiwindow, "CHILD | NODEFAULT", sayx+width, sayy, width, height) In fact, you can also specify "NODEFAULT" for the first console window too. What this means is that, if your script ever does a SAY or PULL instruction, then a third (default) console window will automatically pop open for that SAY/PULL. (In my example, SAY/PULL would instead go to that one console window). | 4. #11053 Posted by: PeterJ 2007-07-13 14:06:06 Last edited by: PeterJ 2007-07-26 04:43:00 (Total edited 2 times) | ... used Jeff's sample to add 4 concurrent consoles ;-)
Peter
vacation='08/08/07'
LIBRARY rexxgui, rxconsole
guierr = "SYNTAX"
guiheading = 1
backcolor = 1
textcolor = 1
pullcolor = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
SAY guigetmsg()
CATCH SYNTAX
CONDITION()
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_initdialog:
guigetctlplacement(guiwindow, , , "width", "height")
guigetctlplacement('TextColor', "SayX", "SayY", "SayWidth", "SayHeight")
sayy = sayy + sayheight
height = height - sayy
sayy=sayy+5
sayx=sayx
width=(width)%2-10
height=(height-20)%2
concreate('X1', guiwindow, "CHILD | NODEFAULT", sayx,sayy, width, height)
concreate('x2', guiwindow, "CHILD | NODEFAULT", sayx+width+7, sayy, width, height)
concreate('X3', guiwindow, "CHILD | NODEFAULT", sayx,sayy+height+9, width, height)
concreate('x4', guiwindow, "CHILD | NODEFAULT", sayx+width+7, sayy+height+9, width, height)
counter=0
consay(x1,'Waiting for end of working day')
consay(x2,'Waiting for the weekend')
consay(x3,'Waiting for vacation')
consay(x4,'Waiting for Santa Claus')
ERROR = guiaddctl("TIMER 700")
RETURN ""
wm_click_say1:
consay(x1, "Button 1 was clicked")
RETURN
wm_click_say2:
consay(x2, "Button 2 was clicked")
RETURN
wm_click_clear:
conclear(x1)
conclear(x2)
conclear(x3)
conclear(x4)
RETURN
wm_click_textcolor:
textcolor = textcolor + 1
IF textcolor > 3 THEN textcolor = 1
SELECT textcolor
WHEN 1 THEN DO
red = 180
green = 40
blue = 40
END
WHEN 2 THEN DO
red = 40
green = 180
blue = 40
END
OTHERWISE DO
red = 40
green = 40
blue = 180
END
END
consetcolor(x1, , red, green, blue)
consetcolor(x2, , red, green, blue)
consetcolor(x3, , red, green, blue)
consetcolor(x4, , red, green, blue)
RETURN
wm_click_pullcolor:
pullcolor = pullcolor + 1
IF pullcolor > 3 THEN pullcolor = 1
SELECT pullcolor
WHEN 1 THEN DO
red = 180
green = 40
blue = 40
END
WHEN 2 THEN DO
red = 40
green = 180
blue = 40
END
OTHERWISE DO
red = 40
green = 40
blue = 180
END
END
consetcolor(x1, "PULL", red, green, blue)
consetcolor(x2, "PULL", red, green, blue)
consetcolor(x3, "PULL", red, green, blue)
consetcolor(x4, "PULL", red, green, blue)
RETURN
wm_click_backcolor:
guigetctlvalue('BackColor')
SELECT backcolor
WHEN 1 THEN str = "BLACK"
WHEN 2 THEN str = "WHITE"
WHEN 3 THEN str = "LIGHTGRAY"
WHEN 4 THEN str = "DARKGRAY"
OTHERWISE str = "GRAY"
END
consetcolor(x1, "BACK", str)
consetcolor(x2, "BACK", str)
consetcolor(x3, "BACK", str)
consetcolor(x4, "BACK", str)
RETURN
wm_click_pull:
ERROR = guiremovectl()
consay(x1, "Enter some text, then press ENTER")
text = conpull(x1)
consay(x1, text)
ERROR = guiaddctl("TIMER 2500")
RETURN
wm_click_changefont:
consetfont(x1, "")
consetfont(x2, "")
consetfont(x3, "")
consetfont(x4, "")
RETURN
wm_click_setfont:
consetfont(x1, "Courier New", 16, "BOLD")
consetfont(x2, "Courier New", 16, "BOLD")
consetfont(x3, "Courier New", 16, "BOLD")
consetfont(x4, "Courier New", 16, "BOLD")
RETURN
wm_timer:
inst=counter//4
SELECT inst
WHEN 0 THEN consay(x1,time2go('18:00') 'hours')
WHEN 1 THEN consay(x2,days2go(nextwday('SATURDAY'),,'FULL'))
WHEN 2 THEN consay(x3,days2go(vacation,,'FULL'))
WHEN 3 THEN consay(x4,days2go('24/12/07',,'FULL'))
END
counter=counter+1
RETURN ""
nextwday:procedure
PARSE ARG wd,idate
wd=TRANSLATE(wd)
IF idate='' THEN idate=DATE('E')
PARSE VALUE idate WITH dd '/' mm '/' yy
yy=RIGHT(yy,2,0)
mm=RIGHT(mm,2,0)
dd=RIGHT(dd,2,0)
idate=dd||'/'||mm||'/'||yy
idate=DATE('B',idate,'E')
DO bdate=idate TO idate+7
wdate=TRANSLATE(DATE('W',bdate,'B'))
IF wdate=wd THEN LEAVE
END
IF wdate \= wd THEN RETURN '??'
RETURN DATE('E',bdate,'B')
days2go:procedure
PARSE ARG todate,cdate,mode
IF mode='' THEN mode='DAYS'
ndate2=DATE('B',todate,'E')
IF cdate='' THEN ndate=DATE('B')
ELSE ndate=DATE('B',cdate,'E')
days=ndate2-ndate
IF mode='DAYS' THEN RETURN days
days=days-1
ctime=time2go()
RETURN days||' days '||ctime||' hours'
time2go: PROCEDURE
PARSE ARG totime,fromtime
IF totime='' THEN totime='24:00:00'
ELSE totime=totime||':00:00'
PARSE VALUE totime WITH hh ':' mm ':' ss ':' remainder
tt=hh*3600+mm*60+ss
IF fromtime='' THEN fromtime=TIME('N')
ELSE fromtime=fromtime||':00:00'
PARSE VALUE fromtime WITH hh ':' mm ':' ss ':' remainder
ft=hh*3600+mm*60+ss
tt=tt-ft
hh=RIGHT(tt%3600,2,0)
tt=tt-hh*3600
mm=RIGHT(tt%60,2,0)
tt=RIGHT(tt-mm*60,2,0)
RETURN hh||':'||mm||':'||tt
| 5. Console and guigetctlplacement #11294 Posted by: Michael S 2007-07-29 22:06:38 Last edited by: Jeff Glatt 2007-07-31 06:43:56 (Total edited 1 time) | Can I use a console handle with REXX GUI's GuiGetCtlPlacement to resize and reposition the window? | 6. Is this a permanent restriction for consoles ..... #11296 Posted by: Michael S 2007-07-29 22:30:36 Last edited by: Michael S 2007-07-29 22:32:58 (Total edited 1 time) | If you try and do a consay of 50 bytes, and the 10th one is hex 00, then bytes 11 onwards are never shown | 7. #11298 Posted by: Jeff Glatt 2007-07-29 22:49:08 Last edited by: Jeff Glatt 2007-07-29 22:51:58 (Total edited 1 time) | Right. Console windows do not display non-printable characters, and 00 has a special "end of line" meaning to many Windows text functions.
Moral of the story: Don't bother trying to display non-printable output to a console window. That output is meaningless. Reformat it as some sort of text output. | 8. #11304 Posted by: mestrini 2007-07-30 00:12:44 Last edited by: Jeff Glatt 2007-07-30 05:30:15 (Total edited 2 times) | Yep. That happened a lot to me while i handle a lot with binary files. Even ENTRY control treated as an output (text) window behaves the same. | 9. #11321 | Try the latest Reginald, and this:
LIBRARY rexxgui, rxconsole
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')
concreate('console', guiwindow, "CHILD | NODEFAULT", 20, 80, 350, 100)
again:
DO FOREVER
guigetmsg()
CATCH SYNTAX
CONDITION()
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_click_console_button:
guisetctlplacement(coninfo(console, 'HANDLE'), 20, 80, 450, 200)
RETURN | 10. #11488 Posted by: DougA 2007-08-15 05:07:58 Last edited by: Jeff Glatt 2007-09-08 15:00:13 (Total edited 3 times) | The console window doesn't display lines as they are SAY'ed to it, but instead waits until my main script returns to its message loop. Why? Doug | 11. #11491 | When using REXX GUI, then the window isn't updated until you do a PULL, or a call to GuiGetMsg(). That should happen fairly quickly. | 12. #11501 Posted by: DougA 2007-08-15 20:47:23 Last edited by: Jeff Glatt 2007-09-08 15:02:12 (Total edited 2 times) | I have a program that reads a large file, this takes awhile, so I display a "start" message on console. I want this to show up right away. Then, I have a search process that likewise takes a noticable time (20 sec or so). Again, i post a start, as well as some tracks, debug info, etc on the console so i can follow the action. But nothing is displayed until the process finishes. Doug | 13. #11506 Posted by: Jeff Glatt 2007-08-16 01:23:53 Last edited by: Jeff Glatt 2007-08-16 01:25:44 (Total edited 1 time) | You get the listbox, or console window, to update with a call:guigetmsg("CLEAR") But in this case, at the start of your operation, you should disable your window containing the console, and other open GUI windows, so that some event handler isn't called during this. Then re-enable things after you're done with your operation.
Ideally, when a multi-threaded version of Reginald is done, you'll do these lengthy operations from a secondary thread, and this call won't be needed. (But the disable/enable stuff will be). | Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
|
|