Jump to content

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

Recommended Posts

Posted

OK, I've done it - again!  I have to take full blame for this mess (you always do as a developer).

 

Without going into a lot of sordid detail, my Child table is in need of adjustment.  Seems on a large percentage of records, the ChildLastName and ChildFirstName are reversed.  I now need to swap them.  So here's what I thought would work.

  1. Create a calculated field called LNameSwap.  In calc, make it equal ChildLastName.  This works.
  2. Simple Script:
    1. Set Field ChildLastName = ChildFirstName
    2. Set Field ChildFirstName = LNameSwap
  3. Assign Script to a Go button
  4. Create second button with "Next" to move forward to the next record.
  5. Note:  I can't do this more automated because I have to visually inspect the two name fields to see if a change is needed.  Again, this condition is only on certain records.  There's only 1400 of them so I'm cutting my loses.

Browse mode.  Press Go button.  Doesn't work.  Script Debugger shows a 102 error - Field Is Missing as soon as the script moves from Step1 to Step2   This error doesn't help because a close inspection for typos shows no discrepancy.

 

Question:  I don't get what is "missing".  What is it looking for?

 

H

Posted

Is the layout you are using from the correct table occurrence?

 

Incidentally, you should reverse the order of the Set Field steps otherwise all your children will have a first name in their last name too because the calculated field will re-evaulate when ChildLastName is reset.

Posted

Yes, there is only one table and one table occurance.  This is a legacy solution using external data sources.  So this table and table occurance is the only one in this Child.fp7.  And so I see that the order in the script does make sense.

 

Still I can't get the names to swap.  I've also tried setting a local variable ($lnameswap) to temporarily hold the ChildLastName while I attempt to place the ChildFirstName into ChildLastName, then copy back the $lnameswap into ChildFirstName.  I've researched passing the variable to the field and I haven't gotten that to work either.  I believe it's syntactical or maybe variables can't be used this way to inject field contents.

 

Anyway, the temporary field LNameSwap seemed like a viable approach.  And the script just isn't working.  Reversing the order as you've pointed out yields the exact same "102" error on moving from Step1 to Step2.

 

Wish I could figure this out...

 

H

Posted

Try:

 

 

Go to Record/Request/Page

       [ First ]

Loop

    Set Variable [ $last; Value:${ChildTable}::Last ]

    Set Variable [ $first; Value:${ChildTable}::First ]

    Set Field [ ChildTable::Last; $first ]
    Set Field [ ChildTable::First; $last ]

    Go to Record/Request/Page

         Next; Exit after last ]

End Loop 

  • Like 1
  • Newbies
Posted

The loop script relies on finding the records that you want to edit, you could add a temp field and mark them, then apply the loop script, probably the safest method......

Posted

Or you can just disable the Loop and the Record Requests for individual record changes.

Posted

OK, I finished.  I took out/disabled the loop - because - I need to stop at each record and individually visually check which way the names are (were).  A pain, yes but it's the penance of my sin of having the field label over the wrong field on the layout.  Looping sends the script through the entire found set which works on all records - not just the ones out of adjustment.  I was smart enough to test it on a backup copy - whew!

 

I still would like to know why my followup script didn't work where I set a temp_var, set lastname to temp_var, make lastname = firstname, then set firstname = temp_var.  I was getting a "102" error, which I don't see why.  The fields are there.

 

Hoib

Posted

OK, I found the error. 

{from memory}

 

set variable [ $swapname; Chlld Info::child_lastname ]

set field [ Child Info::child_lastname = Child Info::child_firstname ]

set field [ Child Info::child_firstname = $swapname ]

 

See it?  I didn't.  What's the equal sign doing there?  I was atempting to make one field "equal" another.  Close but no cigar!  Somehow FM permitted this.  But...Can't blame it on FM - I clearly wasn't following instructions.  And, I probably need new glasses...

 

This second script step should actually be:          set field [Child Info::child_firstname; Child Info::child_lastname ]   And the third follows the same semi-colon pattern.

 

I modified the steps and yes indeed it now does work. 

 

As someone aptly and correctly pointed out, I should show the actual script instead my own interpretation. 

Question:  How do I get FM to export or save or display scripts as a text file so that they're subject to manipulation in the Windows clipboard?  In Edit Scripts, there's no "export" or Save As feature that I can find.  Copy/Paste only works within the confines of FM.

 

H

This topic is 4440 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.