View result of formula, field or variable in procedure editor


#1

I recall being able to select a portion of text in the procedure editor and, I think, press cmd 2 to view the result of a formula, field or variable in the bottom bar of the window.

Is there another way to do this now?

Thanks,
Jeff


#2

I don’t think you can do it in the procedure window, but you can copy your highlighted formula, and paste it into the Formula Workshop.


#3

I don’t recall any Command-2 to view results in the status bar. You can put a statusmessage statement in your code to display a result in the status bar as the program runs, and that is still possible.

In addition to just copy and pasting into the Formula Workshop as Dave suggested, you can also select a formula, then right click and choose Help>Formula Workshop, see Programming Context Menu on this page.

A nice enhancement of the Formula Workshop in Panorama X is that you can open as many as you want, to look at multiple values at the same time.


#4

It’s on the Debug menu in Panorama 6.

44%20PM


#5

You’re right, I completely forgot about that. And I can’t find it in the documentation anywhere. Anyway, Panorama X doesn’t have that, and it doesn’t have the Inspector either.


#6

I learned about it by reading his question.


#7

Congratulations Jeff, I think you win “Stump the Experts”!! :grinning:


#8

Ha! : )

I was thinking I could define a global hotkey but it looked like it would have to go in every procedure to work? Is that correct? If it would work, the below procedure would need to check to see if anything was selected.

Jeff

definehotkeys “Global”, “COMMAND-2”, |||local clipboardSave,statusFormula,test
test=“checking”
clipboardSave=clipboard()
copy
statusFormula=clipboard()
clipboard()=clipboardSave
statusmessage statusFormula|||


#9

No, you just have to run the procedure once, then it will work in any window in any database (until you quit Panorama, when you relaunch you’ll have to run it again).

Unfortunately, I just did a test and the statusmessage doesn’t work in a procedure window. If it did work, this is the code you would use:

definehotkeys “Global”, “COMMAND-2”, |||

let selectedSource = info("procedureselectedtext")
let theValue = formulavalue("",selectedSource)
statusmessage selectedSource

|||

Since statusmessage doesn’t work in this situation, you could replace it with message or nsnotify.

Also, keep in mind that this will NOT work if the formula you have selected contains local variables, or windowglobal variables. I’m afraid there is currently no way to get it to work in this situation.

I’ve made a note in the issue tracker to somedqy modify statusmessage so that this can be done.


#10

This would be something that might be implemented as a Service. Jim has said that he does not use Services, but I find CalcService and WordService from Devon Technologies useful with Panorama X. They are both available for free through the App Store.

Also, New BBEdit Document with Selection (or TextEdit Window) is useful. Those could be a model for Panorama X: New Formula Workshop Window from Selection. Since Services are across applications, we could use both these to assist in writing a procedure in BBEdit before pasting it into Panorama.


#11

While we are also on the subject of the Formula Workshop, here is a feature request.

I had modified my Pan 6 Formula Wizard so I could select a portion of the formula, click a button, and see the result of that portion instead of the whole formula.

This was super handy for debugging a complex formula.


#12

Since you can open multiple Formula Workshop windows already, you can basically do that now. Just select and copy the portion of the formula you are interested, click the green arrow to open a second workshop window, then paste.


#13

Here is a very simple suggestion for an improvement for the Formula Workshop. Simply turn on the Rich Text option for the Result Text Display Object. This way you can experiment with all the Rich Text features right in the Formula Workshop.


#14

I’m not super enthusiastic about this idea. In general, rich text is used with Text Display objects, and you can easily enable the rich text object and play with rich text right within the graphical editor. I don’t really see what extra the Formula Workshop would bring to the table. This suggestion wouldn’t be super difficult to implement, but it would be a bit more complex than the other display options since it would involve changing the graphical form object in the wizard, rather than just tweaking the formula. (Though maybe it could be done with the textdisplay( function, instead of enabling the Rich Text option in the object.)

Anyway, I think I need some extra convincing before I say yes on this one.


#15

Ok, I can see that having the Rich Text option turned on all the time might cause problems in some situations. I just altered my copy of the Formula Workshop so that the Format button in the Results bar now includes a “RichText” item. I then added this code to the Evaluate procedure:

elseif resultFormat match "RichText"
    theWizardFormulaResult=richtextdisplay(chr(1)+theWizardFormulaResult)

I know, what the heck is the chr(1) doing in the richtextdisplay? Well, if the text formula begins with a tag then that color will be retained for any future text when you turn the RichText Format item off. If you put any character in front of the tag this will not happen. I tested this bug in another Text Display Object and got the same results. The first color is retained even if there are other color changes later in the text as long as that tag is at the very beginning of the text. Here is my test Text Display Object with the procedure to change the variable in the formula panel depending on whether the TDO is clicked with the option modifier or not.

image

This is the action from alternate clicks with and without the option modifier. If I add the chr(1) character at the beginning of the richtextdisplay formula it will alternate properly between red and black as expected.

RichText%20Bug

Anyway, I’m not about to proselytize this any further and am happy with the simple alteration I made to my Formula Worksop copy and will most likely include it myself in any future Pan X versions.


#16

Hi Jim,

Just saying, if there is any way to add the Cmd 2 feature back in Panorama X, it would be so helpful!

It’s super fast for debugging and checking results and formulas while programming, compared to opening the formula workshop or copy/pasting to it if it’s open.

I definitely miss the feature.

Jeff


#17

It looks like it would not be too difficult to do as I suggested, as a Service, but I am too busy with other things to work on it myself. But if someone could write an Applescript to input text into the Formula Workshop, it could be done in Automator, according to this article:
https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/MakeaSystem-WideService.html

As I said, the advantage would be that not only would it work in Panorama, it would work in any text editor.