Pan X not ready for me yet

Replace( works just fine. There must be more to your situation that is causing the issue.

Panorama X cannot accept it as a valid statement, because it is a function. And this function works pretty well when you combine it with a formula fill statement e.g.:
formulafill replace(«»,chr(13),chr(11))

Again: replace( is NO statement.

Your screenshot contains 4 formulas, but there is not any statement that would select a field and would apply those formulas to that field.

I am not saying replace( is a statement; Panorama X is.

Whether there is anything that selects a field or not is irrelevant. It should work on the current field. But it does not get that far.

If there is someplace in the Panorama documentation that says that replace( is a statement, that definitely needs to be corrected. However, I cannot find any text that says that. Certainly the main page for replace( is clear:

It’s always been the case that ANY keyword that ends with ( is a function, not a statement. Functions can be used in formulas, they cannot be used as standalone steps in a procedure. Here is your procedure in Panorama 6 – it doesn’t work there either.

Personally I think the Panorama X error message is better, but it could recognize that the keyword is a function and give an even better error message, I suppose. At least Panorama X correctly identifies the spot of the error, which is a definite improvement.

I think the correct code for what you are trying to do is this, which will work in both Panorama 6 and Panorama X.

«» = replace(«», "Early", "4:30")
«» = replace(«», "Second", "5:45")
«» = replace(«», "Very Late", "8"15")
«» = replace(«», "Late", "7:00")

The question of statements vs. functions, and where they can be used, has tripped up more than one Panorama user over the years. I’ve taken another crack at explaining this in the new Panorama X documentation. This page hasn’t been released in the Help wizard yet but it is already available on line:

The relevant section is Statements vs. Functions, which I have included below. Please note that everything stated in this section is applicable to both Panorama 6 and Panorama X.


Statements vs. Functions

In some programming languages, all actions are functions that can return a value and be used in formulas. In Panorama, however, statements and functions are distinct. In Panorama, a statement performs an action. A function, on the other hand, returns a value. You can’t use a function where Panorama is expecting a statement, and you can’t use a statement in a formula, where Panorama needs a value.

To illustrate this, consider the message statement.

message "Warning, negative balance"

When used in a program, this statement displays an alert, like this.

But since message is a statement, not a function, it doesn’t return a value and you cannot use it in a formula. So this code will not work:

x = message "Warning, negative balance"

and neither will this:

x = message("Warning, negative balance")

On the other hand, consider the sqr( function, which calculates a square root. Since this is a function and returns a value, it’s perfectly fine to use it in a formula, for example with this assignment.

x = sqr(7)

But the sqr( function cannot be used by itself. It’s not an action, so Panorama doesn’t know what to do with this:

sqr(7)

The basic rule is, if a keyword ends with a (, it’s a function and returns a value, and can be used in formulas. If a keyword doesn’t end with a (, it’s a statement and it performs an action.

I know the difference between a function and a statement. But the error message in the screenshot says Unknown statement: replace(

What I was trying to do was to write a replacement for a procedure in Panorama 6 which Panorama X does not like:

Change “Early” “4:30”…

I expected that it may not work as I wrote it, but the error message throws me.

I know that you do not like the Change statement, but it is quick and easy to remember.

Panorama gives this message because, if the first word in a valid line of code is not a field name or a variable, it must be a statement name (that may be a simplistic summation but you get the idea). In your code, replace( is neither a field nor a variable so Panorama assumes you are using it as a statement name which it isn’t. Your comment, “I am not saying replace( is a statement; Panorama X is.”, is wrong - Panorama doesn’t think replace( is a statement, it thinks that you think it is and it’s correcting that view. You would get the same type of message if you typed arraysot old,new,sep when you meant to use the arraysort statement.

Your original code used a statement, change, which has not been carried over to Panorama X. There is no exactly matching statement, so you have to write the code differently. If you choose to use the replace( function, you must use it properly.

Jim acknowledges that the message could have been more explicit. It would be great if we got messages like “In line 456 of the procedure , you’ve used a function where you perhaps meant to use a statement.” but Panorama 6 wouldn’t be out of beta yet, and Panorama X would be less that a twinkle in Jim’s eye, if that was a universal objective.

Before I blame Jim or Panorama X for an anomaly, I look for a user error (well, almost always).

Further, I’m sure you know that the change statement in Panorama 6 changes all selected records if used on a field, so your Panorama X code should involve a formulafill - Jim’s examples, like «» = replace(«», "Early", "4:30") will affect only one record.

The reason I don’t “like” the change statement is because it uses a non-standard syntax that is different from any other statement in Panorama. In Panorama 6 many statements did their own custom parsing, the result was a bit of a hodge-podge of different syntaxes. The change statement is probably the worst offender. To make it work as it did in Panorama 6 would require an entire special parser just for this one statement. I don’t think this is a good allocation of resources, especially since it is trivial for customers to rewrite procedures that use this statement, and this statement is used relatively infrequently.

Since the replace( function now allows multiple pairs of parameters, you can now write your code in a single line.

formulafill replace(«», "Early", "4:30", "Second", "5:45", "Very Late", "8:15", "Late", "7:00")

The next version of Panorama X does have a Find & Replace (aka Change) dialog, but because of the non-standard syntax, it does not have a change statement.

So it seems I could write a custom Change statement where the code for
Change Parameter(1) Parameter(2) is
formulafill replace(«», Parameter(1), Parameter(2))

Not certain why a custom parser is necessary.

I am just hesitant to try it out, because whenever I try something like this, I get a bunch of crashes. I think I have succeeded in getting a custom statement to work. Custom functions are another question, though, and experimentation leads to crashes.

Given that the new code is only one line, you certainly don’t need a custom statement. Just replace each occurrence of the change statement (or, using Jim’s example, each group of change statements) with the formulafill statement. You are going to have to replace every change statement anyway, regardless of the solution you choose.

1 Like

If you want assistance with writing custom statements and functions, contact me at audax@wideband.net.au and I can almost certainly save you a lot of time.

Your custom statement will not have the same syntax as the original change statement. The change statement required the parameters to be separated by a space. Panorama X doesn’t allow that, the parameters must be separated by a comma. Also, the change statement had optional additional options of word and caps. These were also separated by spaces and not quoted – totally non-standard.

It would be easy for me to create a new change statement that was kind of similar to the old one. However, since it would not be exactly the same, I think it would cause confusion, especially since a Panorama 6 procedure that contained the change statement would have a guaranteed syntax error. Of course it does now, but at least the syntax error is on the change statement itself and identifies that statement as the problem. If there was a "replacement* change statement the error would be on one of the parameters and it would be much less obvious that the error had anything to do with the change statement.

I have thought of making a new statement (or probably multiple related) statements for this operation. Perhaps

changetext "old","new"   // replacement for change "old" "new"

and

changeword "this","that"   // replacement for change "this" "that" words caps

This would have the benefit that a search of the help for the word “change” would come up with these statements, which could have notes about modifying a procedure that contained the old “change” statement.

However, this idea has not reached the top of my to-do list, in the meantime, there is a fully functional way to code this.

I have a very basic problem. Opening a very simple Panorama 6 database in Panorama X loses pretty much all functionality. The drop down menu in the “C” column is missing and even worse, I can’t edit text in a form! I haven’t even tried the macros attached to the buttons. I really don’t know what to think about it.

Panorama X does not support editing of data in a View-As-List form, so pop-up menus and Text Editing will not work in these forms. The database needs to be redesigned to use a regular form for editing.

I hope I won’t be a pain too long, but I find myself not in the class of most of you posting on here. I feel like I am stuck in 1996, knowing all the shortcuts and ins and out of Pan. This new version has me scratching my head and it is my fault. When Pan 6 came out with the new menus, I ignored them, sticking with the classic menus. Now I pay the price with Pan X.

To my question. I am doing some work in Pan 6 (knowing how to do that-mainly writing or recording procedures), then making that file a Pan X file. I then get stuck when I want to add new things. So my question is, can I change back to a Pan 6 file without exporting a text file and then importing in Pan 6? I do’t want to go that route, as I may have added a field or two in Pan X and would then have to update Pan 6 before importing.

I know this is like riding a bike using training wheels, but I wanted to move into Pan X and still be productive and that is not happening.

Sorry for the long message.

Pete, the short answer is no you can’t. Export and import is the only way.

That is what I like, short and sweet…or in this case a bit sour…oh, well. I knew I should have paid more attention in class…:grinning:

There are a lot of differences in statements and functions or changes in nomenclature (e.g. what was the menu command “Math > Formula Fill …” had changed to “Fields > Manipulate Data in Field …” in Pan 6 already; in Pan X it has a new name again: “Field > Morph …”).

In the process of migrating your databases from Pan 6 to Pan X, you will have to adjust some statements and functions in your procedures. (Check the procedures with the red alert sign!)

I would not recommend to go forth and then back again (too often). You will learn Pan X the sooner if you really use it. You will get used to it the more you use it.

Just in case you missed the announcement, Panorama X now allows you to record procedures – this feature was added about a month ago. Search for Procedure Recorder in the Help to learn how it works. I think it is actually nicer than the recorder in Panorama 6 because you can watch the code appear “live” as the recording is being made – you can even edit the code while you are recording.