Field code enigma

Probably not strictly a 10.2 problem, but I’m not sure.
I’m changing a database to use the new relational database options, which is making a procedure redundant, except for one element which I should be able to put in the code area for the relevant field. The code in the procedure, which works perfectly is:

if Category contains “Fuel”
alertnoyes “Do you want to claim the fuel rebate for this entry?”
if info(“dialogtrigger”) = “Yes”
getscrap “Fuel rebate rate (c/L):”
FuelRebate=clipboard()
endif
endif

If I put this code into the code section of the field “Category” it sort of works, but the second message comes up without pausing for the first question to be answered, so they have to be completed in opposite order, which makes no sense. If I do it a second time however, the value inserted into the clipboard DOES get entered into the FuelRebate (text) field. I decided I could do without the noyes question, and just ask for the rebate amount, entering zero if I didn’t want to claim the rebate. However, now I get the following error - and have no idea why?

I was not able to duplicate the problem you are seeing. But if I did, I would try adding a statement at the start of the procedure

setdialogtrigger ""

Also, I know that Jim discourages the use of getscrap in order to avoid the clipboard. Instead you can use gettext, which uses a variable that you must declare first.

let localvar=""
gettext "dialog message",localvar

For even more options, you can use gettexxtdialog.

Thanks for your suggestions. Neither of these options corrected the problem, but they have enabled me to understand what the problem is (up to a point). It relates to the second query not waiting for the first. I think this is a known issue (from vague recollection of previous discussions), but I thought if I put the code into a procedure and called the procedure in the properties panel, it would fix it - but that is not the case. This is what I have done:

if Category = ""
      Category = gCategory
endif
if Category contains "Fuel"
let a = ""
        gettext "Fuel rebate rate (c/L):",a
        message a
        «FuelRebate»=a
endif

(I’m sorry Jim, every time I quote some code I remember you once asked me to do something so it looks different, but I can’t remember what that was??)
50% of the time when this runs, the Message panel comes up a split second after the first query, and is obviously blank because the variable has not been filled. Interestingly the other 50 percent of the time, the message comes up ok, but its still not filling the field correctly.

Just a side question. Why isn’t there a getnumber option? I would personally find this very helpful, instead of having to remember to treat the information as text and convert it to a number.

Ignore my 50% of the time statement. It seems (now) to always do the fast run through. Hence I’m assuming it fails to put the value into the field because it has passed that part of the code before I have filled in the box.

But then you’d have to remember to treat it as a number for your message and field assignment, since your procedure seems to handle it as text. And you’d need to start it as 0 rather than “”.

Pause and Resume commands are in the 10.2 help so apparently they are still a thing - you might look at Pause and Resume in the Help because it sounds like you want to assure dialog B triggers after dialog A is done.

The original question is completely puzzling to me. Alerts and dialogs always pause Panorama to wait for your input. There is no way that a second message can come up without pausing for the first question to be answered, there has never been a reported bug like this in any version of Panorama or Panorama X.

This is bizarre. I have never heard of this happening ever. This is not a known issue. I just pasted your code into a database here and it worked perfectly 100% of the time, the message alert never appeared until the Fuel rebate rate was entered. I don’t know what it could be but there must be something additional you are not telling us, or else there is something really weird going on with your computer.

What does “the fast run through” mean?

Again, a program will never continue running past a gettext statement until the box is filled in. The way Panorama is written internally, this is totally impossible. The dialog has to close before the code can continue to run.

This is my screen shot of both alerts appearing:


The one in front is blank because the one behind hasn’t been filled in to give a value to display in the one in front. That’s what I mean when I say ‘the fast run through’.
I have definitely come across this problem previously (I think) - so pre 10.2. I thought I got around it by putting the code into a formula which I ‘called’. I assumed I had got this fix from the forum, but maybe I figured it out for myself? Either way, its not helping this time.

I think the second alert is an error, unrelated to your code.

However, I think this new screen shot does give me the missing piece I needed to understand what is going on. I can see underneath that the Category edit box is open. What I didn’t understand was that you are calling this code after editing a field.

You can’t open a dialog or alert in the code called after editing a field.

At that point, Panorama is busy doing things. It’s not finished with tidying up after editing the field, and opening another window, dialog or alert completely screws it up. As you can see.

In previous versions of Panorama the answer was simply “you can’t do this.” This is going to part of one of the future sessions in the class. Here is the related help page.

It’s after 1 AM here, so take this with a grain of salt, but I think you might be able to get your code working by putting the line

wait 0

right above the gettext statement. Explanation of why this might work I will delay until the class, but you can read about this new statement here:

Though now with 10.2 I think you can do this, in my opinion you should not do this. Popping up a modal dialog after data entry breaks all modern user interface rules, at least in my opinion. I think a much better solution would be to set up a custom tab order, if the category contains fuel, tab to the FuelRebate field. This would be much less jarring for the user.

Thankyou. Go to sleep now. I’ll digest the information you’ve given here and respond with any questions. However, after what you said about it working perfectly, I just made a new database, with 2 columns - category and fuelrebate, and the code worked perfectly…

Thankyou. Both fixes you suggested worked for me. I agree that the second approach is better.
Look forward to hearing what the first one means when you get to that part of the tutorials

1 Like