Options

How to append an ASCII to a string?

RachelSoonRachelSoon Member Posts: 202
Hi All,
How can i append an ASCII key to a string?

For Example :
I have a string which concantenate the ID and Name.
i would like to append a tab in between the ID and Name. How can i do that?

Comments

  • Options
    eromeineromein Member Posts: 589
    So you have a string like following:

    007James Bond

    And you want to have it like this :

    007->James Bond (-> = tab)

    Is this correct? And why want this?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    RachelSoonRachelSoon Member Posts: 202
    Yes, eromein. Your example is what i am looking for.

    The reason i want the string to be this manner is i am going to send out this string as an email text. It's easier to read if i have a tab to separate the information.

    would like my email text something like this :

    007 James Bond
    008 Jennifer Lopez
    009 Santa Clause
  • Options
    jmjm Member Posts: 156
    Hi,

    try this little code:
    ID   := '007';
    Name := 'James Bond';
    TabChar := 9;
    
    MESSAGE('%1',ID+FORMAT(TabChar)+Name);
    
    with following definitions:
    Name           DataType      Subtype       Length
    ID             Code       	              10
    Name           Text                        30
    TabChar        Char
    

    br
    Josef Metz
    br
    Josef Metz
  • Options
    RobertMoRobertMo Member Posts: 484
    define a variable of data type Char:
    Name	DataType	Subtype	Length
    ch9	Char		
    
    then just assign an ascii value for this char:
    ch9:=9; //9 is ascii for tab
    
    when combining strings use STRSUBSTNO:
    MyText := STRSUBSTNO('007%1James Bond',ch9);
    
    or concatenation of strings:
    MyText := '007' + Format(ch9) + 'James Bond';
    
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    RobertMoRobertMo Member Posts: 484
    It's getting dangerous to post answers. Some posts may just colide... :)
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    RachelSoonRachelSoon Member Posts: 202
    hi guys,
    Thank you very muchy.

    I got it now!. :D
Sign In or Register to comment.