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

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

Recommended Posts

Posted

I have 4 fields, A, B, C, and D. Sometimes one or more of them is empty. I want to make a script that shuffles them around so that the empty ones are always last. That is, if A is empty but B has a value, I want to move the value to A and clear it out of B.

Anyway, the caffeine isn't helping today, and I wonder if someone has a semi-elegant way of doing this, in a loop maybe -- but Exit Loop If ... what?

Posted

Just a bunch of If's would work, but maybe not too elegant.

If (IsEmpty(A))

If (notIsEmpty(:)

SetField(A, :

SetField(B, "")

Else

If(notIsEmpty©)

SetField(A, C)

SetField(C,"")

Else

If(notIsEmpty(D))

SetField(A, D)

SetField(D, "")

End If

End If

End If

End If

If (IsEmpty(:)

If (notIsEmpty©)

SetField(B, C)

SetField(C,"")

.

.

.

I'm tired of typing, but you get the idea.

-bd

Posted

If you like the idea of automatic shuffling, check out this attachment.

I just did it to see if it was possible, after reading your post. Turns out that it is! smile.gif

Note: updated example to exclude data fields consisting of only " " or par.gif

shufflefields.zip

Posted

Thank you both for the help. -Q-, that's a very, very clever solution. It's a little more than I want to get into though, since I actually need to move a whole row of 5 fields, some of which already have other lookups. LiveOak, I also got tired of typing -- I was staring at my script, similar to yours, and just thinking there must be a better way. This morning I had a small inspiration, so now I have a pseudo-loop in which the script calls itself after each move, and I only need 3 IFs:

IF ( IsEmpty(A) and not IsEmpty(: )

.. SetField(A, B)

.. SetField(B, "")

.. Perform Script (this script)

End IF

#

IF ( IsEmpty(B) and not IsEmpty© )

.. SetField(B, C)

.. SetField(C, "")

.. Perform Script (this script)

End IF

#

IF ( IsEmpty© and not IsEmpty(D) )

.. SetField(C, D)

.. SetField(D, "")

.. Perform Script (this script)

End IF

#

Posted

Hey, I like that idea, too. More thinking outside the box, which is too much fun for me to handle. smirk.gif

I wonder if you could use my idea, but base the lookup on a calculation between the Get Field and original lookup fields. Hmmm.

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