Topics

Stripping out unwanted decimal points!

Martin G0HDB
 

Hello all, from a new member of this forum.  Before I move onto my reason for this posting I'd like to thank Richard for producing such an excellent bit of software.  I did a little bit of Basic (and 8080/Z80 assembly language!) programming many, many years ago but my skills are exceedingly rusty and limited, so it's been a pleasure to get to grips with BB4W and do something useful with it... :-)

I decided a couple of weeks ago that I wanted to write a program to tackle a particular problem I have with converting the >25,000 entries in an amateur radio logbook from its native format into the widely-used ADIF; firstly I tried the demo version of BB4W.  It enabled me, despite my limited and ageing skills, to make a start on my conversion program so I then paid for the full version and am very glad I did - it's a great bit of software.

Now, to the problem in hand...

The native format of the amateur logbook that I want to convert to ADIF uses a character string that's 290bytes long to record the details of each contact made.  Within the overall string there's a mid-string that records the radio frequency used for the contact; the frequency field starts at character 187 in the overall string and can be up to 9 characters long.  Note that the frequency field (and each entire record) is a series of ASCII characters, not a numeric value.  Unfortunately one of the programs that has created entries in the overall logbook has recorded the frequency in the format "1.234.56" (ie. 8 characters long) or "12.345.67" (ie. the field's max length of 9 characters).

In both cases I want to be able to remove the second decimal point from the frequency field so that the entries appear as "1.23456" or "12.34567".  I've tried a variety of combinations of LEFT$, MID$ and RIGHT$ but so far have signally failed to achieve what I want.  All the rest of my program to convert the entries in the logbook to ADIF seems to be working as desired and as expected, but the presence of the spurious decimal point in the frequency field is causing problems when the ADIF file generated by my program is read by some other logbook programs - they reject a frequency in the form of "1.234.56".

Can anyone offer a means of removing the unwanted second decimal point from the frequency strings in the native log file and then appending the two characters that follow the second decimal point onto the end of the string that precedes the decimal point, so that each frequency string appears as "1.23456" or "12.34567"?

Many thanks in advance,

--
Martin (G0HDB)

Richard Russell
 

On Wed, Aug 16, 2017 at 03:18 am, Martin G0HDB wrote:
Can anyone offer a means of removing the unwanted second decimal point from the frequency strings
There's probably no 'best' way to do it but here's one suggestion:

      DEF FNremoveseconddp(a$)
      LOCAL I%
      I% = INSTR(a$, ".")
      IF I% THEN I% = INSTR(a$, ".", I%+1)
      IF I% THEN a$ = LEFT$(a$, I%-1) + MID$(a$, I%+1)
      = a$

Richard.

Dave Sergeant
 

Martin

It looks as if Richard has come up with an answer for your problem. You
may however be interested in the program I wrote some years ago which
converts ones eQSL inbox to an ADIF. You can find it at
http://davesergeant.com/bbcbasic/bbcbasic.htm as eqsladif.zip

73 Dave G3YMC

On 16 Aug 2017 at 2:45, Martin G0HDB wrote:
I decided a couple of weeks ago that I wanted to write a program to
tackle a particular problem I have with converting the >25,000 entries
in an amateur radio logbook from its native format into the widely-used
ADIF; firstly I tried the demo version of BB4W.  It enabled me, despite
my limited and ageing skills, to make a start on my conversion program
so I then paid for the full version and am very glad I did - it's a
great bit of software.

http://davesergeant.com

J.G.Harston
 

On 16-08-2017 10:45, Martin G0HDB wrote:
Can anyone offer a means of removing the unwanted second decimal point...
so ["1.23.456"] appears as "1.23456" or "12.34567"?
A%=INSTR(A$,"."):REM Look for '.' starting at start of string
IF A% THEN
A%=INSTR(A$,".",A%+1):REM Look for '.' starting after first '.'
IF A% THEN
A$=LEFT$(A$,A%-1)+MID$(A$,A%+1):REM Chop out the '.'
ENDIF
ENDIF

or as a single line:
A%=INSTR(A$,"."):IF A%:A%=INSTR(A$,".",A%+1):IF A%:A$=LEFT$(A$,A%-1)+MID$(A$,A%+1)

As part of my interest in history research I've written quite a bit of string manipulation code in tools I use for processing census data:
http://mdfs.net/Docs/Whitby/Census/Tools/

I won't claim it's the best code, as some of it has to have special cases bolted on to cope with oddities that the data throws up, but it shows examples of what you can do.

--
J.G.Harston - jgh@... - mdfs.net/jgh

Richard Russell
 

Ahem, I do believe your code is (effectively) identical to what I posted two hours earlier!

Richard.

 

... one more alternative...

      ADIF_1$=STRING$(18,"abcdefghij")+"12poyS1.234.56Edldop555"
      PRINT FN_Remove_Second_Point(ADIF_1$,192)''
      ADIF_2$=STRING$(18,"abcdefghij")+"12poyS12.345.67Edldop555"
      PRINT FN_Remove_Second_Point(ADIF_2$,192)
      END

      DEFFN_Remove_Second_Point(A$,start%)
      LOCAL p%:p%=INSTR(A$,".",start%)
      =LEFT$(A$,p%-1)+RIGHT$(A$,LENA$-p%)

The difference with the other solutions I've seen is that this function eliminates the "."  that is in position start% (192) or in a position following.
As your first dot is in position 187,  FN_Remove_Second_Point(A$,start%) will remove the second "." in the part of your string that represents the ADIF number.

The other solutions may eliminate the second "." they encounter earlier in the string, even if not in the part that represents ADIF

Richard, J.G.,  pls. correct me if I'm wrong.
 
 Eddy


From: Dave Sergeant <dave@...>
To: bb4w@groups.io
Sent: Wednesday, August 16, 2017 12:44 PM
Subject: Re: [bb4w] Stripping out unwanted decimal points!

Martin

It looks as if Richard has come up with an answer for your problem. You
may however be interested in the program I wrote some years ago which
converts ones eQSL inbox to an ADIF. You can find it at
http://davesergeant.com/bbcbasic/bbcbasic.htm as eqsladif.zip

73 Dave G3YMC

On 16 Aug 2017 at 2:45, Martin G0HDB wrote:

> I decided a couple of weeks ago that I wanted to write a program to
> tackle a particular problem I have with converting the >25,000 entries
> in an amateur radio logbook from its native format into the widely-used
> ADIF; firstly I tried the demo version of BB4W.  It enabled me, despite
> my limited and ageing skills, to make a start on my conversion program
> so I then paid for the full version and am very glad I did - it's a
> great bit of software.
>


http://davesergeant.com





J.G.Harston
 

Richard Russell wrote:
Ahem, I do believe your code is (effectively) identical to what I
posted two hours earlier!
You're right, but my internet connection has been so stodgy it only arrived a few minutes ago. ;) (Edit: it's taken six^W ten^W twenty minutes since I typed this for my connection to come back so I can post it).

Anyway, it gave me an opportunity to plug my census data manipulation tools written in BBC BASIC to add to the examples of BBC BASIC for Windows being used for real-world tasks.

Can't remember where I was working, but I spotted SimplEPOS in use.

--
J.G.Harston - jgh@... - mdfs.net/jgh

Richard Russell
 

On Wed, Aug 16, 2017 at 09:28 am, J.G.Harston wrote:
Can't remember where I was working, but I spotted SimplEPOS in use.
Long since (many years) not written in BBC BASIC, sadly.  One that got away.

Richard.

Richard Russell
 

On Wed, Aug 16, 2017 at 08:04 am, Edja wrote:
The difference with the other solutions I've seen is that this function eliminates the "."  that is in position start% (192) or in a position following
Arguably your function is misleadingly named because it doesn't do what it says on the tin ('FN_Remove_Second_Point'); perhaps it could have been called something like 'FN_Remove_Point_After'.  To make it do what the OP asked for you need to know where the first decimal point is before calling it!

Perhaps the most flexible solution is to combine the two approaches, to produce a 'remove second decimal point after':

      DEF FNremoveseconddpafter(a$, I%)
      I% = INSTR(a$, ".", I%)
      IF I% THEN I% = INSTR(a$, ".", I%+1)
      IF I% THEN a$ = LEFT$(a$, I%-1) + MID$(a$, I%+1)
      = a$

Richard (G4BAU).

Martin G0HDB
 

Hello again all, many thanks for the excellent suggestions for getting rid of my unwanted decimal points in my log files - it's great to have such a helpful group of BB4W users.

I've just quickly tried JG's one-line version of the code in my ADIF log conversion program and, although I haven't yet done any exhaustive tests to see if any of the other frequency fields in the ADIF output file are showing strange values, at first glance everything looks just fine and the ADIF file created by my program from a subset of the original log file can now be imported into other logging programs without any resulting blank frequency entries - things are looking promising!

Dave 'YMC - I'll drop you an email separately, to prevent any further discussions about log conversion programs from boring the rest of the forum members...!

Thanks again to everyone,

--
Martin

Previous Topic Next Topic