fixed-width printf() output on an XmList on Solaris


 
Thread Tools Search this Thread
Top Forums Programming fixed-width printf() output on an XmList on Solaris
# 1  
Old 11-20-2002
Tools fixed-width printf() output on an XmList on Solaris

This one is a bit of bugger and I'm not sure if it's entirely relevant to this board but here goes...

I'm trying to produce some fixed width output to a List widget (X11/Motif GUI) So, I use something similar to:

sprintf(Buffer, "%*d%*f", 20, some_integer, 20, some_float);

This gives me a nice fixed-width string, which I then have to convert to an XmString and then add that to the List widget.

My problem is, after adding multiple lines, the columns are not aligned. On some machines they are (for instance if I remote shell from a Windows box using ReflectX), but on the host the output does not align.

Most of my widgets use the system default font, through which in Motif (as I understand it) you specify by using XmFONTLIST_DEFAULT_TAG in most of your XmString updates. I have a feeling that the font the host uses is not fixed-width - but I wouldn't have a clue where to change the font or what font it is using. Is it quite possible for X to use non fixed-width fonts?

Perhaps this is better targeted to a Motif forum, but thought it was worth a shot....

Thx in advance Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining fixed width files

Hi All, I need to join fixed width files on a column which is position 1 to 3 and need to have all the records from file1 file1.txt Cu1nullL1L2 Cu2nullL1L2 Cu3nullL1L2 file2.txt Cu1B1B2 Cu3B1B2 output.txt Cu1L1B1L2B2 Cu2L1L2 Cu3L1B1L2B3 I tried but not getting the expected... (12 Replies)
Discussion started by: shash
12 Replies

2. Shell Programming and Scripting

Alter Fixed Width File

Thank u so much .Its working fine as expected. ---------- Post updated at 03:41 PM ---------- Previous update was at 01:46 PM ---------- I need one more help. I have another file(fixed length) that will get negative value (ex:-00000000003000) in postion (98 - 112) then i have to... (6 Replies)
Discussion started by: vinus
6 Replies

3. Shell Programming and Scripting

Using printf (or other?) to create variable fixed width text

I would like to use printf (or something else?) to create a line of text that has varying column widths. This will be used to create a fixed width file (with varying column widths). For example, consider variables $1 $2 $3 are equal to a, b, c respectively and they should be printed in column... (10 Replies)
Discussion started by: farrenthorpe
10 Replies

4. UNIX for Dummies Questions & Answers

Length of a fixed width file

I have a fixed width file of length 53. when is try to get the lengh of the record of that file i get 2 different answers. awk '{print length;exit}' <File_name> The above code gives me length 50. wc -L <File_name> The above code gives me length 53. Please clarify on... (2 Replies)
Discussion started by: Amrutha24
2 Replies

5. Shell Programming and Scripting

variable fixed-width fields

Hi there, CTL Port IO Rate(IOPS) Read Rate(IOPS) Write Rate(IOPS) Read Hit(%) Write Hit(%) Trans. Rate(MB/S) Read Trans. Rate(MB/S) Write Trans. Rate(MB/S) 09:36:48 0 A 136 0 135 97 100 ... (6 Replies)
Discussion started by: gray380
6 Replies

6. Shell Programming and Scripting

Comparing two fixed width file

Hi Guys I am checking the treads to get the answer but i am not able to get the answer for my question. I have two files. First file is a pattern file and the second file is the file i want to search in it. Output will be the lines from file2. File1: P2797f12af 44751228... (10 Replies)
Discussion started by: anshul_er
10 Replies

7. Shell Programming and Scripting

Fixed-Width file from Oracle

Hi All, I have created a script which generates FIXED-WIDTH file by executing Oracle query. SELECT RPAD(NVL(col1,CHR(9)),20)||NVL(col2,CHR(9))||NVL(col3,CHR(9) FROM XYZ It generates the data file with proper alignment. But if same file i transfer to windows server or Mainframe... (5 Replies)
Discussion started by: Amit.Sagpariya
5 Replies

8. Shell Programming and Scripting

Printing Fixed Width Columns

Hi everyone, I have been working on a pretty laborious shellscript (with bash) the last couple weeks that parses my firewall policies (from a Juniper) for me and creates a nifty little columned output. It does so using awk on a line by line basis to pull out the appropriate pieces of each... (4 Replies)
Discussion started by: cixelsyd
4 Replies

9. UNIX Desktop Questions & Answers

Help with Fixed width File Parsing

I am trying to parse a Fixed width file with data as below. I am trying to assign column values from each record to variables. When I parse the data, the spaces in all coumns are dropped. I would like to retain the spaces as part of the dat stored in the variables. Any help is appreciated. I... (4 Replies)
Discussion started by: sate911
4 Replies

10. UNIX for Dummies Questions & Answers

Fixed Width file using AWK

I am using the following command at the Unix prompt to make my 'infile' into a fixed width file of 100 characters. awk '{printf "%-100s\n",$0}' infile > outfile However, there are some records with a special character "©" These records are using 3 characters in place of one and my record... (2 Replies)
Discussion started by: alok.benjwal
2 Replies
Login or Register to Ask a Question
PRINTF(9)						   BSD Kernel Developer's Manual						 PRINTF(9)

NAME
printf, uprintf, tprintf, log -- formatted output conversion SYNOPSIS
#include <sys/types.h> #include <sys/systm.h> int printf(const char *fmt, ...); void tprintf(struct proc *p, int pri, const char *fmt, ...); int uprintf(const char *fmt, ...); #include <sys/syslog.h> void log(int pri, const char *fmt, ...); DESCRIPTION
The printf(9) family of functions are similar to the printf(3) family of functions. The different functions each use a different output stream. The uprintf() function outputs to the current process' controlling tty, while printf() writes to the console as well as to the log- ging facility. The tprintf() function outputs to the tty associated with the process p and the logging facility if pri is not -1. The log() function sends the message to the kernel logging facility, using the log level as indicated by pri. Each of these related functions use the fmt parameter in the same manner as printf(3). However, printf(9) adds two other conversion speci- fiers. The %b identifier expects two arguments: an int and a char *. These are used as a register value and a print mask for decoding bitmasks. The print mask is made up of two parts: the base and the arguments. The base value is the output base expressed as an integer value; for example, 10 gives octal and 20 gives hexadecimal. The arguments are made up of a sequence of bit identifiers. Each bit identifier begins with an integer value which is the number of the bit (starting from 1) this identifier describes. The rest of the identifier is a string of characters containing the name of the bit. The string is terminated by either the bit number at the start of the next bit identifier or NUL for the last bit identifier. The %D identifier is meant to assist in hexdumps. It requires two arguments: a u_char * pointer and a char * string. The memory pointed to be the pointer is output in hexadecimal one byte at a time. The string is used as a delimiter between individual bytes. If present, a width directive will specify the number of bytes to display. By default, 16 bytes of data are output. The log() function uses syslog(3) level values LOG_DEBUG through LOG_EMERG for its pri parameter (mistakenly called 'priority' here). Alter- natively, if a pri of -1 is given, the message will be appended to the last log message started by a previous call to log(). As these mes- sages are generated by the kernel itself, the facility will always be LOG_KERN. RETURN VALUES
The printf() and the uprintf() functions return the number of characters displayed. EXAMPLES
This example demonstrates the use of the %b and %D conversion specifiers. The function void printf_test(void) { printf("reg=%b ", 3, "102BITTWO1BITONE "); printf("out: %4D ", "AAAA", ":"); } will produce the following output: reg=3<BITTWO,BITONE> out: 41:41:41:41 The call log(LOG_DEBUG, "%s%d: been there. ", sc->sc_name, sc->sc_unit); will add the appropriate debug message at priority ``kern.debug'' to the system log. SEE ALSO
printf(3), syslog(3) BSD
September 8, 2006 BSD