Recent

Author Topic: Why Doesn't this work.....?  (Read 5628 times)

captian jaster

  • Guest
Why Doesn't this work.....?
« on: October 18, 2010, 11:07:02 pm »
 :( Weird....
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. Var
  3. S:String;
  4. P1,P2:SizeInt;
  5. begin
  6.   S := '[Test]';
  7.   P1 := Pos(S,'[');
  8.   P2 := Pos(S,']');
  9.   ShowMessage(Copy(S,P1,P2));
  10. end;
  11.  
It returns a blank text D:

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Why Doesn't this work.....?
« Reply #1 on: October 18, 2010, 11:12:21 pm »
Try reversing the arguments to Pos.

Thanks.

-Phil

captian jaster

  • Guest
Re: Why Doesn't this work.....?
« Reply #2 on: October 18, 2010, 11:40:09 pm »
Try reversing the arguments to Pos.

Thanks.

-Phil

Nope...
Weird :\

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Why Doesn't this work.....?
« Reply #3 on: October 18, 2010, 11:44:48 pm »
It doesn't work because your copying nothing.
What is your point?

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: Why Doesn't this work.....?
« Reply #4 on: October 18, 2010, 11:55:44 pm »
Try reversing the arguments to Pos.
Nope...
Weird :\
Well, "Pos('[', S)" works for me...
BTW: the second argument for Copy should be the number of characters, not the end position.

Gr.
Dirk.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Why Doesn't this work.....?
« Reply #5 on: October 19, 2010, 12:15:14 am »
Quote
Well, "Pos('[', S)" works for me...

Yes, thats the right procedure using pos function

captian jaster

  • Guest
Re: Why Doesn't this work.....?
« Reply #6 on: October 19, 2010, 01:18:33 am »
Oh So I was using it wrong...
I fell stupid ;_;
Thank you

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Why Doesn't this work.....?
« Reply #7 on: October 19, 2010, 05:35:51 pm »
Quote
I fell stupid
Oh, don't worry, were not born robots that memorizes everything that we've experience before. :D

 

TinyPortal © 2005-2018