@@ -585,6 +585,43 @@ function SXToStr(de: double): string;
585
585
Result := d + ' :' + m + ' :' + s;
586
586
end ;
587
587
588
+ function StrToSX (sx: string): double;
589
+ const sep = ' :' ;
590
+ var
591
+ s, p: integer;
592
+ t: string;
593
+ begin
594
+ try
595
+ sx := StringReplace(sx, ' ' , ' 0' , [rfReplaceAll]);
596
+ if copy(sx, 1 , 1 ) = ' -' then
597
+ s := -1
598
+ else
599
+ s := 1 ;
600
+ p := pos(sep, sx);
601
+ if p = 0 then
602
+ Result := StrToFloatDef(sx, -9999 )
603
+ else
604
+ begin
605
+ t := copy(sx, 1 , p - 1 );
606
+ Delete(sx, 1 , p);
607
+ Result := StrToIntDef(t, 0 );
608
+ p := pos(sep, sx);
609
+ if p = 0 then
610
+ Result := Result + s * StrToIntDef(sx, 0 ) / 60
611
+ else
612
+ begin
613
+ t := copy(sx, 1 , p - 1 );
614
+ Delete(sx, 1 , p);
615
+ Result := Result + s * StrToIntDef(t, 0 ) / 60 ;
616
+ Result := Result + s * StrToFloatDef(sx, 0 ) / 3600 ;
617
+ end ;
618
+ end ;
619
+ except
620
+ Result := -9999 ;
621
+ end ;
622
+
623
+ end ;
624
+
588
625
function IndiFormatFloat (x: double; fmt: string): string;
589
626
begin
590
627
if copy(fmt, Length(fmt), 1 ) = ' m' then
@@ -602,6 +639,20 @@ function IndiFormatFloat(x: double; fmt: string): string;
602
639
end ;
603
640
end ;
604
641
642
+ function IndiStr2Float (txt, fmt: string; out value : double): integer;
643
+ begin
644
+ if copy(fmt, Length(fmt), 1 ) = ' m' then begin
645
+ value :=StrToSX(txt);
646
+ if value =-9999 then
647
+ result:=1
648
+ else
649
+ result:=0 ;
650
+ end
651
+ else begin
652
+ val(txt, value , result);
653
+ end ;
654
+ end ;
655
+
605
656
procedure Tf_indigui.CreateNumberWidget (iprop: TIndiProp);
606
657
var
607
658
lbl: TLabel;
@@ -1036,11 +1087,15 @@ procedure Tf_indigui.SetButtonClick(Sender: TObject);
1036
1087
entry := TEdit(iprop.entry.Objects[j]);
1037
1088
if entry.Text <> ' ' then
1038
1089
begin
1039
- val (entry.Text, Value , er );
1040
- if er = 0 then
1090
+ er:=IndiStr2Float (entry.Text,nvp.np[i].format, Value );
1091
+ if er = 0 then begin
1041
1092
nvp.np[i].Value := Value ;
1093
+ buf := buf + nvp.np[i].Name + ' =' + FloatToStr(nvp.np[i].Value ) + ' ' ;
1094
+ end
1095
+ else begin
1096
+ buf := buf + nvp.np[i].Name + ' not numeric ' +entry.Text+ ' ' ;
1097
+ end ;
1042
1098
entry.Clear;
1043
- buf := buf + nvp.np[i].Name + ' =' + FloatToStr(nvp.np[i].Value ) + ' ' ;
1044
1099
end ;
1045
1100
end ;
1046
1101
indiclient.sendNewNumber(nvp);
0 commit comments