Help me plz...

Im trying to write a simple application..

that converts ' 0.0.0.0 / l:user p:pass port:21 ' this
to this ' ftp://user:pass@0.0.0.0:21 /'

thought it was straight forward until i hit a wall..

im trying to find the commaned that searches the edit1.Text that the user entered ' 0.0.0.0 / l:user p:pass port:21 ' for the ip'0.0.0.0' then adds it to the var address then searches edit1.text again to find the l:user then addes it to the var login_name.. etc..

i tryed searching in the help files for " find,scan " with no luck :(..

thanks in advance ;)

Comments

  • : Im trying to write a simple application..
    :
    : that converts ' 0.0.0.0 / l:user p:pass port:21 ' this
    : to this ' ftp://user:pass@0.0.0.0:21 /'
    :
    : thought it was straight forward until i hit a wall..
    :
    : im trying to find the commaned that searches the edit1.Text that the user entered ' 0.0.0.0 / l:user p:pass port:21 ' for the ip'0.0.0.0' then adds it to the var address then searches edit1.text again to find the l:user then addes it to the var login_name.. etc..
    :
    : i tryed searching in the help files for " find,scan " with no luck :(..
    :
    : thanks in advance ;)
    :
    With Pos() you get the index of a substring in a string. Then you can Copy() (Delphi function) it into a different variable. Lastly you can use Delete() to remove it from the complete text. Here is an example to get the IP address from the entered text:
    [code]
    EnteredText := Edit1.Text;
    IPAddress := Copy(EnteredText, 1, Pos('/')-1); //Get everything before the first "/"
    IPAddress := Trim(IPAddress); // remove spaces around the IP
    Delete(EnteredText, 1, Pos('/')); // Remove everything including the first "/"
    [/code]
    Note: for this to work you need to copy the Text property into a string, otherwise the Delete() won't work.
    You can use the same method to get the user name by stripping the updated EnteredText until "p:". And so on for all the other parts.
    After you have the parts you can add them together in any sequence you like.
  • : : Im trying to write a simple application..
    : :
    : : that converts ' 0.0.0.0 / l:user p:pass port:21 ' this
    : : to this ' ftp://user:pass@0.0.0.0:21 /'
    : :
    : : thought it was straight forward until i hit a wall..
    : :
    : : im trying to find the commaned that searches the edit1.Text that the user entered ' 0.0.0.0 / l:user p:pass port:21 ' for the ip'0.0.0.0' then adds it to the var address then searches edit1.text again to find the l:user then addes it to the var login_name.. etc..
    : :
    : : i tryed searching in the help files for " find,scan " with no luck :(..
    : :
    : : thanks in advance ;)
    : :
    : With Pos() you get the index of a substring in a string. Then you can Copy() (Delphi function) it into a different variable. Lastly you can use Delete() to remove it from the complete text. Here is an example to get the IP address from the entered text:
    : [code]
    : EnteredText := Edit1.Text;
    : IPAddress := Copy(EnteredText, 1, Pos('/')-1); //Get everything before the first "/"
    : IPAddress := Trim(IPAddress); // remove spaces around the IP
    : Delete(EnteredText, 1, Pos('/')); // Remove everything including the first "/"
    : [/code]
    : Note: for this to work you need to copy the Text property into a string, otherwise the Delete() won't work.
    : You can use the same method to get the user name by stripping the updated EnteredText until "p:". And so on for all the other parts.
    : After you have the parts you can add them together in any sequence you like.
    :
    :**********************************************************************:**********************************************************************
    :Thanks For replying so fast ;)
    :
    :I tried this exact code
    : [code]
    :procedure TForm1.Button1Click(Sender: TObject);
    :var
    :IPAddress, login_name, pass_word, EnteredText : string;
    :port_num : integer;
    :begin
    : EnteredText := Edit1.Text;
    : IPAddress := Copy(EnteredText, 1, Pos('/')-1);
    : IPAddress := Trim(IPAddress);
    : Delete(EnteredText, 1, Pos('/'));
    :end;

    : [/code]

    it came out with 2 errors
    : [code]
    1)IPAddress := Copy(EnteredText, 1, Pos('/')"|"-1); //"|" here it say's "Not Enough actual parameters"

    2)Delete(EnteredText, 1, Pos('/')"|"); // "|" here it says "Not Enough actual parameters"
    [/code]
    wish you could tell me whats missing.
    thanks ...

  • : : : Im trying to write a simple application..
    : : :
    : : : that converts ' 0.0.0.0 / l:user p:pass port:21 ' this
    : : : to this ' ftp://user:pass@0.0.0.0:21 /'
    : : :
    : : : thought it was straight forward until i hit a wall..
    : : :
    : : : im trying to find the commaned that searches the edit1.Text that the user entered ' 0.0.0.0 / l:user p:pass port:21 ' for the ip'0.0.0.0' then adds it to the var address then searches edit1.text again to find the l:user then addes it to the var login_name.. etc..
    : : :
    : : : i tryed searching in the help files for " find,scan " with no luck :(..
    : : :
    : : : thanks in advance ;)
    : : :
    : : With Pos() you get the index of a substring in a string. Then you can Copy() (Delphi function) it into a different variable. Lastly you can use Delete() to remove it from the complete text. Here is an example to get the IP address from the entered text:
    : : [code]
    : : EnteredText := Edit1.Text;
    : : IPAddress := Copy(EnteredText, 1, Pos('/')-1); //Get everything before the first "/"
    : : IPAddress := Trim(IPAddress); // remove spaces around the IP
    : : Delete(EnteredText, 1, Pos('/')); // Remove everything including the first "/"
    : : [/code]
    : : Note: for this to work you need to copy the Text property into a string, otherwise the Delete() won't work.
    : : You can use the same method to get the user name by stripping the updated EnteredText until "p:". And so on for all the other parts.
    : : After you have the parts you can add them together in any sequence you like.
    : :
    : :**********************************************************************:**********************************************************************
    : :Thanks For replying so fast ;)
    : :
    : :I tried this exact code
    : : [code]
    : :procedure TForm1.Button1Click(Sender: TObject);
    : :var
    : :IPAddress, login_name, pass_word, EnteredText : string;
    : :port_num : integer;
    : :begin
    : : EnteredText := Edit1.Text;
    : : IPAddress := Copy(EnteredText, 1, Pos('/')-1);
    : : IPAddress := Trim(IPAddress);
    : : Delete(EnteredText, 1, Pos('/'));
    : :end;
    :
    : : [/code]
    :
    : it came out with 2 errors
    : : [code]
    : 1)IPAddress := Copy(EnteredText, 1, Pos('/')"|"-1); //"|" here it say's "Not Enough actual parameters"
    :
    : 2)Delete(EnteredText, 1, Pos('/')"|"); // "|" here it says "Not Enough actual parameters"
    : [/code]
    : wish you could tell me whats missing.
    : thanks ...
    :
    :
    Both have the same error: Pos('/', EnteredText).
  • [b][red]This message was edited by SNM at 2003-7-19 0:55:37[/red][/b][hr]
    thank again it worked , but the formula seems worng ..
    i used this ..

    [code]
    procedure TForm1.Button1Click(Sender: TObject);
    var
    IPAddress, login_name, pass_word, path, EnteredText : string;
    port_num : string;
    begin
    EnteredText := Edit1.Text;

    IPAddress := Copy(EnteredText, 1, Pos('/',EnteredText)-1);
    IPAddress := Trim(IPAddress);





    EnteredText := Edit1.Text;
    login_name := Copy(EnteredText,Pos('l:',EnteredText), Pos('p:',EnteredText)-2);
    login_name := Trim(login_name);



    EnteredText := Edit1.Text;
    pass_word := Copy(EnteredText,Pos('p:',EnteredText), Pos('port:',EnteredText)-1);
    pass_word := Trim(pass_word);


    EnteredText := Edit1.Text;
    port_num := Copy(EnteredText,Pos('port:',EnteredText), Pos('0',EnteredText)-1);
    port_num := Trim(port_num);


    edit2.Text := 'ftp://'+ login_name + ':' + pass_word + '@' + IPAddress + ':' + port_num + path;
    [/code]

    the input was this
    0.0.0.0 / l:user p:pass port:21
    the output came out like this
    ftp://l:user p:pass po:p:pass port:21@0.0.0.0:

    i would love from you to point me where i went wrong...
    i hope im not asking much ;)

    never mind , i didnt get the rest of what u said earlier
    the Delete() its working now
    thanks a mill ;)
    love this message board look to see me asking more ;)

  • [b][red]This message was edited by zibadian at 2003-7-19 7:42:59[/red][/b][hr]
    : [b][red]This message was edited by SNM at 2003-7-19 0:55:37[/red][/b][hr]
    : thank again it worked , but the formula seems worng ..
    : i used this ..
    :
    : [code]
    : procedure TForm1.Button1Click(Sender: TObject);
    : var
    : IPAddress, login_name, pass_word, path, EnteredText : string;
    : port_num : string;
    : begin
    : EnteredText := Edit1.Text;
    :
    : IPAddress := Copy(EnteredText, 1, Pos('/',EnteredText)-1);
    : IPAddress := Trim(IPAddress);
    :
    :
    :
    :
    :
    : EnteredText := Edit1.Text;
    : login_name := Copy(EnteredText,Pos('l:',EnteredText), Pos('p:',EnteredText)-2);
    : login_name := Trim(login_name);
    :
    :
    :
    : EnteredText := Edit1.Text;
    : pass_word := Copy(EnteredText,Pos('p:',EnteredText), Pos('port:',EnteredText)-1);
    : pass_word := Trim(pass_word);
    :
    :
    : EnteredText := Edit1.Text;
    : port_num := Copy(EnteredText,Pos('port:',EnteredText), Pos('0',EnteredText)-1);
    : port_num := Trim(port_num);
    :
    :
    : edit2.Text := 'ftp://'+ login_name + ':' + pass_word + '@' + IPAddress + ':' + port_num + path;
    : [/code]
    :
    : the input was this
    : 0.0.0.0 / l:user p:pass port:21
    : the output came out like this
    : ftp://l:user p:pass po:p:pass port:21@0.0.0.0:
    :
    : i would love from you to point me where i went wrong...
    : i hope im not asking much ;)
    :
    : never mind , i didnt get the rest of what u said earlier
    : the Delete() its working now
    : thanks a mill ;)
    : love this message board look to see me asking more ;)
    :
    :
    As is said in the help, Copy has the following parameters:
    - string
    - start index
    - length of resulting string
    You used the Copy with the following parameters:
    - string
    - start index
    - [b]end index[/b]
    Also you need to start later than the start position of 'p:', because you don't want to copy the "p:" itself. A correct copy would be something like this:
    [code]
    pass_word := Copy(EnteredText,
    Pos('p:',EnteredText)+2, // remove the "p:"
    Pos('port:',EnteredText)-Pos('p:',EnteredText)+2-1); // calc length
    [/code]
    If you use the Delete() to remove the part you just Copy()ed, then you don't need to worry about calculating the length.

Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion