Why does this string not fully display in a Edit2.text ? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Why does this string not fully display in a Edit2.text ?

Hiya fellas,

Here is my problem with code extracts:

[code]

filestring,mystring: string[30];

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

[code]

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


Comments

  • zibadianzibadian Posts: 6,349Member
    : Hiya fellas,
    :
    : Here is my problem with code extracts:
    :
    : [code]
    :
    : filestring,mystring: string[30];
    :
    : while filestring[i] <> ',' do
    : begin
    : mystring[incr] := filestring[i];
    : i:=i+1;
    : incr:=incr+1;
    : end;
    : Edit2.Text := mystring;
    :
    : [/code]
    :
    : 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.
  • rtdvoiprtdvoip Posts: 30Member
    : : Hiya fellas,
    : :
    : : Here is my problem with code extracts:
    : :
    : : [code]
    : :
    : : filestring,mystring: string[30];
    : :
    : : while filestring[i] <> ',' do
    : : begin
    : : mystring[incr] := filestring[i];
    : : i:=i+1;
    : : incr:=incr+1;
    : : end;
    : : Edit2.Text := mystring;
    : :
    : : [/code]
    : :
    : : 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.

  • rtdvoiprtdvoip Posts: 30Member
    : : : Hiya fellas,
    : : :
    : : : Here is my problem with code extracts:
    : : :
    : : : [code]
    : : :
    : : : filestring,mystring: string[30];
    : : :
    : : : while filestring[i] <> ',' do
    : : : begin
    : : : mystring[incr] := filestring[i];
    : : : i:=i+1;
    : : : incr:=incr+1;
    : : : end;
    : : : Edit2.Text := mystring;
    : : :
    : : : [/code]
    : : :
    : : : 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..
    [code]
    procedure TForm1.Button1Click(Sender: TObject);
    var
    vlStringList: TStringList;
    filein: textfile;
    filestring: String;
    begin
    assignfile (filein,'C: est.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;
    [code]

    Thanks for the help,
    rtdvoip

  • rtdvoiprtdvoip Posts: 30Member
    : : : : Hiya fellas,
    : : : :
    : : : : Here is my problem with code extracts:
    : : : :
    : : : : [code]
    : : : :
    : : : : filestring,mystring: string[30];
    : : : :
    : : : : while filestring[i] <> ',' do
    : : : : begin
    : : : : mystring[incr] := filestring[i];
    : : : : i:=i+1;
    : : : : incr:=incr+1;
    : : : : end;
    : : : : Edit2.Text := mystring;
    : : : :
    : : : : [/code]
    : : : :
    : : : : 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..
    : [code]
    : procedure TForm1.Button1Click(Sender: TObject);
    : var
    : vlStringList: TStringList;
    : filein: textfile;
    : filestring: String;
    : begin
    : assignfile (filein,'C: est.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;
    : [/code]
    :
    : Thanks for the help,
    : rtdvoip
    :
    :

  • zibadianzibadian Posts: 6,349Member
    : : : : : Hiya fellas,
    : : : : :
    : : : : : Here is my problem with code extracts:
    : : : : :
    : : : : : [code]
    : : : : :
    : : : : : filestring,mystring: string[30];
    : : : : :
    : : : : : while filestring[i] <> ',' do
    : : : : : begin
    : : : : : mystring[incr] := filestring[i];
    : : : : : i:=i+1;
    : : : : : incr:=incr+1;
    : : : : : end;
    : : : : : Edit2.Text := mystring;
    : : : : :
    : : : : : [/code]
    : : : : :
    : : : : : 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..
    : : [code]
    : : procedure TForm1.Button1Click(Sender: TObject);
    : : var
    : : vlStringList: TStringList;
    : : filein: textfile;
    : : filestring: String;
    : : begin
    : : assignfile (filein,'C: est.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;
    : : [/code]
    : :
    : : 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.
Sign In or Register to comment.