July 10, 200322 yr 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?
July 11, 200322 yr 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
July 11, 200322 yr 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! Note: updated example to exclude data fields consisting of only " " or shufflefields.zip
July 11, 200322 yr Author 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, .. SetField(B, "") .. Perform Script (this script) End IF # IF ( IsEmpty( 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 #
July 11, 200322 yr Hey, I like that idea, too. More thinking outside the box, which is too much fun for me to handle. I wonder if you could use my idea, but base the lookup on a calculation between the Get Field and original lookup fields. Hmmm.
Create an account or sign in to comment