Discussion:
Psock in Uses Clause
(too old to reply)
Keith Wright
2007-10-10 02:40:00 UTC
Permalink
I am trying to migrate and application from Delphi 6 to Delphi 2007 but it
is asking for a Psock in my uses clause. The source of my error seems to be
a String manipulation where I pull a value from a table, ignore the first
character 'H', then manipulate the remaining characters (integer) and
finally add the 'H' back onto the front of the string.
The source looks like this:
MaxVal := qryMaxRef.FieldByName('Max_Ref').Value;
//confirm that it is a Hydro Reference Number
if (NthPos(MaxVal,'H',1)) = 1 then
begin
MaxVal := Copy(MaxVal,2,10);
MaxVal := InttoStr(StrtoInt(MaxVal)+1);
MaxVal := 'H'+MaxVal;
Since the FastNet components were not included in the Delphi 2007, how can I
acheive the same string manipulation? The key is the NthPos line, that seems
to be where the Psock is being referenced.
Any help is much appreciated.
Keith Wright
Developer
Canada
Andy Teal
2007-10-10 10:41:40 UTC
Permalink
can't you replace the check with:
if (MaxVal[1]='H') then ....

Cheers,
Andy T
Post by Keith Wright
I am trying to migrate and application from Delphi 6 to Delphi 2007 but it
is asking for a Psock in my uses clause. The source of my error seems to be
a String manipulation where I pull a value from a table, ignore the first
character 'H', then manipulate the remaining characters (integer) and
finally add the 'H' back onto the front of the string.
MaxVal := qryMaxRef.FieldByName('Max_Ref').Value;
//confirm that it is a Hydro Reference Number
if (NthPos(MaxVal,'H',1)) = 1 then
begin
MaxVal := Copy(MaxVal,2,10);
MaxVal := InttoStr(StrtoInt(MaxVal)+1);
MaxVal := 'H'+MaxVal;
Since the FastNet components were not included in the Delphi 2007, how can
I acheive the same string manipulation? The key is the NthPos line, that
seems to be where the Psock is being referenced.
Any help is much appreciated.
Keith Wright
Developer
Canada
Keith Wright
2007-10-10 18:57:09 UTC
Permalink
OK Thanks Andy that seems to work. Now I found another reference later in my
application I use the NthPos to determine the position of a space in a
string like this:

procedure TfrmSaveH.LocTest;
var
FLStr : String;
Sp1, Sp2, Sp3 : Integer;
begin
//determine Test Reference
FLStr := frmMainH.edTestName.Text;
//find position of blanks
Sp1 := NthPos(FLStr,' ',1);
Sp2 := NthPos(FLStr,' ',2);
Sp3 := NthPos(FLStr,' ',3);
Any idea what the equivalent is? or better yet, what do I search in my help
files to find the answer?
Thanks,
Keith
Post by Andy Teal
if (MaxVal[1]='H') then ....
Cheers,
Andy T
Post by Keith Wright
I am trying to migrate and application from Delphi 6 to Delphi 2007 but it
is asking for a Psock in my uses clause. The source of my error seems to
be a String manipulation where I pull a value from a table, ignore the
first character 'H', then manipulate the remaining characters (integer)
and finally add the 'H' back onto the front of the string.
MaxVal := qryMaxRef.FieldByName('Max_Ref').Value;
//confirm that it is a Hydro Reference Number
if (NthPos(MaxVal,'H',1)) = 1 then
begin
MaxVal := Copy(MaxVal,2,10);
MaxVal := InttoStr(StrtoInt(MaxVal)+1);
MaxVal := 'H'+MaxVal;
Since the FastNet components were not included in the Delphi 2007, how
can I acheive the same string manipulation? The key is the NthPos line,
that seems to be where the Psock is being referenced.
Any help is much appreciated.
Keith Wright
Developer
Canada
Andy Teal
2007-10-12 15:10:11 UTC
Permalink
You need to be looking at pos (substr, instr) in the help which returns the
position of substr within instr
(returns 0 if not found)

Cheers,
Andy
Post by Keith Wright
OK Thanks Andy that seems to work. Now I found another reference later in
my application I use the NthPos to determine the position of a space in a
procedure TfrmSaveH.LocTest;
var
FLStr : String;
Sp1, Sp2, Sp3 : Integer;
begin
//determine Test Reference
FLStr := frmMainH.edTestName.Text;
//find position of blanks
Sp1 := NthPos(FLStr,' ',1);
Sp2 := NthPos(FLStr,' ',2);
Sp3 := NthPos(FLStr,' ',3);
Any idea what the equivalent is? or better yet, what do I search in my
help files to find the answer?
Thanks,
Keith
Post by Andy Teal
if (MaxVal[1]='H') then ....
Cheers,
Andy T
Post by Keith Wright
I am trying to migrate and application from Delphi 6 to Delphi 2007 but
it is asking for a Psock in my uses clause. The source of my error seems
to be a String manipulation where I pull a value from a table, ignore the
first character 'H', then manipulate the remaining characters (integer)
and finally add the 'H' back onto the front of the string.
MaxVal := qryMaxRef.FieldByName('Max_Ref').Value;
//confirm that it is a Hydro Reference Number
if (NthPos(MaxVal,'H',1)) = 1 then
begin
MaxVal := Copy(MaxVal,2,10);
MaxVal := InttoStr(StrtoInt(MaxVal)+1);
MaxVal := 'H'+MaxVal;
Since the FastNet components were not included in the Delphi 2007, how
can I acheive the same string manipulation? The key is the NthPos line,
that seems to be where the Psock is being referenced.
Any help is much appreciated.
Keith Wright
Developer
Canada
Keith Wright
2007-10-14 05:04:01 UTC
Permalink
Thanks Andy, I used the PosEx like this:
Sp1 := PosEx(' ',FLStr,1);
Sp2 := PosEx(' ',FLStr,Sp1+1);
Sp3 := PosEx(' ',FLStr,Sp2+1);
which located the spaces in my string.
Thanks again,
Keith
Post by Andy Teal
You need to be looking at pos (substr, instr) in the help which returns
the position of substr within instr
(returns 0 if not found)
Cheers,
Andy
Post by Keith Wright
OK Thanks Andy that seems to work. Now I found another reference later in
my application I use the NthPos to determine the position of a space in a
procedure TfrmSaveH.LocTest;
var
FLStr : String;
Sp1, Sp2, Sp3 : Integer;
begin
//determine Test Reference
FLStr := frmMainH.edTestName.Text;
//find position of blanks
Sp1 := NthPos(FLStr,' ',1);
Sp2 := NthPos(FLStr,' ',2);
Sp3 := NthPos(FLStr,' ',3);
Any idea what the equivalent is? or better yet, what do I search in my
help files to find the answer?
Thanks,
Keith
Post by Andy Teal
if (MaxVal[1]='H') then ....
Cheers,
Andy T
Post by Keith Wright
I am trying to migrate and application from Delphi 6 to Delphi 2007 but
it is asking for a Psock in my uses clause. The source of my error seems
to be a String manipulation where I pull a value from a table, ignore
the first character 'H', then manipulate the remaining characters
(integer) and finally add the 'H' back onto the front of the string.
MaxVal := qryMaxRef.FieldByName('Max_Ref').Value;
//confirm that it is a Hydro Reference Number
if (NthPos(MaxVal,'H',1)) = 1 then
begin
MaxVal := Copy(MaxVal,2,10);
MaxVal := InttoStr(StrtoInt(MaxVal)+1);
MaxVal := 'H'+MaxVal;
Since the FastNet components were not included in the Delphi 2007, how
can I acheive the same string manipulation? The key is the NthPos line,
that seems to be where the Psock is being referenced.
Any help is much appreciated.
Keith Wright
Developer
Canada
Loading...