Emptyfield? Need it in X

Has something replaced Pan 6’s “emptyfield” command, to take the cursor to the next available field in a line item?

There is still a link to an emptyfield statement in the documentation of the field statement, but it leads to a not existing html page.

It is listed as “unimplemented” in Help, and no promise that it won’t be eventually deprecated anyway. It seems like there might be an interim workaround, but I’m having trouble figuring one out. Maybe someone has?

maybe something like
    loop
        right
        if sizeof(«») = 0 stop endif
    until stopped

Here is something I worked out to simulate the emptyfield statement that you can use with a call, farcall or shortcall scheme. Using a shortcall you would have this in the same procedure at the bottom:

Emptyfield:
    local x,y y=parameter(1)
    x=arraystrip(arrayfilter(info("fields"),¶,{?(import() beginswith y and striptoalpha(import())=y and replace(import(),y,"")=striptonum(replace(import(),y,"")),import(),"")}),¶)
    looparray x,¶,element,index
        executelocal {y=sizeof(}+element+{)}
        if y=0
            field (element)
            stoploopif y=0
        endif
    endloop
    return

This would be invoked for example with:

shortcall Emptyfield,"Quantity" // use only the base field name without the ending number

Or obviously if the code was in another procedure called Emptyfield you would use:

call Emptyfield,"Quantity"

This operates by getting a list of all the fields and then narrowing it down to only the fields that begin with the base field name and only that name other than the ending numbers. It then uses a looparray with this list to test each one in turn to see it it is empty. If it finds an empty field it makes it active and stops.

Or, ideally, set it up as a custom statement called emptyfield.

Thank you all for the many ways to deal with this. In my present situation I know which cello I am in and what line it is so it’s pretty easy to derive the “next empty field” with some simeple code. I’ll keep these all in mind if (when) I need a more universal solution, unless “emptyfield” is revived.

It will be.

I’ve been watching this thread to see if some one comes up with a good solution that I can just use as is :slight_smile: But I think I may be implementing this in Objective-C.

Sometimes an idea just comes out of the blue, and this afternoon while driving I thought of a way to efficiently implement emptyfield in Panorama code – no Objective-C required. So this statement has been added and will definitely be in the next release. I did make one change – it now will cause an error if there is no empty field available. This is different than Panorama 6, but I think a definite improvement.

If you don’t want to wait for the next release, it’s only a few lines of code.

local emptyFields,targetField,targetPattern,nextEmptyField
targetField = "ItemΩ"  // put in the actual field name you want here
targetPattern = "^"+replace(regexliteral(targetField),"Ω","[0-9]+")+"$"
arrayfilter info("fields"),emptyFields,cr(),?(import() regexmatchexact targetPattern and sizeof(import())=0,import(),"")
arraystrip emptyFields,cr()
nextEmptyField = firstline(emptyFields)
if nextEmptyField<>""
    field nextEmptyField+""
else
    returnerror "There is no empty “"+targetField+"“ field available."
endif

Just plug the actual field you want into the second line.

This is a good example of the power available with the combination of arrayfilter and regular expressions. This actually could be collapsed into a single line, but that would be hard to read.

This brings up a question I’ve wanted to ask about creating interim workarounds for commands that are not currently implemented. As it “was”, the code I’d use in Pan 6 looks like this:

emptyfield "«myfield»"

but I would guess that in order to use the code you cite here in Pan X, if I named it “emptyfield” then I would have to invoke it like:

call emptyfield, "«myfield»"

Please correct me if I misunderstood. What I’m getting at, is there a way to be able to invoke this procedure using the first format (without a “call”)? Thus not having to edit my original code at all; it would work now and it would work when “emptyfield” becomes a built-in command? I am more concerned with the “resynchronize” command that is currently making many procedures unrunnable without removing or commenting out those lines. Could I make a “resynchronize” procedure that did nothing but a NOP but would let me leave those lines in untouched now as well as when the real functionality is completed? I worry that I’ll miss places where I’ve had to comment out lines like this and then uncomment them when the functionality returns.

Is this real code? Or did you make it up just now. I’m asking because that code won’t work in Panorama X, at least not right now. The documentation says that the field name must end with Ω, because this must be a line item. Also, you should not use chevrons, since the name is quoted.

If this is real code that actually worked in Panorama 6, let me know, hopefully I can make adjustments.

I am more concerned with the “resynchronize” command that is currently making many procedures unrunnable without removing or commenting out those lines

It is possible for you to make a custom statement. However, I have just now added a dummy resynchronize command to Panorama X, so you won’t have to worry about these errors once the next release drops.

That is, in fact, a direct lift from functioning Pan 6 code except for the name “myfield”. I think your Pan X requirements make more sense, but it won’t just “drop in” to existing Pan 6 origin code as it is. Not sure that’s a show-stopper, I don’t use it a lot of places.

Now you’re talking! I do use this in a lot of places.

I was looking for a way to delete empty fields (not records, the actual field), came across the emptyfield procedure via Panorama Help, and notice typos in the Description section of the help documentation. This first sentence reads like the way I talk when I forget the person I’m speaking too can’t read my mind and “hear” the words I left out.

Description
This statement the next line item field that is empty the current field. Most commonly this is used so that you may …

The rest of the copy makes sense.

Should be:

Description
This statement makes the next line item field that is empty the current field. Most commonly this is used so that you may …

1 Like

I’ve made this correction. This seems like a good time to post a reminder that in about the time it takes to make a post here on the forum, you can submit a documentation change yourself! I know Bruce knows about this because he has submitted many changes, but we have a lot of new users here that may not be aware of this capability. See Submitting Corrections on this page to learn how to do it:

So far there have been nearly a thousand corrections submitted by various users, thanks to all of you!

Had I run across it in Help, I might have made the change, but here I was just adding the word that made the sentence make sense.

Jim -
I had a faint recollection there was a method for submitting corrections to the documentation. Thank you for the reminder and link pointing towards how to do so.
JimA