1. printf fix

Rob:
       While you are fixing printf why don't you add support for

       \t the escape tab character so it is easier to format text

        without having to add a zillon spaces.

   Bernie

new topic     » topic index » view message » categorize

2. Re: printf fix

Bernie Ryan writes:
>  While you are fixing printf why don't you add support for
>   \t the escape tab character so it is easier to format text
>   without having to add a zillon spaces.

I don't know what you mean.
\t is already supported as a special character.
You can use it in arguments to printf(), or anywhere else.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: printf fix

Correction make that SPRINTF;

  If I do this: ? sprintf("\t\t abcd",0)

  I get { 9,9,32,97,98,99,100 }

  shouldn't the tabs be expanded into spaces ?

new topic     » goto parent     » topic index » view message » categorize

4. Re: printf fix

Bernie Ryan wrote:

>Correction make that SPRINTF;
>
>   If I do this: ? sprintf("\t\t abcd",0)
>
>   I get { 9,9,32,97,98,99,100 }
>
>   shouldn't the tabs be expanded into spaces ?

The ? operator will always return the sequence representation of any string.
Try coding ? "\t\t abcd" -- you get the same result. The 9's are the tab
characters. It's not a sprintf() problem, it's the way Euphoria works. Use
puts(1, sprintf("\t\t abcd", 0)) or printf(1, "\t\t abcd", 0) if you want to
see the tabs expanded.

-- Gabriel

______________________________________________________
PLEASE IGNORE ANY ADS YOU MAY SEE BELOW THIS LINE. smile
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

5. Re: printf fix

The purpose of the sprintf is to format a string.

  \t is a formatting character.

  All it takes in the interpeter is to expand \t into to 8 spaces.

  If I want to create a Title/Caption for a window I would like to
  simply use \t in stead of space,space,space...etc.

new topic     » goto parent     » topic index » view message » categorize

6. Re: printf fix

On Wed, 26 Apr 2000 10:57:51 -0400, Bernie Ryan wrote:

>Correction make that SPRINTF;
>
>  If I do this: ? sprintf("\t\t abcd",0)
>
>  I get { 9,9,32,97,98,99,100 }
>
>  shouldn't the tabs be expanded into spaces ?

No, tabs are simply a special character (ASCII code = 9) that are subject
to the interpretation of the editor/text viewer being used.

-- Brian

new topic     » goto parent     » topic index » view message » categorize

7. Re: printf fix

On Wed, 26 Apr 2000 12:30:51 -0400, Brian Broker <bkb at CNW.COM> wrote:

>No, tabs are simply a special character (ASCII code = 9) that are subject
>to the interpretation of the editor/text viewer being used.

 No \t is a escape sequence in a text string which means to goto
 the next tab stop. When the escape character \ is seen it means
 that the next character following is special character and because
 that character is a t then it is interrupted as a tab to next stop.


 Would't you like to use tabs in text in a listbox control.

new topic     » goto parent     » topic index » view message » categorize

8. Re: printf fix

On Wed, 26 Apr 2000 12:49:48 -0400, Bernie Ryan wrote:

> No \t is a escape sequence in a text string which means to goto
> the next tab stop. When the escape character \ is seen it means
> that the next character following is special character and because
> that character is a t then it is interrupted as a tab to next stop.
>
>
> Would't you like to use tabs in text in a listbox control.

There are many messages that you can send to a listbox.  Try looking into
LB_SETTABSTOPS at:

Note:  To respond to the LB_SETTABSTOPS message, the list box must have
been created with the LBS_USETABSTOPS style.

Hope this helps,
-- Brian

new topic     » goto parent     » topic index » view message » categorize

9. Re: printf fix

Bernie Ryan writes:
> The purpose of the sprintf is to format a string.
>  \t is a formatting character.
> All it takes in the interpeter is to expand \t into to 8 spaces.

sprintf() should not expand tabs because:

    1. How does it know how many spaces equals one tab?
        8 is common, but by no means universal.

    2. How does it know how many spaces to the next tab stop?
        It has no concept of the current column position.

The tabs will be expanded when and if you choose to print
the result of sprintf() on some device that understands tabs.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

10. Re: printf fix

On Wed, 26 Apr 2000 13:33:21 -0400, Brian Broker <bkb at CNW.COM> wrote:



>
>Note:  To respond to the LB_SETTABSTOPS message, the list box must have
>been created with the LBS_USETABSTOPS style.

  Brian:

  That message sets tab stops in a listbox, but requires the user to
  calculate and adjust the tabs under different conditions. What I am
  saying is if sprintf formated a string as it should, then a user could
  use text in the listbox without dealing with adjusting tab stops,
  because the tabs would have been converted into spaces. In addition
  sprintf could then be used to format titles and other text strings
  in windows and dos.

  Bernie

new topic     » goto parent     » topic index » view message » categorize

11. Re: printf fix

> -----Original Message-----
> From:  Bernie Ryan
>
>   Brian:
>
>   <snip> if sprintf formated a string as it should

But as a few people have already pointed out, sprintf *does* format a string
'as it should'.  A tab is a defined character (ASCII 9, as someone pointed
out), which doesn't equal a certain number of spaces.  To get the behavior
you're looking for, you could try:

constant tab = repeat( ' ',8)
sequence string
string = sprintf("%sTab Spaces:%s%d",{tab,tab,length(tab)})



>, then a user could
>   use text in the listbox without dealing with adjusting tab stops,
>   because the tabs would have been converted into spaces.

Except that as Robert pointed out, sprintf would have no way to deal with
line position or font size, two things that would absolutely be needed in
order to simulate tab stops.

I think you're trying to use the wrong tool for this job.


Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

12. Re: printf fix

printf() and sprintf() should and do translate '\t' into 9.
The tab translation works just as it should.  That is all I have
to say.

        Lucius L. Hilley III
        lhilley at cdc.net
+----------+--------------+--------------+
| Hollow   | ICQ: 9638898 | AIM: LLHIII  |
|  Horse   +--------------+--------------+
| Software | http://www.cdc.net/~lhilley |
+----------+-----------------------------+

> ---------------------- Information from the mail
header -----------------------
> Sender:       Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
> Poster:       Bernie Ryan <xotron at BUFFNET.NET>
> Subject:      Re: printf fix
> --------------------------------------------------------------------------
-----
>
> On Wed, 26 Apr 2000 13:33:21 -0400, Brian Broker <bkb at CNW.COM> wrote:
>
>
>
> >
> >Note:  To respond to the LB_SETTABSTOPS message, the list box must have
> >been created with the LBS_USETABSTOPS style.
>
>   Brian:
>
>   That message sets tab stops in a listbox, but requires the user to
>   calculate and adjust the tabs under different conditions. What I am
>   saying is if sprintf formated a string as it should, then a user could
>   use text in the listbox without dealing with adjusting tab stops,
>   because the tabs would have been converted into spaces. In addition
>   sprintf could then be used to format titles and other text strings
>   in windows and dos.
>
>   Bernie
>

new topic     » goto parent     » topic index » view message » categorize

13. Re: printf fix

> No, tabs are simply a special character (ASCII code = 9) that are subject
> to the interpretation of the editor/text viewer being used.
>
> -- Brian
>

That's Right

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu