Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6629 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Never gone as far as posting a script before, but I just can't work this out no matter how long I stare at it.

Okay. In database Whole thing, we're in table edition; art is another table. [These names are all truncated but largely accurate.]

In art, EditionCount is a field that contains a number from 1 to 8. That represents how many copies of an artwork will be available for sale, at different prices. In edition, I want one record, related to the main serial number, for each of those copies [or editions].

The script has already found records that match the main serial number, so we've got a found set relevant to it. It has then checked to see whether our records outnumber the designated edition [screwup, call user's attention to discrepancy and exit script], or whether they match [no adjustment is needed, exit script]. The possibility remaining, which needs action, is that our edition number calls for more copies than we have records reflecting. So what I thought this script would do:


Loop

  If [Get (FoundCount) < art::EditionCount]

    New Record/Request

    Paste [select; edition::Serial_Number]

  End If

  If [Get (FoundCount) = art::EditionCount]

    Perform script "other helpful script"

    Exit Script []

  End If

End Loop

is start the loop, see if we have enough records yet. If so, great; if not, run it again, make another record, wee if we have enough. [As I'm running this, I'm asking for an edition of 7, and have only 2 records, so I expected it to run five times, then match terms and run other helpful script.]

What it in fact does, as I watch it in debug scripts, is: Makes the new record, inserts the copied data [serial number] in the proper place, then bounces from both If statements to both End If statements - even though the found records now total only three, and EditionNumber is still looking for 7.

So, I'm getting dizzy.

[i'm finding that I can't Copy text out of the script box and into anything - Excel, Word, notepad - so I've just retyped the scripting. If there's a workaround for that, i'd love ot know it - thanks - ]

Posted

As I watche dit go just now, I inadvertently made it work [i think] by 'clicking outside the box' where it had just Pasted. That begs the question:

When the last step in a script is, say, pasting data, which leaves a cursor sitting in a selected live field, what command tells the application to 'click outside the box' - i.e. to deselect all fields? I thought Refresh Window did that, but it ain't.

Posted

Two Things:

a) The scruipt step you're looking for is Commit Records not refresh window

: You should really avoid using copy and paste techniques. Instead, you should store what ever value you want moved in a global text field using the set field script step, then when you need to retrieve it, also use a set field script step. The reason being that it actually performs standard OS copy and paste operations -- so if you had copied something run the script, then paste, it will be lost and you'll paste what ever rubbish you last coppied in the script.

Posted

Also, just for the sake of it (though it's not mandatory) you can use an else or else if statement instead of two if statements, otherwise it tests both even if the first is true (which in your case would make the second false) so there's no real point.

And also also, if you don't want to get dizzy, insert the Freeze Window Script step at he begining of your script

Posted (edited)

It's true that I've been lazy - or as I like to think of it, Otherwise Occupied - in continuing to use copy & paste instead of Set Field. I got dodgy reslts using Set [which I know is a reflection on my half-understanding of what I'm doing, not any software shortcoming].

Do I even need the global storage field? It seems redundant to me since the fields I'm synchronizing are in different tables. I thought that the right dialog was

SetField [ current::WantDataHere ; other::HaveDataHere ]

, but I got irregular results. [i.e. it didn't work often enough that I kept my lazy habits in place.]

Edited by Guest
Posted

... Globals are global, you can access them from anywhere irrespective of the tables they exist in...

Posted

...I start to see the wisdom of your ways.

As is clear, I'm learning the upgrades from 6 to 8 on this project, which includes learning how tables behave ... like globals are well and truly global.

Thanks for your advice. I've been leaning heavily on this message board this weekend; the responses I've gotten have been cordial and very helpful.

This topic is 6629 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.