Setting column width in a command-line program
Is there a way to send data to the screen in a command-line Java program that will be formatted as a number
of columns with a set column width? I am looking for something similar to the C++ setw() I/O manipulator
used in cout.
Thanks,
Steve
If you go to: http://java.sun.com/docs/books/tutorial/essential/io/writingFiltered.html
it will show you how to subclass a filtered output stream and add your own formatting methods.Then you can chain your new class to System.out
like this:
YourFilteredStream yfs = new YourFilteredStream(System.out); .
Then:
yfs.yourNewMethod(); goes directly to system out in the new format.
Similar Messages
-
How to set column width in alvgrid
hi
how to set column width in alvgrid.
thanks.Hi,
Check this,
REPORT ztest.
DATA: BEGIN OF i_scarr_tab OCCURS 0.
INCLUDE STRUCTURE scarr.
DATA: END OF i_scarr_tab.
DATA: i_scarr LIKE TABLE OF i_scarr_tab WITH HEADER LINE,
w_scarr LIKE LINE OF i_scarr_tab.
DATA: o_grid TYPE REF TO cl_gui_alv_grid,
o_container TYPE REF TO cl_gui_custom_container.
DATA: lt_fcat TYPE lvc_t_fcat,
ls_layo TYPE lvc_s_layo,
ls_sort TYPE lvc_s_sort,
lt_sort TYPE lvc_t_sort,
ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
START-OF-SELECTION.
CALL SCREEN 9000.
*& Module status_9000 OUTPUT
text
MODULE status_9000 OUTPUT.
SET PF-STATUS '9000'.
SET TITLEBAR '9000'.
ENDMODULE. " status_9000 OUTPUT
*& Module user_command_9000 INPUT
text
MODULE user_command_9000 INPUT.
CASE sy-ucomm .
WHEN 'BACK' OR 'EXIT'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " user_command_9000 INPUT
*& Module init_9000 OUTPUT
text
MODULE init_9000 OUTPUT.
IF o_container IS INITIAL.
SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE
i_scarr UP TO 100 ROWS.
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
Create a custom container control for ALV Control
CREATE OBJECT o_container
EXPORTING
container_name = 'CONTROL'.
Create a ALV Control
CREATE OBJECT o_grid
EXPORTING i_parent = o_container.
PERFORM build_field_catalgue.
ls_layo-sel_mode = 'A'.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
i_default = 'X'
is_layout = ls_layo
CHANGING
it_outtab = i_scarr[]
it_fieldcatalog = lt_fcat
it_sort = lt_sort[].
ENDIF.
ENDIF.
ENDMODULE. " init_9000 OUTPUT
*& Form build_field_catalgue
text
--> p1 text
<-- p2 text
FORM build_field_catalgue .
DATA: ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-cprog
i_internal_tabname = 'I_SCARR_TAB'
i_structure_name = 'SCARR'
i_client_never_display = 'X'
CHANGING
ct_fieldcat = ls_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE 'FCAT Error' TYPE 'I'.
EXIT.
ENDIF.
LOOP AT ls_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = ls_fieldcat-fieldname. "Fieldname
ls_fcat-ref_table = ls_fieldcat-tabname. "DDIC ref struct
ls_fcat-inttype = ls_fieldcat-inttype. "Data type
ls_fcat-outputlen = ls_fieldcat-outputlen. "Column width
ls_fcat-coltext = ls_fieldcat-seltext_m. "Column Header
ls_fcat-seltext = ls_fieldcat-seltext_m. "Column Desc
ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field
ls_fcat-ref_table = ls_fieldcat-ref_tabname. "Reference table
CASE ls_fieldcat-fieldname.
WHEN 'LUGGWEIGHT' OR 'FORCURAM'.
ls_fcat-edit = 'X'.
ls_fcat-do_sum = 'X'.
WHEN 'URL'.
ls_fcat-no_out = 'X'.
WHEN OTHERS.
ls_fcat-edit = ' '.
ls_fcat-do_sum = ' '.
ENDCASE.
APPEND ls_fcat TO lt_fcat.
ENDLOOP.
ENDFORM. " build_field_catalgue
check the programs bcalv_grid*.
check this link for more detailed example.
http://www.supinfo-projects.com/fr/2005/alv_display_fr/2/
Regards
Sruthi -
Creating a command line program reading AEP/AEPX files?
I'm new with After Effects SDK, and I wanted to know if it's possible to use SDK to implement a command line program that gets information such as duration and frame rate in AEP/AEPX files.
aerender, a command line render program provided by After Effects, prints out these information before rendering. But it doesn't seem to be able to print out the information without doing rendering.
I saw a related thread here: http://forums.adobe.com/thread/844341
But what I want is simpler. I don't need to alter the AEP/AEPX files. I just want to obtain the information quickly from an AEP/AEPX file. Is it possible to write such a tool using SDK?
Thanks!hi eliang.cs!
yes, i'm the same guy who answered on the other thread.
everything the API does, it does through AE as a plug-in.
so if you have AE running (even just the renderer), your project loaded and your plug-in present, you can access all the data you described with no problem, and export it out in whatever way you want. (a plug-in is actually a DLL, so you can do anything you want, even on an OS level)
you can access the data on all elements of the project including comps, layers, footage, render queue, ect...
having said that, you can do all of this using a script instead of a plug-in.
scripts are much easier to build.
perhaps there's even a script out there that does what you're looking for, or something very close that could easily be adjusted. -
Set Column width in query (not using SQL*Plus)
How can I Set Column width in query
I understand you can set column width using
column col1 FORMAT A5
select col1 from table1;But this only works in SQL*Plus
I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
I am using a 'SQL window' in PL/SQL Developer IDE
and when I use this syntax it says:
ORA-00900: Invalid SQL statement
Any suggestions are appreciated...
thanks,
M.Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
e.g.
SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM -
I've been utilizing the below script (thank you so much Ramkumar. P!) to set column widths throughout a sizable InDesign book with tables on every page and it is truly a time saver. At this point in time, I have three versions of it because there are different column widths throughout the book. Is it possible to augment the script to run only on a selected text frame (containing a table)? If so, would someone be kind enough to share the augmented script with me? I've been trying to figure out this seemingly simple change through trial and error with no success as yet. I realize this is a totally newbie request and I'm entirely at the mercy of the kindness of the Javascript gods that contribute within this forum. Seeing that in a different post related to this script, one such guru responded to a request as simple as "Where do I put the scripts in InDesign" gave me enough courage to ask for some help! Thank you in advance to anyone willing to provide a solution.
var myDoc = app.activeDocument;
var myWidths = [100, 100, 150, 150];
for(var T=0; T < myDoc.textFrames.length; T++){
for(var i=0; i < myDoc.textFrames[T].tables.length; i++){
for(var j=0; j < myWidths.length; j++){
myDoc.textFrames[T].tables[i].columns[j].width = myWidths[j];
alert("Table width updated successfully...");Hello all
I have the same problem in that I'm not a scripting person, but was able to get the above script working without problem, and it does set irregular table column widths perfectly, so thanks to Ramkumar. P for that.
BUT, it changes the column width for ALL tables in the document, whereas I would like to just target the selected table.
Any ideas as to how I might amend this script to achieve this?
Thx, Christian -
Is there a command line program that converts WAV to SWF?
Is there a command line program that converts WAV to SWF?
thankswhy you want to do that? you can import your wav into the
swf! -
Cope: a command-line program colouriser
cope is a wrapper around various command-line programs that takes their output and adds colours - a sort of ornamental cope, if you will.
It's written in Perl, and requires version >= 5.10, so installation may be a bit complicated if you have to track down the dependencies. It installs several scripts in a directory, each one calling the program it's named after, only highlighting its output using regexes. Then you add this directory to your $PATH, and everything should (hopefully!) be seamless.
Currently it's in release candidate status - I've been using it personally for a few weeks and nothing catastrophic has happened so far, so there's little point me keeping it private.
Screenshots:
Main site: http://stuff.cytzol.org/cope/
GitHub: http://github.com/cytzol/copePKGBUILD
# Contributor: denton <e9203.00 gmail com>
pkgname=cope-git
pkgver=20091208
pkgrel=1
pkgdesc='A colourful wrapper for terminal programs'
arch=(any)
url=http://stuff.cytzol.org/cope/
license=('GPL' 'PerlArtistic')
depends=("perl>=5.10")
makedepends=(git)
provides=(cope)
conflicts=(cope)
install=$pkgname.install
_gitroot=git://github.com/cytzol/cope.git
_gitname=cope
build() {
cd $srcdir
# Git
msg 'Connecting to Git server...'
if [ -d $_gitname ] ; then
cd $_gitname && git pull origin || return 1
msg 'The local files are updated.'
else
git clone $_gitroot || return 1
fi
msg 'Git checkout done or server timeout.'
msg 'Starting make...'
rm -rf $srcdir/$_gitname-build
git clone $srcdir/$_gitname $srcdir/$_gitname-build || return 1
cd $srcdir/$_gitname-build
# Build
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
make || return 1
make install DESTDIR=$pkgdir || return 1
# Remove perllocal.pod and .packlist
find $pkgdir -name perllocal.pod -delete
find $pkgdir -name .packlist -delete
cope-git.install
post_install() {
echo 'Prepend /usr/share/perl5/vendor_perl/auto/share/dist/Cope/ to $PATH'
post_upgrade() {
post_install
First time making a perl package. It puts files that shouldn't be in */site:
/usr/bin/perlbin/site/envpath
/usr/lib/perl5/site_perl/5.10.1/IO/Pty.pm
/usr/lib/perl5/site_perl/5.10.1/IO/Tty.pm
/usr/lib/perl5/site_perl/5.10.1/IO/Tty/
/usr/lib/perl5/site_perl/5.10.1/IO/Tty/Constant.pm
/usr/lib/perl5/site_perl/5.10.1/List/MoreUtils.pm
/usr/lib/perl5/site_perl/5.10.1/Params/Util.pm
/usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.bs
/usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.so
/usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.bs
/usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.so
/usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.bs
/usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.so
/usr/share/perl5/site_perl/5.10.1/Class/Inspector.pm
/usr/share/perl5/site_perl/5.10.1/Class/Inspector/
/usr/share/perl5/site_perl/5.10.1/Class/Inspector/Functions.pm
/usr/share/perl5/site_perl/5.10.1/Env/Path.pm
/usr/share/perl5/site_perl/5.10.1/IO/Stty.pm
/usr/share/perl5/site_perl/5.10.1/IO/stty.pl
/usr/share/perl5/site_perl/5.10.1/Regexp/Common.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/CC.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/SEN.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1035.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1738.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1808.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2384.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2396.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2806.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/fax.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/file.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/ftp.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/gopher.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/http.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/news.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/pop.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/prospero.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tel.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/telnet.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tv.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/wais.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/_support.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/balanced.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/comment.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/delimited.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/lingua.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/list.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/net.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/number.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/profanity.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/whitespace.pm
/usr/share/perl5/site_perl/5.10.1/Regexp/Common/zip.pm
And as shown by the previous list, I haven't fetched these binaries (are they in the repos?):
Env::Path
File::ShareDir
IO::Handle
IO::Pty
IO::Stty
List::MoreUtils
Regexp::Common
Term::ANSIColor
Everything works, except cope_path.pl.
Last edited by denton (2009-12-08 09:14:37) -
Fast command-line program which displays connectivity
Hi
I'm looking for a command-line program which can show whether or not my network interface has an IP address or not. It could use "ifconfig" to extract the information, I don't really care, but it has to be *fast* and it cannot require root access.
ThanksThanks, but if someone knows some sed/awk magic to get only the interface's IP address, that would be great!
EDIT:
Using the little "sed" I know, this is what I came up with:
ifconfig wlan0 | grep -w inet | sed "s/^\\s*//" | sed "s/^inet addr://" | sed "s/\\s.*//"
EDIT2:
Now I have this reasonable command:
ifconfig wlan0 | grep -w inet | sed "s/.*inet addr:\([^ ]*\).*.*/\1/"
Last edited by skorpan (2009-06-07 16:44:19) -
How can I set column width in JTable?
How can I set column width in JTable?
Also, read the JTable API before posting questions. You will find a link to the Swing tutorial on "How to Use Tables", which contains an example of doing exactly this.
-
Tagging command line programs in subtle?
I'd like to be able to tag command line programs so I can assign them to specific views and gravities within those views.
For example, I'd like to be able to have 'gclacli calm' be recognized by a tag so it appears in my 'agenda' view and assign it a gravity. Is there a way to do this? Right now the best I can do is limit xterm to different views but they still move around when I change views.
Last edited by tinySpark (2012-06-14 18:04:12)None of these options have worked.
for the user variables, i just create a new one called "Path" and type in my path to java \bin right?
This is quite frustrating. Thanks for the help though!
--Brenton -
Uninstalling Command Line Programs
I've searched these forums and the internet for an answer to this, but there doesn't seem to be anything out there, so I hope this will be helpful to others as well.
I have some open source command line programs that I downloaded, compiled, and installed as part of some exercises I was doing in a book on open source GIS (geographic information systems). What I want to know is how do I remove those programs? I can find references for compiling and installing these types of programs all over the internet, but nothing about removing or uninstalling them.
Also, any ideas for good, up-to-date references on learning Unix in Mac OS X would be appreciated too. I'd like to get more into open source GIS, but from the research I've been doing, knowing Unix would help a lot.What process did you use to compile and install? Was it a configure, make, make install sequence, which is fairly common? If so, go back to the directory where you did that, and try, for example, 'make uninstall'. This might work.
Look for output files from the compile and install process (perhaps config.log) that might tell you where files will be installed. Perhaps in /usr/local?
Is there a README or INSTALL file that came with the source code? Documentation about what was installed where might be there.
If worst comes to worst, and you're really determined, you could repeat the compile and install steps, but with a before and after listing of all the files in your system, and compare the listings. Or use the find command immediately after the reinstall, looking for recently created or changed files (the 'mtime' option or similar). -
How do I set Column Width in table displayed - have tried everything :-(
Hi,
I'm using Jdev 10.1.2, adf bc and jsp's.
Simple problem, driving me nuts. In my app i display a number of different view objects in a number of jsp's. i want to set the width of the columns so that the info (if large) in each field will stay on one line. i.e. it wont continue onto the next line and take up two rows.
i have tried setting the width property of the <th> & <td>, setting the disply width property in the entity object editor and the view object editor, nothing makes a bit of difference to how the column is displayed.
this results in the tables looking messy and squised, which is totally unsatisfactory.
so if anyone could shed any light on the subject, i would be most grateful.
Thanks in advance......hi Newbe,
if you set the option noWrap="true" on the column the text will not be wrapped;
<af:column noWrap="true" sortable="false" headerText="col5">
<af:outputText value="#{row.col5}"/>
</af:column>
Good luck
Luc Bors -
How do I set column widths in read/write rules?
Hello structure experts,
I am reading a set of DITA files into a specific FM template format, and there is one detail I cannot get to work properly. It should be possible to define column widths in a table, even if the DITA file does not include that information. But the Structure Application Developer Reference does not give the information on which string to pass to the column widths fm property. Does anyone out there have experience in doing this ?
Thanks
JangGot it !!!
Turned out to be simple, but the info was more or less hidden in the Dev Ref Guide: I had already put the "fm property column widths is value " line in but did not know the syntax for the values. Turns out you need to delimit the values by spaces, not commas. The parser does not give ANY useful information about this, just mentions 'syntax error near somewhere' or completely ignores the values you specify.
This is how the rule for my DITA properties element now works out:
element "properties" {
is fm table element;
fm property columns value is "3";
fm property column widths value is "5cm 5cm 6cm";
It works. I earn 10 points for answering my own question. :-)
Ciao
Jang -
Command line program: can it implement keyListener??
Hello,
before I take the trouble to learn keyListener implementation, I am wondering if my program could even implement it. It is just a small game that just plays in the command window. I would like it to respond to the user pressing up, down, left and right keys. Is this possible with a keyListener or is this only possible in a 'windowed' application?
And if you cannot register keys this way from the command line, then how would I make my program interactive. Do you know a link to an API description that explains how to set the program up to give a prompt?
Thank you very much!
-Mike.guess not...
-
Setting column widths using CSS...
Hi guys,
I am using a simple 2 column table to layout pictures and
text. The problem I'm having is that I'm not sure how to set the
column widths and as such when you flick from page to page the
column widths and don't stay exactly equal to each other as I'd
like them too.
This can clearly be seen through clicking and comparing the
following two pages.
http://www.fyrne.com/mb_food_and_drink.html
http://www.fyrne.com/mb_television.html
Any advice on how I can resolve this would be much
appreciated.
Cheers, JHi James,
I see the scrollbars now but now I also see what you mean :(
I think the easy fix is to create a class and apply it to
every single
td that has the text/image/heading to give them a fixed
width! (Maybe
only applying it to the top td's would do the trick... I'm
really no
good with tables)
Hope it made some sense
JamesFryer skrev:
> Hi Kim,
>
> Thanks for posting this link. I think it was Nadia who
previously suggested I
> implement the suggest edcode line to auto add the
vertical scroll bar and avoid
> an overall site shift problem I was having.
>
> However I have now implemented this and am still getting
the shift problem -
> you will notice it is not the overall site (ie the
bordered area) which is
> shifting but the internal table columns. I believe I
have set these column
> widths in DW design view but this often proves
problematic (pushing out the
> width of the main table for no reason although this does
not actually show when
> previewed).
>
> As such I hoped I would be able to control this through
CSS - I don't believe
> it's the same as the shifting problem...
>
> Thanks again, J
>
Kim
http://www.geekministry.com
Maybe you are looking for
-
HOW TO - Create new from clipboard and process multiple files - please help
Need help - have new version of photoshop on trial only ATM... Want to know - HOW TO: 1. Create new from clipbaord 2. Process multiple files Please help.
-
SAP* user not working in new client
Hi, I created a new client from SCC4. And now I am trying to login with SAP* user and pass password but it is not allowing. Note provided in SAP Config Guide is not working. I installed SAP Solution Manager 7.0 SP12 and then created a client. Please
-
Hi, Does SAP have a standard AR report that will sort by Salesperson, customer account #, due date and or a combination of all three? If not, is it possible? if it is possible, How can i customize the report to get the above requirement.Kindly help m
-
Do I need multiple Vendor ID and device ID ?
Hi I am developing a Compact PCI/ PXI card. Will I need a different DEVICE ID for each card, so that Labview can recognise between two cards. Is the distinction between two cards having the same vendor ID done on the basis of Device ID's or is it don
-
Round in steps of 6. For example: 6 - 12 - 18 - 24 ....
Hello, I have the following problem: I'm programming a tool, where people can order meals + drinks. It should only be possible to order one kind of drink in steps of 5. For Example: Coca Cola only in 5 - 10 - 15 - ... and so on This works well with: