2D string array text wrapping
Hello,
I would like to know how can we wrap text of just one column in 2D array of strings.
If I try to wrap just one coloumn entire array gets affected. Please see the image to get a better idea.
See how the numbers look, compared to the texts. How can I wrap the text for just the text?
Hi sandy,
can you illustrate, how you want your array to look like after you apply this "wrapping"?
Generic answer: in an array all elements share the same properties, they only differ in value…
Similar Messages
-
Text file convert to string array
I tried to convert text file to string array. But it is not successful.
text file :
SD, 1,2,3,4
GD, 3,4,5,6
I use spreadsheet string to Array function but ALL characters is become to zero.
my result:
0,1,2,3,4
0,3,4,5,6
Solved!
Go to Solution.
Attachments:
convert.vi 18 KBHi,
indeed the solution of GerdW is the way to do it, except for the fact that the while loop isn't needed in this case
Have fun using LabVIEW
Kind regards,
- Bjorn -
Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's
LabVIEW 5.1 - LabVIEW 2012
Attachments:
Speadsheet_to_array.JPG 27 KB -
Hello everybody,
if I have a string array of say 10 elements, how would I go about shifting those elements to the right or left by one place, ensuring that what had shifted off either end of the array would "wrap around" to the other end of the array?
Thank you for your help in this.
regards,
THE_TH1NGYou could use Arrays.asList() to wrap your array in a list.
To rotate to the right, remove the last element of the list, and add it to the front of the list.
To rotate to the left remove the first element, and add it to the end.
The changes made via the list are written through to the original array you had.
Alternatively write a couple of methods that will do it by hand.
1) store a reference to the array element that will wrap.
2) loop through the elements in the array, copying them into the next element up/down as appropriate.
3) put the stored element back at the start/end of the array as appropriate. -
Text Wraps on Interactive Report
I created an APEX 4.1.1.00.23 application with some interactive reports. On the interactive reports I had a problem with text wrapping around so a string like this:
505 EAST 144TH STEEET
Would display as:
505 EAST
144TH
STREET
I corrected the problem with the following java script in the Execute When Page Loads page attribute:
$('td[headers="ADDRESS"]').attr("style","white-space:nowrap");
The user requested that the report break on two columns. I opened Actions>Format>Control Break, selected the columns, and saved the report. Now the java to format the address column does not seem to take effect. Before I applied the breaks the text would sometimes wrap and I could correct it by pressing the F5 key but this does not work anymore. How do I get the java script to take effect or otherwise correct the text wrapping problem?Comet wrote:
I created an APEX 4.1.1.00.23 application with some interactive reports. On the interactive reports I had a problem with text wrapping around so a string like this:
505 EAST 144TH STEEET
Would display as:
505 EAST
144TH
STREET
I corrected the problem with the following java script in the Execute When Page Loads page attribute:
$('td[headers="ADDRESS"]').attr("style","white-space:nowrap");
The user requested that the report break on two columns. I opened Actions>Format>Control Break, selected the columns, and saved the report. Now the java to format the address column does not seem to take effect. Before I applied the breaks the text would sometimes wrap and I could correct it by pressing the F5 key but this does not work anymore. How do I get the java script to take effect or otherwise correct the text wrapping problem?See +{message:id=9208685}+
With the control break the IR generates different mark-up, so you need to add another selector to the rules so there's a match on the column cells in both the standard and break report views. -
How do I read a formatted excel worksheet as a string array
I am using the report toolkit to read a excel worksheet as a LV string array. This works fine except that it reads the full precision of numeric cells (~10 digits of precision).
In my workbook I have the displayed precision set to 2. Is there any way to read the table as it is displayed instead of how it is internally stored? (BTW, I understand how to do this
manually by parsing the string array and limiting the precision myself but would prefer to use excel itself to determine the precision)
Solved!
Go to Solution.sachsm,
This should allow you to get the actual displayed text from an cell or range of cells. Kind of doing a 'Paste Special' 'Values'.
Attachments:
Read Excel Displayed Text.png 30 KB -
Sorry, if my question is too wordy.
First, the problem -- I am reading integers into my application and converting the those into strings using valueOf(). I then need to use those strings in a switch statment. The only way I could figure how to do this was to use the same String variable in each switch statement but change the the message to fit each case. My professor suggested I use an array list instead.
Second, the question -- how can I convert the String I have generated into a String Array and use the indexing of the array to correspond to the specific text for each case?
Thank you.indeed, you can't use the switch mechanism on strings.
but, if the requirement is that you convert an integer into a string and then switch on those (I don't know why...) from an array of the values, swap the String value back into an int and switch from there. -
Passing values to form bean string array from dynamic added textboxes
Hi,
I am unable to pass values to form bean string array from a jsp in which I have incorporated dynamically adding of textboxes in javascript.
I have given add/delete row option in the jsp. If there is single row, this is working fine. But after adding a row, I am not able to either do any validations on added textboxes or pass the values to the String array form bean variable.
code snippet:
var cell6 = row.insertCell(4);
var element5 = document.createElement("input");
element5.type = "text";
element5.className = "formtext1";
element5.size = "5";
element5.value = "00.00";
element5.name= "qty"; // this is a string array of the form bean.
element5.onchange=function() {checkNumeric(this);};
cell6.appendChild(element5);
<html:text styleClass="formtext1" property="qty" value="" size="5" styleId="qty" onchange="checkNumeric(this)"/></td>
form bean declaration
private String[] qty; Please help.
Edited by: j2eefresher on Jan 12, 2010 11:23 PMShivanand,
There's no need to post that much code when you could create a very short test case that demonstrates only the problem you are having.
You're using &NAME. notation on something that isn't a page or application item. You can't reference PL/SQL variables that way (or any other way) outside the PL/SQL scope. For your situation, you could create a page item named P55_DOCID and assign it a value in the PL/SQL process (:P55_DOCID := DOCID;), then reference &P55_DOCID. in HTML areas like the success message.
Scott -
I'm trying to display text on a JOptionPane.showMessageDialog, but sometimes the the string can be so long the dialog box goes off the computer monitor. Is there a way to do text wrapping on a JOptionPane box?
Just in case anyone is still struggling with this, I wrote a method that works well to correct the problem. Sorry to dig up an old thread, but I just now joined the forum and saw this was still in stasis.
Hope it helps someone.
public String wrapText(String passedStr)
* This method solves the problem of JOptionPanes not automatically *
* wrapping long lines of text. Set the LINE_LENGTH constant to *
* the length you want each line to be. A newline character will be *
* inserted at the first whitespace after each character located at *
* the LINE_LENGTH postition. *
* Known problem: *
* - Traditional double-whitespace that appears between sentences *
* can sometimes result in lines starting with whitespace, causing *
* the left edge of the text to look jagged. This can be "fixed" *
* by only hitting the spacebar once between sentences. *
// Constant to indicate the length of each line.
final short LINE_LENGTH = 80;
// Variable to indicate the next carriage-return position.
int nextCR = LINE_LENGTH;
// Create a StringBuffer copy of the string to wrap (passedStr).
StringBuffer newStr = new StringBuffer(passedStr);
// Read entire string from beginning to end.
for (int i = 0; i < newStr.length(); i++)
// Push back nextCR another LINE_LENGTH for all newlines found.
if (newStr.charAt(i) == '\n' || newStr.charAt(i) == '\r')
nextCR = i + LINE_LENGTH;
// Insert carriage-return at whitespace on or after nextCR.
if (newStr.charAt(i) == ' ' && i >= nextCR)
newStr.insert((i + 1), "\n");
nextCR += LINE_LENGTH;
return newStr.toString();
}Usage:
JOptionPane.showMessageDialog(null, wrapText(stringThatNeedsWrapped), header, JOptionPane.PLAIN_MESSAGE); -
String to 2D string array conversion
Hi,
I have a string like this below. I would like to extract all the texts within the quotes " ". How to do that?.
05-Mar.20:52 skalyana label type "BASELINE_1.2" (locked)
28-Apr.19:19 skalyana label type "BASELINE_1.8"
i have tried using Match regular expression. I am able to extract one text within " ".
I would like to know how to extract all the text within " "
I have attached the vi for your reference
Thanks
Kalyan
Attachments:
string to 2D string array conversion.vi 19 KBHi Jim,
its simply superb...
how to get more info on these 'Regular Expressions', is there any KB (knowledge base) or tutorial available for the same.
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT. -
I need to make a dynamic string array.
Deeper explanation:
I am trying to use a FOR loop to send a series of commands to an 8-channel device. Each channel requires 7 (actually, 1/2 need only 5, the other 1/2 need 7) strings to set them up and the entire sequence needs to be performed 8 times. I started a test .vi by simply using a constant array of type sting. I can sequentially pick each string and program my device perfectly. Now I'd like to do things like add the channel # somewhere in the mix, use variable values based on other controls in my .vi to set the parameters of the channel.
EXAMPLE:
The user sets certain values that determine delays and width for an 8-channel DDG (Digital Delay Generator, to some, a pulse generator). These values then need to be loaded into the DDG. The Strings will look something like this:
ULSE1TATE 1
ULSE1:WIDTH 0.009 000 *NOTEpaces behind decimal are for better viewability only
ULSE1ELAY 0.000 000
ULSE1YNC T0
ULSE1:CMODE DUTY
ULSE1COUNTER 1
ULSE1:BCOUNTER 1
ULSE2TATE 1
ULSE2:WIDTH 0.000 300
ULSE2ELAY 0.008 700
ULSE2YNC T0
ULSE2:CMODE NORMAL
So widith and delay params change, the pulse# changes, and whether it's on certain channels decides if the mode is duty or normal and duty comes with the subsequent params pcount and bcount.
help?
PS - I am going to move the state, sync, and cmode to a common, initialize loop run only at program start, but I still need to use width, delay, and (variably) pcount and bcount.
PPS - I am trying to edit post to diable smilies. Commands should read:"colon, P (or D)" not ,
PPPS - Success, at least for me. I disabled smilies in my settings, I don't know if that means my posts won't show smilies or if just what I am looking at won't show smilies, any responders let me know how it's showing for you.
Message Edited by Radiance_Jon on 07-16-2007 01:48 PM
Message Edited by Radiance_Jon on 07-16-2007 01:52 PMsmercurio_fc wrote:
Well, in my experience I have found that dealing with errors early on is the best course of action as it leads to less headaches down the road...
Auto-indexing is one of the more powerful features of LabVIEW. If you're familiar with text-based languages it's equivalent to the "foreach" statement. Basically it allows you to wire an array into a for-loop and the size of the array tells LabVIEW how many times the loop needs to execute. Inside the loop LabVIEW peels of each element of the array in order for each iteration of the loop. Looks like this:
My comment regarding not needing the sequence frame was related to using the error cluster since that wire would allow you enforce data dependency like so:
Note that the VISA resource wire does the same thing.
"I got a little aggravated at how NI seemed to handle the loops in those two frames concurrently". That's because LabVIEW is a data-flow language, and not a sequenced language like C or VB. In fact, that's one of the things that makes LabVIEW so powerful.
Message Edited by smercurio_fc on 07-16-2007 04:48 PM
MAN! I KNEW that!!!! GGRRRRR!!! That makes sense. Actually that's WHY I connected the error lines in the first place was to aide in flow control. OH!!! Still getting used to LabVIEW.
But I still have a question related to flow control. Check out the pic below. LabVIEW runs everything in a seemingly random order... well at least where it STARTS each chain of data. It obviously starts with the static constants or the earliest data in each chain, but I can't figure out how in the world it's deciding WHICH chain to start first. It kind of seems to go with the lower right and work it's way to top-left, but it doesn't exactly do that either. I dunno if it's worth you answering this concern or not, but if you got one for me I'd be much obliged.
I should take a LabVIEW class! Yeah right, as if they'd let me... R&D means I won't need it tomorrow ;( which stinks cause I'm liking LabVIEW the more I learn it. (I was not fond of it in the beginning, but that was my stubborness).
thanks again so much for all your help!!!!
Also, I am using all those strings to make my display appear as I want it to... I wonder if there is another way? I am aware of system labels, but I like the look of the recessed, grayed control boxes better.
Message Edited by Radiance_Jon on 07-16-2007 05:06 PM -
I use the following code to populate a string array:
File dirFile = new File("C:\\somedir");
String fileImport[] = dirFile.list();
This gives me a string array with a whole bunch of files in the following format:
XXXDDMMYYHHMISS.xml
What I need to know is what is the easiest way to sort this array based on this date format, or any date format, in the ascending order, so that when I am loading my XML files, I get the oldest one first.
Appreciate any input.
SamUse the String name of the file (the Date part), together with a java.text.SimpleDateFormat object to parse() the String. You have to set the formatter with a pattern - these are explained fully in the Javadocs for the SimpleDateFormat class. After parsing, you will have java.util.Date objects for each of the files - you can then use these as keys in a java.util.SortedMap (the values would be the files) - the natural ordering of dates will ensure that they are ordered appropriately
-
Reports and flaky text wrapping
Hi There, we have a 10g pdf report running that does some strange things with text wrapping.
If a person were to enter a big long string of "UUUUUU" or "SSSSSSS" or "TTTTTTTTT" or "RRRRRRRR", they would break differently at the edge of the field. The "S"s break at the edge, which is good, the "R"s and "U"s break a little past the edge, which is not so good, and the "T"s break even farther out of the field.
Is this a known issue with Reports? Any suggestions on how to fix? We're stuck with the client's template, so changing the font isn't an option.
TIA,
JPost Author: SKodidine
CA Forum: Exporting
Instead of drawing boxes around the text fields, try right clicking on the text field and under the border tab choose single for all four sides and then export and see if that works for you. Just a thought. -
String Array to Comma spearated list
Hey Guys,
I have a struts application that receives a string[] array of product numbers corresponding to those that a user has selected. I need to put these into a SQL query in the form of "PRODUCTS.PRODUCT_NAME IN ('product1','product2','product3')" -- in otherwords, a comma separated list, with each item wrapped in apostrophes.
I can successfully drop in individual items using notation like the following:
<c:set var="where" value="and PRODUCTS.PRODUCT_NAME IN ('${formChecker4.selectedProductListForm2[0]}')" />What I'm not sure about is the best way to create my comma separated list. In my formChecker4 class, I have getSelectedProductListForm2() and setSelectedProductListForm2() methods, but these expect and return a string[] array, not a plain string. Does anyone have any handy suggestions for converting my array into a string, either within my class or within my EL tags?
Here's some of my formChecker4 class:
private String[] selectedProductListForm2;
public String[] getSelectedProductListForm2() {
return this.selectedProductListForm2;
public void setSelectedProductListForm2(String[] selectedProductListForm2) {
if (selectedProductListForm2.length == 0) {
this.selectedProductListForm2 = null;
} else {
this.selectedProductListForm2 = selectedProductListForm2;
}1) don't do it in JSP
2) [Use a prepared statement. |http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html] -
Getting index of a string array based on user selection in a comboBox
I'm not really sure how to phrase my questions, but here goes.
I have created a string array that holds the values of a ComboBox. Based on which selection the user makes in the comboBox, I need the program to then perform particular calcualtions (based on their selection). I have tried using an ItemListener, but that doesn't seem to work. I've also tried using the ActionListener connected to the ComboBox, again...without results. I'm not sure what I'm looking for exactly, but I know what I want it to do, I'm just not finding the right way to do it. Can anyone help me figure this out?Here is my entire code. I'm completely confused at where to put the ActionListener or how to make it do what I want. Right now I just have it set up to display a simple message in the displayArea, just so that I could see if it was working. I think once I figure out how to get the right index from the ComboBox array, then I'll be able to add the code I need to perform the calcualtions...it's just getting to that step that's not going so well! Any help is appreciated.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
import java.lang.String;
public class MortCalcSR5 extends JFrame implements ActionListener
int term = 0;
double principal = 0;
double rate = 0;
double monthlyPyment = 0;
double interest = 0;
String[] loanChoices = {" ", "7 years @ 5.35%", "15 years @ 5.5%", "30 years @ 5.75%"};
//create panel for input
JPanel inputPanel = new JPanel();
JLabel mortAmtLabel = new JLabel("Mortgage Amount $");
JTextField mortAmtField = new JTextField(15);
JLabel loanSelectionLabel = new JLabel("Loan Selection");
JComboBox loanSelection = new JComboBox(loanChoices);
JTextField loanSelected = new JTextField(15);
//create button panel
JPanel buttonPanel = new JPanel();
JButton calcButton = new JButton("Calculate");
JButton clearButton = new JButton("Clear");
JButton exitButton = new JButton("Exit");
//create panel for payment information
JPanel paymentPanel = new JPanel();
JLabel paymentLabel = new JLabel("Monthly Payment $");
JTextField paymentField = new JTextField(15);
//create panel for text box information
JPanel textPanel = new JPanel();
JLabel numPaymentLabel = new JLabel("Payment #");
JLabel balLabel = new JLabel("Balance");
JLabel ytdPrincLabel = new JLabel("Principal");
JLabel ytdIntLabel = new JLabel("Interest");
//create payment for display area
JPanel displayPanel = new JPanel(new FlowLayout());
JTextArea displayArea = new JTextArea(10,30);
JScrollPane scroll = new JScrollPane(displayArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
public MortCalcSR5()
//set size of GUI display
setSize(400,450);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane = getContentPane();
JScrollPane scroll = new JScrollPane (displayArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
pane.setLayout(layout);
//add components to the inputPanel
GridLayout layout2 = new GridLayout(4,1);
inputPanel.setLayout(layout2);
inputPanel.add(mortAmtLabel);
inputPanel.add(mortAmtField);
mortAmtField.setText(" ");
inputPanel.add(loanSelectionLabel);
inputPanel.add(loanSelection);
loanSelection.addActionListener(this);
pane.add(inputPanel);
//add components to buttonPanel
FlowLayout layout3 = new FlowLayout(FlowLayout.CENTER, 10, 10);
buttonPanel.setLayout(layout3);
buttonPanel.add(calcButton);
buttonPanel.add(clearButton);
buttonPanel.add(exitButton);
pane.add(buttonPanel);
//add listeners to buttons
calcButton.addActionListener(this);
clearButton.addActionListener(this);
exitButton.addActionListener(this);
//add components to outputPanel
FlowLayout layout4 = new FlowLayout(FlowLayout.LEFT, 10,10);
paymentPanel.setLayout(layout4);
paymentPanel.add(paymentLabel);
paymentPanel.add(paymentField);
pane.add(paymentPanel);
//add components to textPanel
FlowLayout layout5 = new FlowLayout(FlowLayout.LEFT, 10,10);
textPanel.setLayout(layout5);
textPanel.add(balLabel);
textPanel.add(ytdPrincLabel);
textPanel.add(ytdIntLabel);
pane.add(textPanel);
//add components to displayPanel
FlowLayout layout6 = new FlowLayout(FlowLayout.CENTER,10,10);
displayPanel.setLayout(layout6);
displayPanel.add(scroll);
pane.add(displayPanel);
setContentPane(pane);
setVisible(true);
public void actionPerformed(ActionEvent event)
String fs = (String)loanSelection.getSelectedItem();
if (fs.equals("7 years @ 5.35%")) {
displayArea.setText("yay");
else
displayArea.setText("blah");
JButton command = (JButton)event.getSource();
if(command==calcButton) //calculate button clicked - run payment event
Payment();
if(command==clearButton) //clear button clicked - clear all fields
mortAmtField.setText(null);
paymentField.setText(null);
displayArea.setText(null);
loanSelected.setText(null); //hidden text field still needs to be cleared
//loanChoices = null;
if(command==exitButton) //exit button clicked - exit program
System.exit(0);
public void Payment()
//perform the calculations
// int mortAmt = Integer.parseInt(mortAmtField.getText());
// double loanSelect = Double.parseDouble((String)loanSelected.getText());
displayArea.append("Calcualations performed!");
public static void main(String[] args)
new MortCalcSR5();
/*/calculations
int mortAmt = Integer.parseInt(mortAmtField.getText()); //get text user entered in mortAmt field - parse it from a string to integer
int loanTerm = Integer.parseInt(loanTermField.getText()); //get text user entered in loanTerm field - parse it from a string to integer
double interestRate = Double.parseDouble(interestRateField.getText()); //get text user entered in interestRate field - parse it from a string to double
int moTerm = (loanTerm*12); //calculate monthly loan term
double moInterest = ((interestRate/100)/12); //calculate monthly interest rate
double payment = mortAmt*(moInterest/(1-Math.pow(1/(1+moInterest), moTerm))); //calculate monthly payment amount
valid = true; //number format is accepted
paymentField.setText(Double.toString(payment)); //display output
*/ -
Hi,
This is probably a simple problem, but I have a csv file with string values in one column and numbers in another. For example:
Volume, 6
Diameter, 5
But much larger of a file.
I would like to be able to read the first column in and come up with an array of just the strings. I have tried using the Read Text from file into the Spreadsheet string to Array into the Index Array functions, but I cannot seem to get this string array to work out, as it just comes up with 0's for any text.
If anyone can point me in the right direction it would be greatly appreciated.
Thank You!!
Solved!
Go to Solution.Hi sean,
you have to convert to an array of strings! Then you will receive your first column as text data...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Maybe you are looking for
-
MAIL ADAPTER TCPGW CONFIGURATION
Hi all I am new to the SDN forum and hence excuse me if this post shouldnt be here. Now i have been trying to configure the mail adapter to work properly with the TCPGW But i have been having a lot of errors. I am very new to this and just on
-
FM/BAPI for Parking a document ( FBV1 )
Hi Experts, We have a requirement where we need to POST a document & then Park It. We are able to post a document using "BAPI_ACC_DOCUMENT_POST ". But we are unable to find a FM/BAPI for Parking a document. We cannot use BDC as the document type is n
-
Hi all, I want to index a few iViews, so the users are able to find them through portal search. For this reason the pcd-folder is now visible in km content and the index service "portalRolesSearch" is enabled, like discribed in the thread: http://www
-
I purchased movies on my iPad 2. They show up in iTunes on my computer (PC). How can I transfer these movies to my iPhone 4? Thanks, tsturgeon
-
Wifi Canon Camera launches iPhoto (in Mavericks), but nothing shows to import?
Prior to upgrading to Maverick, I had no troubles connecting my Canon S110 wirelessly to my neatork, computer, and into iPhoto. Now, when I connect the camera to my computer, the computer detects the connection, and even launches iPhoto, so it's bei