Help asked: systemRPL ^IFMain question
|
01-27-2016, 09:51 PM
Post: #1
|
|||
|
|||
Help asked: systemRPL ^IFMain question
Hi,
This my first post on this forum, sorry for starting with a rather detailed technical question for help. I hope this is the proper place to ask. I am working on a simple systemRPL program for the 50g with an InformBox as a UI. The program works fine but I want to improve usability. What I want to achieve is this: I have defined a custom menu key to perform a calculation with (the content of) input Fields on the form. How things currently work is that if I enter a value in an input field, I push 'ENTER' to close the edit-line and move the new value to the Field, then I push the custom menu key (F6 in this case) to perform the computation and show the result. This is standard behavior. What I would like to do is to include the 'ENTER' behavior in the KeyProcNS of my custom menu key. So there would be no separate 'ENTER' required, this would be handled by the custom key implicitly. The desired result is that after keying a new value of the input field, pushing F6 would do two things: enter the value into the input field and close the command line, then perform the computation, all in one F6 keystroke. I hope this description of what I want to do is clear. I read the books on systemRPL by Donnelly, by Malinowski and Dominic, and RPLMan. I find the documentation on ^IfMain quite limited in these publications and haven't found a clue on how to achieve what I want. I use Debug4x. Any help is greatly appreciated. |
|||
02-02-2016, 08:19 PM
(This post was last modified: 02-02-2016 08:21 PM by wojtek.)
Post: #2
|
|||
|
|||
RE: Help asked: systemRPL ^IFMain question
Nobody will know how to help you until you provide a sample of the code you've written
|
|||
02-03-2016, 09:23 AM
(This post was last modified: 02-03-2016 09:27 AM by brrm.)
Post: #3
|
|||
|
|||
RE: Help asked: systemRPL ^IFMain question
(02-02-2016 08:19 PM)wojtek Wrote: Nobody will know how to help you until you provide a sample of the code you've written Thanks. Here's the code of the message handler. Code:
This works, except that following the IfEnterKeyPress, the current field is not updated with the contents of the edit line, so that the previous value of that field is used in the computation. Only after a second keypress the calculation is performed with all the correct values. I am looking forward to any info on how to solve this. |
|||
02-04-2016, 01:58 AM
Post: #4
|
|||
|
|||
RE: Help asked: systemRPL ^IFMain question
(02-03-2016 09:23 AM)brrm Wrote: I am looking forward to any info on how to solve this. Thanks for posting your code snippet, it helped to better understand what you are attempting to do. It appears to me that you may be running into trouble by making the call to ^IfEnterKeyPress in an effort to simulate the ENTER key while an EditLine is active. I believe that procedure was designed more for other situations where you might want to do some of your own processing as a result of responding to a message, then simulating the effect of the user pressing the enter key. There's a subtle difference in context here. The following may work better for you: Immediately after the TakeOver in your menu routine, test for the presence of an active EditLine and take care of storing the current value if there is one. Then proceed with your calculations as needed. Here's a sample of what that might look like (with absolutely no error checking!): Code: TakeOver This assumes, of course, that I've understood what you're trying to accomplish. I may have misunderstood your intent. If it helps to see a more complete example, here's the generated source code from an InputForm built using Debug4x. This is about as simple an example as I could think of to show how the code might work. In this case, the "SUM" menu command simply adds the three values in fields 1-3 and places the total into field 4. I'm hoping this works the way you want: Code: ( Inform Box File ) ( Inline Text ) ( Do not modify this line ) Hope this helps! - David |
|||
02-04-2016, 09:16 PM
(This post was last modified: 02-04-2016 09:41 PM by brrm.)
Post: #5
|
|||
|
|||
RE: Help asked: systemRPL ^IFMain question
(02-04-2016 01:58 AM)DavidM Wrote: Hope this helps! It certainly does! Thank you very much! When I worked on it I ran into another problem. When I use your code, it works as desired, but ONLY if I enter the decimal separator to force a real (i.e. type '7.' followed by <SUM>) it gives the correct answer. If I omit the separator (i.e. type '7' followed by <SUM>) then the result is garbage. I was able to fix this with CK&DISPATCH1. The final source code is: Code: ' :: Regards bram |
|||
02-04-2016, 11:38 PM
Post: #6
|
|||
|
|||
RE: Help asked: systemRPL ^IFMain question
(02-04-2016 09:16 PM)brrm Wrote: When I worked on it I ran into another problem. CK&DISPATCH1 will do the conversion (as will CKREAL), but it also sets some other things that aren't desirable at the point in your code (protection word comes to mind). When I mentioned before that there was no error checking, this is part of what I was alluding to. Storing the value in the field in this manner bypasses the normal validation that IfMain does to make sure that the object is an acceptable type. It may be a better approach to use the IfCheckFieldtype function that is part of the InputForm API. While I haven't tried all possible combinations of objects and field types, it did at least appear to convert a ZINT to a REAL automatically in this situation. It also returns a boolean that allows you to branch accordingly if the type wasn't acceptable. When I was playing around with this earlier today, it seems that there's some fragility with this method of obtaining the data directly from the command line. I'm not sure, but I suspect that this comes from having several stacked "environments" active simultaneously. I tried the following code for the form's message handler and found that it was reasonably effective: Code: ' :: One of the potential problems that can occur is if the command line contains a string which will compile into multiple objects (ie. "123A" becomes % 123 and 'A' ). Things get a bit messier for that kind of scenario. Whatever you end up with, you'll want to run through a variety of scenarios to make sure it works the way you want. |
|||
02-09-2016, 11:37 AM
Post: #7
|
|||
|
|||
RE: Help asked: systemRPL ^IFMain question
(02-04-2016 11:38 PM)DavidM Wrote: ... Thanks for your reply. Over the weekend I have tested my code (based on CK&DISPATCH1) thoroughly with all kinds of wrong input in the edit line. It is all handled correctly, I haven't yet found any undesired side-effects. |
|||
02-09-2016, 02:33 PM
Post: #8
|
|||
|
|||
RE: Help asked: systemRPL ^IFMain question
(02-09-2016 11:37 AM)brrm Wrote: Thanks for your reply. Over the weekend I have tested my code (based on CK&DISPATCH1) thoroughly with all kinds of wrong input in the edit line. ...and that's what it's all about! Glad you got it working the way you wanted. I went back and re-read the documentation for CK&DISPATCH1 and noticed that it doesn't set the protection word like the CKx and CKxNOLASTWD commands. So the only potential problem I was thinking of shouldn't even come up. Glad to see that there are still some folks plugging away at SysRPL! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)