[fpc-pascal] Odd delimited text file length limitations

Bart bartjunk64 at gmail.com
Wed Jul 6 13:36:51 CEST 2011


Hi Ko,

On 7/6/11, Ko Hashiguchi <ko.d.hashiguchi at gmail.com> wrote:

> The last two values in the rows in VchrtTRN.TXT are not supposed to have
> values of 0.0. This is where my problem is: why doesn't the program give me
> the expected, non-zero answer?

I tried a different approach.
Instead of breaking down the InputString yourself, why not let a
TStringList do it for you.

After doing so you can iterate through the stringlist and obtain the values.

You need unit Classes for TStringList
I also used StrToFloatDef instead of Val (but that is not necessary,
just a matter of taste), this is in the unit SysUtils.

You need to use a try..finally block to make sure the stringlist gets
freed, hence the {$Mode ObjFpc} compiler switch at the beginning.
(In default mode FreePascal does not use exceptions and try..finally blocks)

In the program I also set DefaultFormatSettings.DecimalSeparator to
'.', just to be sure (on my Dutch Windows it is ','). The value is
needed in StrToFoatDef().

See attached test.lpr for what I did.
I'll attach the output as well.

Oddly the values for NodZ and NsdZ seem to be the same always, even
thoug the values of OldiNod and OldiNsd (used as input for
LongitudeString) are not the same (I tested this).

Not sure why.
I didn't look into the LongitudeString function though...

One other observation: you define the character for "degree" as an
extende ASCII character (#187).
This will only work on your codepage, it probably will not on mine.

Bart
-------------- next part --------------
KeKe, 1921/04/12,28º58,16º34, 4º25,15º11,20º16,17º02,26º26, 4º23, 4º23
KeVe, 1921/09/06,20º15,14º43, 2º19,13º23,28º49, 2º58, 3º20,25º43,25º43
KeSu, 1922/10/31,14º11,24º10,25º40,16º40, 7º29, 8º10,21º05, 6º34, 6º34
KeMo, 1923/03/06,21º48, 4º16,27º15, 7º09, 8º44,26º09,26º16,27º46,27º46
KeMa, 1923/10/02,15º09, 3º23, 9º02,20º58,27º01,25º50,28º24,18º21,18º21
KeRa, 1924/02/26,13º31,25º28,24º17,22º45, 1º06,24º43, 9º20, 9º21, 9º21
KeJu, 1925/03/10,26º17,21º26, 0º37,14º52,28º16,24º18,21º17,20º35,20º35
KeSa, 1926/02/09,26º51, 7º35,21º43,24º19, 7º12,15º13, 2º43, 2º33, 2º33
KeMe, 1927/03/15, 0º45,25º12,27º40,27º39,18º28,20º20,14º49,11º00,11º00
VeVe, 1928/03/06,22º31,19º09, 3º32,22º28,12º23,16º11,25º51,21º08,21º08
VeSu, 1931/06/19, 4º02,13º29,21º33,12º13,11º43, 0º59,28º45,18º10,18º10
VeMo, 1932/06/13,29º01,15º47,28º52,21º55, 0º28,25º34,11º09,28º42,28º42
VeMa, 1934/02/03,20º43,29º58, 0º50,23º59, 6º16, 0º13,25º15,26º21,26º21
VeRa, 1935/03/30,15º35,15º52,21º48,16º27,25º50,29º43,12º10, 5º32, 5º32
VeJu, 1938/03/14,29º56, 3º42, 5º23, 9º14, 8º20,26º24,13º04, 6º18, 6º18
VeSa, 1940/10/29,12º34,18º07, 4º32, 2º46,22º14,18º15,18º43,17º54,17º54
VeMe, 1943/12/13,27º13,14º33,14º29,12º25,16º57, 3º59, 0º18,14º30,14º30
VeKe, 1946/09/28,11º20,14º14,21º35,25º43, 9º15, 7º27,13º16,21º01,21º01
SuSu, 1947/11/22, 5º54,20º06,16º18,26º17, 3º18,13º10,29º24, 0º17, 0º17
SuMo, 1948/03/09,25º23, 6º40,29º44, 7º53,27º37, 3º43,23º55,22º36,22º36
SuMa, 1948/09/05,19º22,13º40, 9º12, 3º30, 7º55,26º35, 5º09,13º04,13º04
SuRa, 1949/01/09,25º27,14º13,11º16, 1º37,10º20,19º07,12º34, 8º30, 8º30
SuJu, 1949/11/29,13º28, 2º59,17º32, 0º23,24º37, 6º32,25º24,22º18,22º18
SuSa, 1950/09/13,26º39,10º25, 4º52,10º41,28º11, 7º03,29º08, 5º10, 5º10
SuMe, 1951/08/21, 4º08,26º36,21º21,23º55, 8º34,20º31, 7º37,16º41,16º41
SuKe, 1952/06/22, 7º29, 5º29,22º21, 6º44, 8º53,18º53,15º06,29º29,29º29
SuVe, 1952/10/26, 9º30, 9º44,28º35,11º39,16º54,24º28,26º33,25º12,25º12
MoMo, 1953/10/21, 4º16,15º02,28º17, 9º55,29º40, 3º12, 6º36, 5º39, 5º39
MoMa, 1954/08/17, 0º30, 6º41,25º36,15º35, 4º41,25º33,10º47,20º53,20º53
MoRa, 1955/03/15, 0º35,14º16, 3º30,18º45,18º26,26º38,27º46, 8º16, 8º16
MoJu, 1956/09/05,19º19,24º49,15º45, 3º31,26º27,18º56, 3º57, 9º17, 9º17
MoSa, 1957/12/29,13º55,13º45, 6º11,21º07,10º58, 4º56,25º50,15º22,15º22
MoMe, 1959/07/22, 5º20, 2º04,26º03,16º24, 7º46,28º50, 8º39,12º58,12º58
MoKe, 1960/12/13,27º52,18º34,14º53,10º02,21º48,16º27,24º07,16º34,16º34
MoVe, 1961/07/11,25º18, 7º20, 8º16,10º54,13º55,10º43, 3º49, 4º26, 4º26
MoSu, 1963/03/03,18º32,24º29,27º19, 5º09,13º09,28º56,23º44, 5º29, 5º29
MaMa, 1963/08/30,12º44,15º12, 9º07,12º47,27º58,25º26,25º10,26º11,26º11
MaRa, 1964/01/24, 9º51, 5º42,15º23,15º17,15º13,20º10,29º36,17º43,17º43
MaJu, 1965/02/05,22º48, 2º18, 9º28, 6º28, 4º20,23º51,11º40,27º58,27º58
MaSa, 1966/01/07,23º02,22º35, 5º46,20º24,18º22, 0º18,19º33,10º37,10º37
MaMe, 1967/02/10,27º20, 5º40,13º27,19º33, 6º00, 3º23, 4º06,17º01,17º01
MaKe, 1968/02/02,18º59, 1º19, 7º06,14º28,25º04, 9º46,14º48,27º38,27º38
MaVe, 1968/06/28,13º06, 8º39, 0º00,15º14,11º15, 8º29, 0º48,21º20,21º20
MaSu, 1969/08/22, 5º28,23º09,29º58,28º25,20º04,12º50,15º30,27º51,27º51
MaMo, 1969/12/26,10º47, 7º37, 0º21, 3º42,14º27, 8º03, 8º41,20º50,20º50
RaRa, 1970/07/24, 7º25,21º10,25º04,19º46,10º21, 3º59,27º37, 9º46, 9º46
RaJu, 1973/03/22, 7º55,15º23,22º50, 3º11, 3º11,11º47,21º22,19º38,19º38
RaSa, 1975/08/03,16º43,19º43,18º43,18º01,29º04, 0º57, 1º22, 4º40, 4º40
RaMe, 1978/05/25,10º03,16º55,19º19,10º10,25º55,14º08, 0º51,10º27,10º27
RaKe, 1980/11/28,12º30,28º33,25º07,11º29,11º03,12º01,13º55,19º50,19º50
RaVe, 1981/12/11,25º26,22º57,25º45, 7º56, 4º05, 9º03,26º26,29º11,29º11
RaSu, 1984/11/25, 9º26, 8º46, 1º08,19º47,13º27,19º41,27º05, 3º47, 3º47
RaMo, 1985/10/15,28º06,12º11,13º06, 4º39,28º31,13º41, 2º36,15º33,15º33
RaMa, 1987/04/08,24º08,14º31,29º21,18º54, 7º59,15º05,27º25,17º48,17º48
JuJu, 1988/04/20, 6º37,23º40, 6º06,21º12,15º12,15º56, 8º47,28º45,28º45
JuSa, 1990/05/28,12º52, 3º57,18º42, 3º40, 3º59,18º18, 1º11,15º31,15º31
JuMe, 1992/11/25, 9º24,19º19, 1º56,20º11, 3º45,15º01,19º23,27º43,27º43
JuKe, 1995/02/19, 6º15,22º36,12º19,22º32,26º19,19º02,19º24,14º03,14º03
JuVe, 1996/01/21, 6º36,15º53, 1º20,13º29,16º11,10º09,27º13,26º58,26º58
JuSu, 1998/09/07,20º31, 0º21, 4º42, 6º37,17º16, 0º23, 9º21, 7º38, 7º38
JuMo, 1999/06/22, 6º29,22º42, 0º51,21º24, 2º35, 5º07,19º31,20º06,20º06
JuMa, 2000/10/14,27º16, 7º29,20º49,29º58,23º10,17º00, 6º14,26º00,26º00
JuRa, 2001/09/15,28º31,26º35,24º41,28º56, 9º31,18º13,20º57, 9º03, 9º03
SaSa, 2004/01/27,12º39,19º33,20º28,21º11, 1º30,24º08,13º49,22º44,22º44
SaMe, 2007/01/14,29º39,28º56, 4º01,18º36, 4º04,16º51,29º46,23º49,23º49
SaKe, 2009/09/09,22º38,15º59,12º01,22º11,15º00,24º59,29º55, 5º03, 5º03
SaVe, 2010/10/13,25º43, 6º06,22º55,18º44,25º17, 1º38,15º13,11º58,11º58
SaSu, 2013/11/26,10º01,14º14,22º39,24º03,29º47,25º51,22º31,13º21,13º21
SaMo, 2014/11/03,16º36,27º20,28º12,18º52,11º41,26º35, 0º03,25º07,25º07
SaMa, 2016/05/26,11º16, 0º35,20º44, 8º06, 6º24,19º35,19º37,24º06,24º06
SaRa, 2017/06/29,13º32,21º31,22º33,29º34,22º03,19º40,29º24, 1º10, 1º10
SaJu, 2020/04/20, 6º25, 4º37,21º09,18º59,20º00, 2º10, 7º27, 7º02, 7º02
MeMe, 2022/10/19, 1º35,17º39,17º58, 0º38, 0º32, 6º42,24º25,19º22,19º22
MeKe, 2025/03/04,19º38,16º40, 6º57,16º31,23º12,18º19,26º52, 3º13, 3º13
MeVe, 2026/02/24,11º20, 6º58,27º58,22º59, 0º43,21º13, 6º55,14º45,14º45
MeSu, 2028/12/10,24º22, 6º55, 5º25,29º32, 0º42,27º39,10º46,19º58,19º58
MeMo, 2029/10/12,24º51,25º55,11º41,11º06,18º58, 9º28,29º38, 3º48, 3º48
MeMa, 2031/03/06,21º06,16º00, 3º03,23º17,24º28, 2º15, 8º38, 7º13, 7º13
MeRa, 2032/02/26,12º49,11º20, 0º12,18º06,20º17,28º26,21º50,17º28,17º28
MeJu, 2034/09/01,14º29,17º07, 6º52,28º33,10º14,18º15, 6º13,29º38,29º38
MeSa, 2036/11/25, 9º07, 1º02,27º14,11º23,18º09,29º04, 8º13,16º04,16º04
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.lpr
Type: application/octet-stream
Size: 10432 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110706/2f9b1ed3/attachment.obj>


More information about the fpc-pascal mailing list