comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Format in PRINTF
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Format in PRINTF [message #45650 is a reply to message #45649] Tue, 27 September 2005 05:56 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
coco wrote:
> Hi,
>
> I have a stringarray containing numbers and letters and want to print
> this string to a file. each line should consist of 130 arrayelements,
> each element should take two places.
>
> Using this format command: format='(130(A2))' just writes the letters,
> but not the numbers.
>

Hi,

Believe it or not - your numbers are being output - but they are being
truncated, too.


IDL> v = 18
IDL> s = STRING(v)
IDL> print, v
18
IDL> print, s
18

The 'natural' length of an integer converted to a string is 8
characters. Note that the integer-now-string is padded on the left with
spaces. Anytime you specify the output format with '(A2)' then just the
first two characters are output and the rest is truncated.

IDL> v = '1234'
IDL> print, v, FORMAT = '(A2)'
12


Where to go from here depends on what you need to do. Since you have a
string array to start with you might try STRTRIM(value, 2) which strips
leading and trailing blanks.

IDL> v = STRING(18)
IDL> s = STRTRIM(v, 2)
IDL> print, v
18
IDL> print, s
18


Make sure you have a plan for when the numbers exceed two digits in length.

Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: USERSYM filled AND outlined?
Next Topic: How to disable "auto debug mode" in idlwave?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:56:32 PDT 2025

Total time taken to generate the page: 0.00422 seconds