Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Why does this string not fully display in a Edit2.text ? Posted by rtdvoip on 30 Sept 2003 at 11:13 AM
Hiya fellas,

Here is my problem with code extracts:


filestring,mystring: string[30];

while filestring[i] <> ',' do
  begin
   mystring[incr] := filestring[i];
   i:=i+1;
   incr:=incr+1;
  end;
 Edit2.Text := mystring;


In the Edit2.text field, all I get is the first index of mystring.
But with the in another Edit#.text with the same assignment using
filestring, I get the complete string.
Only difference is that filestring is a readln from a file
and mystring is incremented depending on filestring.
Is it because mystring does not have a eoln marker?
Or is it something different?

Thanks in advance for your help,
rtdvoip


Report
Re: Why does this string not fully display in a Edit2.text ? Posted by zibadian on 30 Sept 2003 at 12:53 PM
: Hiya fellas,
:
: Here is my problem with code extracts:
:
:
: 
: filestring,mystring: string[30];
: 
: while filestring[i] <> ',' do
:   begin
:    mystring[incr] := filestring[i];
:    i:=i+1;
:    incr:=incr+1;
:   end;
:  Edit2.Text := mystring;
: 
: 

:
: In the Edit2.text field, all I get is the first index of mystring.
: But with the in another Edit#.text with the same assignment using
: filestring, I get the complete string.
: Only difference is that filestring is a readln from a file
: and mystring is incremented depending on filestring.
: Is it because mystring does not have a eoln marker?
: Or is it something different?
:
: Thanks in advance for your help,
: rtdvoip
:
:
:
What did you set as the initial value of i? It should be set to 1.
Report
Re: Why does this string not fully display in a Edit2.text ? Posted by rtdvoip on 30 Sept 2003 at 1:33 PM
: : Hiya fellas,
: :
: : Here is my problem with code extracts:
: :
: :
: : 
: : filestring,mystring: string[30];
: : 
: : while filestring[i] <> ',' do
: :   begin
: :    mystring[incr] := filestring[i];
: :    i:=i+1;
: :    incr:=incr+1;
: :   end;
: :  Edit2.Text := mystring;
: : 
: : 

: :
: : In the Edit2.text field, all I get is the first index of mystring.
: : But with the in another Edit#.text with the same assignment using
: : filestring, I get the complete string.
: : Only difference is that filestring is a readln from a file
: : and mystring is incremented depending on filestring.
: : Is it because mystring does not have a eoln marker?
: : Or is it something different?
: :
: : Thanks in advance for your help,
: : rtdvoip
: :
: :
: :
: What did you set as the initial value of i? It should be set to 1.
:
i and incr was set to 1.

Report
Re: Why does this string not fully display in a Edit2.text ? Posted by rtdvoip on 30 Sept 2003 at 3:38 PM
: : : Hiya fellas,
: : :
: : : Here is my problem with code extracts:
: : :
: : :
: : : 
: : : filestring,mystring: string[30];
: : : 
: : : while filestring[i] <> ',' do
: : :   begin
: : :    mystring[incr] := filestring[i];
: : :    i:=i+1;
: : :    incr:=incr+1;
: : :   end;
: : :  Edit2.Text := mystring;
: : : 
: : : 

: : :
: : : In the Edit2.text field, all I get is the first index of mystring.
: : : But with the in another Edit#.text with the same assignment using
: : : filestring, I get the complete string.
: : : Only difference is that filestring is a readln from a file
: : : and mystring is incremented depending on filestring.
: : : Is it because mystring does not have a eoln marker?
: : : Or is it something different?
: : :
: : : Thanks in advance for your help,
: : : rtdvoip
: : :
: : :
: : :
: : What did you set as the initial value of i? It should be set to 1.
: :
: i and incr was set to 1.
:
:
I change my procedure of getting the string into the needed fields.
Below is the exchange..
procedure TForm1.Button1Click(Sender: TObject);
var
 vlStringList: TStringList;
 filein: textfile;
 filestring: String;
begin
 assignfile (filein,'C:\test.txt');
 reset(filein);
 while not eof(filein) do
 Begin
  Edit1.Text:= 'Running';
  readln(filein,filestring);
  vlStringList := TStringList.Create();;
  vlStringList.Delimiter := ',';
  vlStringList.DelimitedText:=filestring;
  Query1.ParamByName('Rate_Plan').AsString := vlStringList[0];
  Query1.ParamByName('Target').AsString := vlstringList[1];
  Query1.ParamByName('Breakout').AsString := vlstringList[2];
  Query1.ParamByName('Price').AsString := vlstringList[3];
  Query1.Close;
  Query1.ExecSQL;
  Query1.Close;
 end;
 Edit1.Text := 'Finished';
end;

Thanks for the help,
rtdvoip

Report
Re: Why does this string not fully display in a Edit2.text ? Posted by rtdvoip on 30 Sept 2003 at 3:39 PM
: : : : Hiya fellas,
: : : :
: : : : Here is my problem with code extracts:
: : : :
: : : :
: : : : 
: : : : filestring,mystring: string[30];
: : : : 
: : : : while filestring[i] <> ',' do
: : : :   begin
: : : :    mystring[incr] := filestring[i];
: : : :    i:=i+1;
: : : :    incr:=incr+1;
: : : :   end;
: : : :  Edit2.Text := mystring;
: : : : 
: : : : 

: : : :
: : : : In the Edit2.text field, all I get is the first index of mystring.
: : : : But with the in another Edit#.text with the same assignment using
: : : : filestring, I get the complete string.
: : : : Only difference is that filestring is a readln from a file
: : : : and mystring is incremented depending on filestring.
: : : : Is it because mystring does not have a eoln marker?
: : : : Or is it something different?
: : : :
: : : : Thanks in advance for your help,
: : : : rtdvoip
: : : :
: : : :
: : : :
: : : What did you set as the initial value of i? It should be set to 1.
: : :
: : i and incr was set to 1.
: :
: :
: I change my procedure of getting the string into the needed fields.
: Below is the exchange..
:
: procedure TForm1.Button1Click(Sender: TObject);
: var
:  vlStringList: TStringList;
:  filein: textfile;
:  filestring: String;
: begin
:  assignfile (filein,'C:\test.txt');
:  reset(filein);
:  while not eof(filein) do
:  Begin
:   Edit1.Text:= 'Running';
:   readln(filein,filestring);
:   vlStringList := TStringList.Create();;
:   vlStringList.Delimiter := ',';
:   vlStringList.DelimitedText:=filestring;
:   Query1.ParamByName('Rate_Plan').AsString := vlStringList[0];
:   Query1.ParamByName('Target').AsString := vlstringList[1];
:   Query1.ParamByName('Breakout').AsString := vlstringList[2];
:   Query1.ParamByName('Price').AsString := vlstringList[3];
:   Query1.Close;
:   Query1.ExecSQL;
:   Query1.Close;
:  end;
:  Edit1.Text := 'Finished';
: end;
: 

:
: Thanks for the help,
: rtdvoip
:
:

Report
Re: Why does this string not fully display in a Edit2.text ? Posted by zibadian on 1 Oct 2003 at 2:43 AM
: : : : : Hiya fellas,
: : : : :
: : : : : Here is my problem with code extracts:
: : : : :
: : : : :
: : : : : 
: : : : : filestring,mystring: string[30];
: : : : : 
: : : : : while filestring[i] <> ',' do
: : : : :   begin
: : : : :    mystring[incr] := filestring[i];
: : : : :    i:=i+1;
: : : : :    incr:=incr+1;
: : : : :   end;
: : : : :  Edit2.Text := mystring;
: : : : : 
: : : : : 

: : : : :
: : : : : In the Edit2.text field, all I get is the first index of mystring.
: : : : : But with the in another Edit#.text with the same assignment using
: : : : : filestring, I get the complete string.
: : : : : Only difference is that filestring is a readln from a file
: : : : : and mystring is incremented depending on filestring.
: : : : : Is it because mystring does not have a eoln marker?
: : : : : Or is it something different?
: : : : :
: : : : : Thanks in advance for your help,
: : : : : rtdvoip
: : : : :
: : : : :
: : : : :
: : : : What did you set as the initial value of i? It should be set to 1.
: : : :
: : : i and incr was set to 1.
: : :
: : :
: : I change my procedure of getting the string into the needed fields.
: : Below is the exchange..
: :
: : procedure TForm1.Button1Click(Sender: TObject);
: : var
: :  vlStringList: TStringList;
: :  filein: textfile;
: :  filestring: String;
: : begin
: :  assignfile (filein,'C:\test.txt');
: :  reset(filein);
: :  while not eof(filein) do
: :  Begin
: :   Edit1.Text:= 'Running';
: :   readln(filein,filestring);
: :   vlStringList := TStringList.Create();;
: :   vlStringList.Delimiter := ',';
: :   vlStringList.DelimitedText:=filestring;
: :   Query1.ParamByName('Rate_Plan').AsString := vlStringList[0];
: :   Query1.ParamByName('Target').AsString := vlstringList[1];
: :   Query1.ParamByName('Breakout').AsString := vlstringList[2];
: :   Query1.ParamByName('Price').AsString := vlstringList[3];
: :   Query1.Close;
: :   Query1.ExecSQL;
: :   Query1.Close;
: :  end;
: :  Edit1.Text := 'Finished';
: : end;
: : 

: :
: : Thanks for the help,
: : rtdvoip
: :
: :
There is just 1 thing, which might pose problems: you don't free the stringlist object. By the way, when I started here I posted a small function, which returns an indexed part of a string bound by a character delimited. Here is the link: http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=4&MsgID=64086
Perhaps you might find it useful in the future.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.