Recent

Author Topic: how to use trim ?  (Read 277 times)

nouzi

  • New member
  • *
  • Posts: 43
how to use trim ?
« on: December 05, 2018, 03:57:05 pm »
hi all
my code
Code: Pascal  [Select]
  1. ...
  2. var
  3.   d : string ;
  4. begin
  5.   d :=  ' 123 456 ';
  6.   TrimLeft(d);
  7.   ShowMessage(d);
  8. end;
  9.                  
  10. ...
  11.  

this code not work
« Last Edit: December 05, 2018, 04:37:41 pm by nouzi »
my english is  bad
Lazarus trunk 2.0 free pascal 3.1.1
System : windows 7 64bit

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6608
Re: trim not working ?
« Reply #1 on: December 05, 2018, 04:00:37 pm »
d:=trimleft(d);

nouzi

  • New member
  • *
  • Posts: 43
Re: trim not working ?
« Reply #2 on: December 05, 2018, 04:10:09 pm »
@marcov Thanks
howto remove all space in this word '   ha    ha h a '
thank again
my english is  bad
Lazarus trunk 2.0 free pascal 3.1.1
System : windows 7 64bit

Handoko

  • Hero Member
  • *****
  • Posts: 2675
  • My goal: build my own game engine using Lazarus
Re: trim not working ?
« Reply #3 on: December 05, 2018, 04:29:34 pm »
Trim is working correctly. You should read the documentation before saying it is not working.

Quote
Trim strips blank characters (spaces and control characters) at the beginning and end of S and returns the resulting string.

https://www.freepascal.org/docs-html/rtl/sysutils/trim.html

nouzi

  • New member
  • *
  • Posts: 43
Re: how to use trim ?
« Reply #4 on: December 05, 2018, 04:45:53 pm »
Trim is working correctly. You should read the documentation before saying it is not working.

Quote
Trim strips blank characters (spaces and control characters) at the beginning and end of S and returns the resulting string.

https://www.freepascal.org/docs-html/rtl/sysutils/trim.html
@Handoko thank, i change title post i'm sorry .
the middle of the word example
"hahaha hahaha'
my english is  bad
Lazarus trunk 2.0 free pascal 3.1.1
System : windows 7 64bit

Handoko

  • Hero Member
  • *****
  • Posts: 2675
  • My goal: build my own game engine using Lazarus
Re: how to use trim ?
« Reply #5 on: December 05, 2018, 04:47:09 pm »

HeavyUser

  • Full Member
  • ***
  • Posts: 194
Re: trim not working ?
« Reply #6 on: December 05, 2018, 04:48:48 pm »
@marcov Thanks
howto remove all space in this word '   ha    ha h a '
thank again
Code: Pascal  [Select]
  1.   showmessage(StringReplace('Ha h   a h a h ah a',' ','',[rfReplaceall, rfIgnoreCase]));
  2.  

nouzi

  • New member
  • *
  • Posts: 43
Re: how to use trim ?
« Reply #7 on: December 05, 2018, 04:54:05 pm »
Try DelSpace:
https://www.freepascal.org/docs-html/rtl/strutils/delspace.html
thank @Handoko this is owrk

Code: Pascal  [Select]
  1.   showmessage(StringReplace('Ha h   a h a h ah a',' ','',[rfReplaceall, rfIgnoreCase]));
  2.  


yes is true code thank @HeavyUser
my english is  bad
Lazarus trunk 2.0 free pascal 3.1.1
System : windows 7 64bit

Bart

  • Hero Member
  • *****
  • Posts: 3161
    • Bart en Mariska's Webstek
Re: how to use trim ?
« Reply #8 on: December 05, 2018, 05:34:11 pm »
Why would you use Lazarus trunk in combination with fpc trunk (you sig says you do)?
Especially given the questions you ask here, which indicates you are a novice.

Bart

nouzi

  • New member
  • *
  • Posts: 43
Re: how to use trim ?
« Reply #9 on: December 05, 2018, 06:59:03 pm »
Why would you use Lazarus trunk in combination with fpc trunk (you sig says you do)?
Especially given the questions you ask here, which indicates you are a novice.

Bart
   :-[
I'm  old developer with delphi and dbase and clipper 
I was confused when writing the code
Thank for all
« Last Edit: December 06, 2018, 08:53:16 am by nouzi »
my english is  bad
Lazarus trunk 2.0 free pascal 3.1.1
System : windows 7 64bit