Author Topic: Code replacement with multiple null fields  (Read 6571 times)

Offline devenh

  • Sr. Member
  • ****
  • Posts: 435
    • View Profile
Code replacement with multiple null fields
« on: December 21, 2009, 06:01:16 PM »
Using 4.6.1 Windows, when I have a CR like (tabs are shown as *)

100*field1*field2*field3**

In this case, the last two fields are null (my default replacement is "NA").

If I try to use field5, I get NA as expected.  If I try to use field4, I get blank.

If I change the CR text to

100*field1*field2*field3

(removing the trailing tabs) then both field4 and field5 return NA as I would expect.

Deven

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Code replacement with multiple null fields
« Reply #1 on: December 21, 2009, 07:46:53 PM »
Deven,

Using 4.6.1 Windows, when I have a CR like (tabs are shown as *)

100*field1*field2*field3**

In this case, the last two fields are null (my default replacement is "NA").

If I try to use field5, I get NA as expected.  If I try to use field4, I get blank.

If I change the CR text to

100*field1*field2*field3

(removing the trailing tabs) then both field4 and field5 return NA as I would expect.

OK, I'll take a look at the parser.

-Kirk

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Code replacement with multiple null fields
« Reply #2 on: December 22, 2009, 09:41:50 AM »
Deven,

Using 4.6.1 Windows, when I have a CR like (tabs are shown as *)

100*field1*field2*field3**

In this case, the last two fields are null (my default replacement is "NA").

If I try to use field5, I get NA as expected.  If I try to use field4, I get blank.

If I change the CR text to

100*field1*field2*field3

(removing the trailing tabs) then both field4 and field5 return NA as I would expect.

OK, I have made changes to the parser to make your first example consistent in that 100#4 and 100#5 both parse as empty fields.  They're not 'null', they just evaluate to a zero length string of characters or "".  I wouldn't expect 100#4 and 100#5 to return "NA", but I would expect 100#6 to return "NA" since there is no field #6.

Is there a good reason to change the behavior such that any "empty but exists" replacement should turn into the missing replacement default?

-Kirk

Offline devenh

  • Sr. Member
  • ****
  • Posts: 435
    • View Profile
Re: Code replacement with multiple null fields
« Reply #3 on: December 22, 2009, 02:34:44 PM »
I'm not sure there is a right answer on this one.

If I have six fields and one or more of the first five fields is null, how would I enter that?

Example (tab is *):

code*field1*field2**field4**field6

So fields 3 and 5 are missing.  Are they null or are they blank?

I would think null, and therefore the default value should be returned.  If a user thinks it should be blank, then couldn't they enter blank in the default field value?

Deven

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Code replacement with multiple null fields
« Reply #4 on: December 22, 2009, 03:17:32 PM »
Deven,

I'm not sure there is a right answer on this one.

If I have six fields and one or more of the first five fields is null, how would I enter that?

Example (tab is *):

code*field1*field2**field4**field6

So fields 3 and 5 are missing.  Are they null or are they blank?

I would think null, and therefore the default value should be returned.  If a user thinks it should be blank, then couldn't they enter blank in the default field value?

The decision that what you call a 'null' entry to resolve to either an empty string (which it literally is) or a default replacement is somewhat arbitrary, but the precedent (the way it should have worked when working correctly) was to return the empty string and only resolve to the default replacement when a replacement just doesn't exist.  That's the way it currently works and I don't know if changing it would cause anyone else a different issue.

We should discuss this.

-Kirk

Offline devenh

  • Sr. Member
  • ****
  • Posts: 435
    • View Profile
Re: Code replacement with multiple null fields
« Reply #5 on: December 22, 2009, 05:25:34 PM »
Certainly I think null should returned for all the field(s) if the code value doesn't exist.

I see the logic of returning null when the trailing fields in a multi field CR are missing (e.g. no tabs), but I wish there were a way to force a return of null for an inner field when an outer field exists as in my previous example.

Happy Holidays and thanks for your support throughout the year!

Deven

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Code replacement with multiple null fields
« Reply #6 on: December 22, 2009, 05:49:34 PM »
Deven,

Certainly I think null should returned for all the field(s) if the code value doesn't exist.

I see the logic of returning null when the trailing fields in a multi field CR are missing (e.g. no tabs), but I wish there were a way to force a return of null for an inner field when an outer field exists as in my previous example.

Why is it that you would have field1, field2, field4 and not have field 3 for instance?

If you want that capability, why don't we come up with something else that you could put in the field to cause the default value to be used, for instance make the field value be {default} ?

-Kirk

Offline devenh

  • Sr. Member
  • ****
  • Posts: 435
    • View Profile
Re: Code replacement with multiple null fields
« Reply #7 on: December 23, 2009, 07:04:41 AM »
It is simply missing data.  When you are processing hundreds of images and using an external data as the source of your code replacements, it is not unusual for a field to be missing occasionally.

In my case I am posting photos for sale of ski racers.  I take the race results (which includes things like name, racer ID number/license, team, age, race class, gender, bib number, their time in the race, and how they placed).  Sometimes the racer does not have an ID number, so this is blank.  If the racer is disqualified, then they have no time nor place.

I process all the data in Excel and then export a CR text file.  For maintenance reasons, I try to keep my Excel code as simple as possible, and therefore I would prefer to continue exporting the CR in the format I have described in my previous posts.  Alternatively, I could recode my worksheet and take more control of how the missing fields were represented.

This is not a high priority concern for me, just something I thought was worth bringing to your attention.

Deven