From: Jeff H. <Je...@Je...> - 2023-02-12 20:56:02
|
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p>René,</p> <p>Yep,</p> <p>I get it to work with the stage name <b>AHELP</b>, which in CMS is an almost alias for <b>HELP</b>. <br> </p> <p>I tried to make a HELP class that extends AHELP, but it gives the same error. I then removed all "help.*" files from both <b>src</b> and <b>build</b> directories then rebuilt. Only to get the same error. It seems there must be a <b>help</b> class somewhere else in Java/NetRexx.</p> <p>A solution (?) might be to have the <b>AHELP</b> as a standard stage class and in the pipeline scheduler make a stage alias for <b>HELP</b>, like we do for <b>></b>.</p> <p>While I'd like to be able to use a DISPLAY stage for all the fancy HTML stuff, for now I'll go for plain text via SAY. And continue working in that direction.</p> <p>Thanks for all your help.</p> <p>Jeff<br> </p> <div class="moz-cite-prefix">On 2/12/2023 10:45 AM, René Jansen wrote:<br> </div> <blockquote type="cite" cite="mid:629...@xs..."> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> Hi Jeff, <div><br> </div> <div>I checked in a working help stage.<br> <div><br> </div> <div>My conjecture: somehow we confused the compiler by naming both the class 'help' and the method 'help'. The latter returns a type Rexx.</div> <div>My first reflex was to call your class 'helo' and then it works when starting a </div> <div><br> </div> <div>pipe "helo crc | cons"</div> <div><br> </div> <div>but because 'helo' is not a good name for a help stage, I renamed it back, and changed the help() method on class stage and class crc to 'giveHelp'.</div> <div><br> </div> <div>Somehow someone took a shortcut somewhere. Line 50 must be from the generated stage source. Do we accept this or do we open an issue to go to the bottom?</div> <div><br> </div> <div>best regards,</div> <div><br> </div> <div>René.</div> <div><br> </div> <div><br> </div> <div><br> <div><br> <blockquote type="cite"> <div>On 12 Feb 2023, at 14:31, Jeff Hennick <a class="moz-txt-link-rfc2396E" href="mailto:Je...@Je..."><Je...@Je...></a> wrote:</div> <br class="Apple-interchange-newline"> <div> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <div> <p>René,</p> <p>Thank you.</p> <p>At the moment, I am still pursuing the previous way, but running into a problem.</p> <p>Your code worked for me. ONCE. Now it doesn't, in a way I do not understand.</p> <p>First, there were some exceptions that needed attention. These I now CATCH.</p> <p>So here first is my code, then the results.</p> <blockquote> <p><font face="monospace">-- help.nrx NJPipe Stage<br> /*<br> * Copyright (C) 2023 Jeffrey Hennick, Jeff @ Jeff-H . com<br> * Distributed under the ICU 1.8.1 License with NO WARRANTIES of ANY kind.<br> * See LICENSE for the license and information on using, copying, modifying,<br> * and distributing this program.<br> */<br> /*<br> */<br> <br> options nostrictcase nostrictargs nostrictsignal<br> package org.netrexx.njpipes.stages<br> <br> import org.netrexx.njpipes.pipes.<br> <br> class help extends stage binary</font></p> <p><font face="monospace">trace results</font></p> <p><font face="monospace">method run()<br> <br> parse arg() stage_to_help .<br> if stage_to_help = '' then<br> say "Usage: HELP stage_name."<br> else if stage_to_help = 'HELP' then<br> say helphelp()<br> else do<br> stageClass = class.forName('org.netrexx.njpipes.stages.'stage_to_help)<br> helpMethod = stageClass.getMethod('help',null)<br> say helpMethod.invoke(stageClass,null)<br> catch java.lang.ClassNotFoundException<br> Emsg(11, "Stage" stage_to_help "was not found.")<br> catch java.lang.NoSuchMethodException<br> Emsg(11, "No Help was found for Stage" stage_to_help".")<br> catch java.lang.IllegalAccessException<br> Emsg(11, "Illegal Access.")<br> catch java.lang.reflect.InvocationTargetException<br> Emsg(11, "Reflection Invocation Target Error.")<br> end<br> <br> loop forever<br> aobj = peekto()<br> output(aobj)<br> readto()<br> catch StageError<br> end<br> <br> rc = mrc()<br> exit(rc*(rc<>12))<br> <br> method helphelp() static<br> return -<br> "/** help\n" -<br> " \n" -<br> " >>--+-HELP--+--------+----------------------->< \n" -<br> " | +-string-+ \n" -<br> " \n" -<br> "*/\n"<br> <br> </font><br> </p> </blockquote> <div style="display:inline-block;white-space:pre;background-color:#012456;font-family:'Cascadia Code',monospace;font-size:10pt;padding:4px;"><span style="color:#D3D7CF;background-color:#012456;">PS C:\Users\Jeff\Documents\nr\netrexx-code\examples\pipes> </span><span style="color:#FCE94F;background-color:#012456;">pipe </span><span style="color:#D3D7CF;background-color:#012456;">"help find" 50 +++ _s_1 = help() +++ ^^^^ +++ Error: Cannot convert value of type 'netrexx.lang.Rexx' for assignment t o variable of type 'org.netrexx.njpipes.pipes.stage' NetRexx portable processor 4.05-beta build 1,005-20230212-0754 Copyright (c) RexxLA, 2011,2023. All rights reserved. Parts Copyright (c) IBM Corporation, 1995,2008. Program pebe3cec === class pebe3cec === constructor pebe3cec(Object) overrides pipe() method reset function get(Object) method setup(Object) 50 +++ _s_1 = help() +++ ^^^^ +++ Error: Cannot convert value of type 'netrexx.lang.Rexx' for assignment t o variable of type 'org.netrexx.njpipes.pipes.stage' method config method setup2 method run signals ThreadQ overrides stage.run function main(String[]) signals ThreadQ Compilation of 'pebe3cec' failed [one error] Compilation failed. PS C:\Users\Jeff\Documents\nr\netrexx-code\examples\pipes></span></div> <p> I don't know where the line "50" is. My 50 is a blank line, but the error message stays the same when I added blank lines above it.</p> <p>It does not matter what stage name I ask for the help.<br> </p> <p>Trying from the "raw" PowerShell prompt or in NRWS; with and without quote marks, has made no difference.</p> <p>Thanks for any insight.</p> <p>Jeff<br> </p> <div class="moz-cite-prefix">On 2/11/2023 8:13 AM, René Jansen wrote:<br> </div> <blockquote type="cite" cite="mid:1E0...@xs..."> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> rerouted answer to pipelines list: <div><br> </div> <div>Jeff,</div> <div><br> </div> <div>we have an INSIDE stage, so I would skip all quoting and continuing and pick the right lines out of a file with INSIDE - then you can use the class-level help() to call super.help(stage) and have that deliver the lines.</div> <div>(In there we can test the terminal for graphic ability and deliver the optimal graphics - more than one terminal can do SVG nowadays).</div> <div><br> </div> <div>best regards,</div> <div><br> </div> <div>René.<br> <div><br> <blockquote type="cite"> <div>On 11 Feb 2023, at 13:34, Jeffrey Hennick <a class="moz-txt-link-rfc2396E" href="mailto:Je...@Je..." moz-do-not-send="true"><Je...@Je...></a> wrote:</div> <br class="Apple-interchange-newline"> <div> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <div> <p>Looks great. I'll explore it more later today. Then get to the stage files. Most of them have the railroad diagram in a comment, so it means moving that to the new help() method. I do wish NetRexx had a multi-line quote for this, but adding quote marks and a continuation character to each line should do the trick. (The <b>help</b> stage will need some special work so this method is not taken as a constructor.)<br> </p> <p>Thanks!</p> <p>Jeff<br> </p> <div class="moz-cite-prefix">On 2/10/2023 4:50 PM, <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:rvj...@xs..." moz-do-not-send="true">rvj...@xs...</a> wrote:<br> </div> <blockquote type="cite" cite="mid:AEA...@xs..."> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> And you should use getMethod instead of getDeclaredMethod if you want to inherit the help() from stage - the superclass, for stages that don't have helping yet: <div><br> </div> <div> <div><font face="Courier New">parse arg stage_to_help</font></div> <div><font face="Courier New">stageClass = class.forName('org.netrexx.njpipes.stages.'stage_to_help)</font></div> <div><font face="Courier New">helpMethod = stageClass.getMethod('help',null)</font></div> <div><font face="Courier New">say helpMethod.invoke(stageClass,null)</font></div> <div><br> </div> <div>best regards,</div> <div><br> </div> <div>René.<br> <blockquote type="cite"> <div>On 10 Feb 2023, at 22:43, <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:rvj...@xs..." moz-do-not-send="true">rvj...@xs...</a> wrote:</div> <br class="Apple-interchange-newline"> <div> <meta charset="UTF-8"> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">Hi Jeff,</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">I think this is the best solution for the moment: We know that the stages package is available. We can load the stage class with the Java Reflection API, and then call (invoke) the help() method on it:</span> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New">➜ test git:(master) ✗ cat loadhelp.nrx</font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New">parse arg stage_to_help</font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New">stageClass = class.forName('org.netrexx.njpipes.stages.'stage_to_help)</font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New">helpMethod = stageClass.getDeclaredMethod('help',null)</font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New">say helpMethod.invoke(stageClass,null)</font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New"><br> </font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New">➜ test git:(master) ✗ java loadhelp crc</font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><font face="Courier New">The CRC stage computes a CRC-32 checksum over its input.</font></div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">So you pass in the (short) stage name, complete its name in the class.forName method, which leave a Class object in variable stageClass. We ask that Class object to return the help() method in the variable helpMethod. On that, we invoke it with no parameters, it returns the help message from the static help() method.</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">best regards,</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">René.<br> <div> <div><br> <blockquote type="cite"> <div>On 10 Feb 2023, at 16:14, <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:rvj...@xs..." moz-do-not-send="true">rvj...@xs...</a> wrote:</div> <br class="Apple-interchange-newline"> <div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">and with that I mean the example below-below. </span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> <blockquote type="cite"> <div>On 10 Feb 2023, at 16:08, <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:rvj...@xs..." moz-do-not-send="true">rvj...@xs...</a> wrote:</div> <br class="Apple-interchange-newline"> <div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Hi Jeff,</span> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">I added a static help() method to pipes.stage . I also did override that method on the new crc stage; this just to show.</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">Now about enumeration of the stages: we have several approaches. We could, at NetRexx build time, enumerate all the built-in stages into a structure. That might be the most efficient and straigtforward way. We could also do that dynamically; if the compiler can do it, we also could. This might be more involved and would take slightly longer.</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">The example below does not work because you need to instantiate the stage before you can call methods on it.</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-inden... [truncated message content] |