Mailing List Tutorial 120: Extra Credit…

In order to become familiar with using Panorama X, I am working through the tutorials. I have run into an occasional mismatch with what the tutorial suggests and what I find in Panorama X, but so far I have been able to find enough information to work around these little glitches. I assume that future updates will correct these uneven areas. I have been unable to find any reference to this problem in the forum, so I will describe what is happening in case someone here has already dealt with it.

In this page of the tutorial “Mailing List Tutorial 120: Extra Credit…”, the code provided does not do what it is meant to do. After copying the code into the Code tab of Field Properties of the Phone field, when a phone number is changed or added an error with “Field or Variable [Phone] does not exist.” pops up. After that error message is closed, whatever number was typed is entered into the field exactly as it was typed. I can see that the code works in the animation in the tutorial, but it does not work in the data base that I created by following all of the previous tutorial steps.

The code in question is:

local digits
digits = striptonum(Phone)
if length(digits) = 0 or length(digits)>10
return
elseif length(digits) = 7
digits = “714”+digits
endif
if length(digits) = 10
Phone = formatphone(digits)
return
endif
if length(digits)<7
nsnotify “Bad Phone Number?”,“text”,“Only “+pattern(length(digits),”# digit~”)
endif

I would just like to find out if this has something to do with my version of this database or if there actually a problem with the application of the code.

Ken

I can duplicate your symptoms, if the field isn’t named Phone. If that is the field’s name, it works as advertised.

Thank you, Dave. I see your point.

During the creation of this database, at some earlier point, the name of the Phone field was changed in the tutorial to “Cell”. I never changed it back to “Phone”.

The code now works, except for one condition. There is no error message when a number with more than 10 digits is typed in. This sits like a pea under a mattress, so if you have any other suggestions, I look forward to hearing about it.

Ken

I just tried creating a new database with a phone number field. I think copied the code from your post above and pasted it into the Code section of field properties panel in the Phone number field. I then entered various phone numbers and the code worked perfectly. I would post a screen shot here but it would be exactly the screen shot already in the documentation.

If I renamed the field to something other than Phone, then I get the error message you describe, as shown in this screen shot. For example, I tried adding an extra space to the name, so that the field is actually named *Phone". Of course the space is invisible, but it still is part of the field name.

The name of the Phone field must be exact – if there is an extra space, for example, the code won’t work. So I would suggest carefully checking the field name to make sure it is exactly P H O N E with no extra characters before or after.

Perhaps Panorama X should be changed so that it doesn’t allow any spaces at the beginning or end of the name. Though from past experience I think that most likely someone will complain if that is done, but still, perhaps it should be done anyway. It is also possible to adjust the code so that it works with a trailing space in the field name, simply replace every occurrence of:

Phone

with

«Phone »

That’s what it was programmed to do.

if length(digits) = 0 or length(digits)>10
return

I suppose this is for international numbers, where there might be more than 10 digits. You can remove the test for greater than 10, and then at the end, add something like this.

if length(digits)>10
    nsnotify "Warning","text","More than 10 digits" 
endif

Hi Jim,

I checked Field Properties for the Phone field. When I first place the cursor in the Name: cell, it butts up against the “e” in Phone, so there is no trailing space, and I do not see any leading space in that cell either.

Dave: Thank you. My mistake. I miss read that line of code and did not notice that there is only a "return"statement there.

Ken

I was assuming that the field name was a variation on Phone, but obviously the problem was that the field was called Cell, not Phone. If the field name is changed, the code has to be changed to reflect the actual field name.

The original error message told you exactly what the problem was: that there was no field named Phone.


I think I see what happened. At the bottom of this page:

it says “To examine or change the options, simply click on the Properties tool to open the Field Properties Panel. For example, I can use this panel to change the Phone field to Cell.”

However, it was really not meant for you to change the field name at that point, just to show you that you could do that if you wanted to. Sort of a “Simon says” situtation, and I agree, a bit confusing. I have just added a note there to clarify that if you try changing the field name, you should be sure to change it back before continuing with the tutorial. The link on the web page above already has the correction, and the embedded help system inside Panorama will include it when the next release comes out.

If you run into any other confusing points in the tutorial, I’d be happy to see if we can clarify them as well. We proof read everything carefully, but as in this case it is still possible for something to slip thru.

Jim, thank you for pointing out the meaning of that error message. I just have to keep reminding myself to slow down and think more like a computer when I run into these problems. Otherwise, the process more closely resembles the game of Telephone.

So far I like what I see in Panorama X, and I plan to subscribe tomorrow. My plan is to redo a relational database that I made about 18 years ago with Paradox. It is the last program that I have not been able to leave behind since moving to OS X 9 years ago. I think I will be able to recreate my workflow without having to code as much as I did back then. I am enjoying the challenge.

Wow, I remember that name – I was thinking it was a PC database not Mac. I guess my memory is fuzzy.

Jim, your memory is still good. That program is the only reason that I am still using Windows. Since that old database usually runs without much trouble, I do not want to mess with it, and I have not looked at its code for a long time. I dread mucking about with it to maintain or improve it.

Ken