Changing behavior of a procedure 1.63

Moderators: Phil Winkler, Graham Smith, Pete Tabord

Changing behavior of a procedure 1.63

Postby Paul Nelson » Fri Mar 17, 2017 12:54 pm

Hi all

We run clean-up routines on imported data.

One of these is for UK Postcodes and it is to ensure that they are all in the same format.

The procedure contains the following line:

PostCode := UPPER ( concat ( firstc( StripChar ( PostCode , " " ) , length ( StripChar ( PostCode , " " ) ) - 3 ) , " " , lastc ( PostCode , 3 ) ) ) ;

It has been working without issue for a good number of years.

In the last few days it has started to misbehave and will sometimes work and on other occasions it removes the third character.

I cannot find any pattern.

Can anyone offer any suggestions?

I have not changed anything.

Paul
Paul Nelson
 
Posts: 71
Joined: Mon Sep 10, 2007 8:30 pm
Location: Leicestershire UK
Has thanked: 0 time
Been thanked: 0 time
 

Re: Changing behavior of a procedure 1.63

Postby Gil Fleming » Fri Mar 17, 2017 1:04 pm

Hi Paul. From what I can see, you are removing spaces from the postcode, but you are doing it by splitting your string using firstc and lastc, then glueing the parts back together. In which case,why not just use

Code: Select all
StripChar ( PostCode , " " )
Gil Fleming
Director
Fleming Technical Limited

You can't think about what you don't know - Mike Fidler
If you can't fight, wear a big hat - John S Fleming
The best way to have a good idea is to have lots of ideas - Linus Pauling
Gil Fleming
 
Posts: 546
Joined: Tue May 15, 2012 10:26 am
Location: Liverpool, UK
Has thanked: 1 time
Been thanked: 2 times
 

Re: Changing behavior of a procedure 1.63

Postby Paul Nelson » Fri Mar 17, 2017 1:10 pm

Hi Gil

StripChar on its own would only remove the spaces.

What we do when we "glue it back together" is to add a space before the last three chars in the Post Office preferred format.

Paul
Paul Nelson
 
Posts: 71
Joined: Mon Sep 10, 2007 8:30 pm
Location: Leicestershire UK
Has thanked: 0 time
Been thanked: 0 time
 

Re: Changing behavior of a procedure 1.63

Postby Gil Fleming » Fri Mar 17, 2017 1:14 pm

Sorry Paul, I didn't notice the little " " you snuck in to your derivation. Have you tried using three fields to achieve your result? ie the original incoming data, the stripchar version and the finally corrected version with the space in the right place?
Gil Fleming
Director
Fleming Technical Limited

You can't think about what you don't know - Mike Fidler
If you can't fight, wear a big hat - John S Fleming
The best way to have a good idea is to have lots of ideas - Linus Pauling
Gil Fleming
 
Posts: 546
Joined: Tue May 15, 2012 10:26 am
Location: Liverpool, UK
Has thanked: 1 time
Been thanked: 2 times
 

Re: Changing behavior of a procedure 1.63

Postby Paul Nelson » Fri Mar 17, 2017 1:18 pm

Hi Gil

That's how we used to do it many moons ago and we streamlined it a few years back.

As I said in my original post it has worked satisfactorily for years.

Sometimes it works now, but not always - that is what is so frustrating.

Paul
Paul Nelson
 
Posts: 71
Joined: Mon Sep 10, 2007 8:30 pm
Location: Leicestershire UK
Has thanked: 0 time
Been thanked: 0 time
 

Re: Changing behavior of a procedure 1.63

Postby Gil Fleming » Fri Mar 17, 2017 1:45 pm

Paul, another couple of options:

1. Use a global variable to store the answer before you write it:
Code: Select all
r := SetGlobal(1, UPPER ( concat ( firstc( StripChar ( PostCode , " " ) , length ( StripChar ( PostCode , " " ) ) - 3 ) , " " , lastc ( PostCode , 3 ) ) )) ;
PostCode := GetGlobal(1) ;

or 2. Do it stepwise: Stripchar the postcode into variable1, derive your firstc and lastc figures from variable1 and store them in variable 2 and variable 3, then concat variable 2, space, variable 3.

I suppose you could always ask those helpful people at ffenics what the heck is going on, but I'm not sure they even view the forum any more. :roll:
Gil Fleming
Director
Fleming Technical Limited

You can't think about what you don't know - Mike Fidler
If you can't fight, wear a big hat - John S Fleming
The best way to have a good idea is to have lots of ideas - Linus Pauling
Gil Fleming
 
Posts: 546
Joined: Tue May 15, 2012 10:26 am
Location: Liverpool, UK
Has thanked: 1 time
Been thanked: 2 times
 

Re: Changing behavior of a procedure 1.63

Postby Paul Nelson » Fri Mar 17, 2017 1:54 pm

Hi Gil

Thank you.

Paul
Paul Nelson
 
Posts: 71
Joined: Mon Sep 10, 2007 8:30 pm
Location: Leicestershire UK
Has thanked: 0 time
Been thanked: 0 time
 
 

Return to Ffenics 1.x

Who is online

Users browsing this forum: No registered users and 7 guests

cron