Input a string value
What is the simplest method to accept an input of string value? Is buffering or string tokenizer required to perform this?
vinayv wrote:
What is the simplest method to accept an input of string value? Is buffering or string tokenizer required to perform this?It depends what you're doing. StringTokenizer isn't used to get an input value, it's used to separate it out into tokens. It's also deprecated in favor of String.split.
You might want to use BufferedReader's readLine method. Or you might want to use Scanner's next, nextLine, nextInt, etc. It depends on how you're consuming and parsing input. You might even want to check out the Console class introduced in version 6.
Start here, and play around with the above until you find what best suits your needs.
http://java.sun.com/docs/books/tutorial/essential/io/index.html
Similar Messages
-
How to connect input string value to numerical values
Hello,
I am trying to figure out how to connect a single user's input string value to numerical values. Basically I want the user to input the name of a gas that I have a list for (I believe i put the list of gasses in an array>). Then I want to match 2 numerical values "a" and "b" depending on which gas name the user has put in. These "a" and "b" values will be automatically matched with the gas name from a list I put. For example the gas hydrogen has a value of 3 for "a" and 4 for "b. so when the user puts the name "hydrogen" in a string constant, automatically "a" and "b" should be outputted. I will be connecting a and b to a formula
Thanks for any help
Solved!
Go to Solution.student11 wrote: These "a" and "b" values will be automatically matched with the gas name from a list I put. For example the gas hydrogen has a value of 3 for "a" and 4 for "b".
This sounds a lot like an Enum to me. Make sure you type def the enum to make sure updates quickly and easily make it to all copies of the enums.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
HELP INPUT TYPE = hidden values SEEN IN URL QUERY STRING!!!
Trying to do session management using hidden fields.
The fields that are suppose to be hidden show up in the query string of the URL.
I have included the code, the output to the web page
and the URL with the "hidden" fields please help.
HIDDEN FIELDS IN URL QUESRY STRING
http://localhost:8080/myApp/servlet/Servlet077?firstName=Sandra&item=Michael
WEB PAGE OUTPUT
Enter a name and press the button
Name:
Your list of names is:
Michael
Sandra
JAVA SOURCE CODE
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Servlet077 extends HttpServlet{
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException{
//An array for getting and saving the values contained
// in the hidden fields named item.
String[] items = req.getParameterValues("item");
//Get the submitted name for the current GET request
String name = req.getParameter("firstName");
//Establish the type of output
res.setContentType("text/html");
//Get an output stream
PrintWriter out = res.getWriter();
//Construct an HTML form and send it back to the client
out.println("<HTML>");
out.println("<HEAD><TITLE>Servlet07</title></head>");
out.println("<BODY>");
//Substitute the name of your server or localhost in
// place of baldwin in the following statement.
out.println("<FORM METHOD=GET ACTION="
+ "\"http://localhost:8080/myApp/servlet/Servlet077\">");
out.println("Enter a name and press the button<P>");
out.println("Name: <INPUT TYPE=TEXT NAME="
+ "\"firstName\"><P>");
out.println("<INPUT TYPE=submit VALUE="
+ "\"Submit Name\">");
out.println("<BR><BR>Your list of names is:<BR>");
if(name == null){
out.println("Empty<BR>");
}//end if
if(items != null){
for(int i = 0; i < items.length; i++){
//Display names previously saved in hidden fields
out.println(items[i] + "<BR>");
//Save the names in hidden fields on form currently
// under construction.
out.println("<INPUT TYPE = hidden NAME=item "
+ "VALUE=" + items[i] + ">");
}//end for loop
}//end if
if(name != null){
//Display name submitted with current GET request
out.println(name + "<BR>");
//Save name submitted with current GET request in a
// hidden field on the form currently under
// construction
out.println("<INPUT TYPE = hidden NAME=item "
+ "VALUE=" + name + ">");
}//end if
out.println("</body></html>");
}//end doGet()
}//end class Servlet071. Change <form name=xxx action="your_servlet" mathod="Get"> to
<form name=xxx action="your_servlet" mathod="POST">
2. Add the following lines of code to your servlet.
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doGet(req,res);
return;
}Sudha -
How to update a string value located on the main VI
Hello
I would like, from a subVI, to update a string value located in the main VI (using References). I was trying to find examples on NI web page but it´s impossible to download them (for more than one month : Error, File Not Found), do everyone has got the same problem?
Thanks for your answer
NicolasHi,
this is from LV help file:
Complete the following steps to create a subVI that includes a control reference directly from a Property Node.
1.On the block diagram, right-click the front panel object terminal for which you want a control reference and select Create»Property Node from the shortcut menu to create a Property Node implicitly linked to the object. You can have multiple Property Nodes for multiple front panel objects.
2.Use the Positioning tool to select the new Property Node and select Edit»Create SubVI from menu. LabVIEW automatically creates a control reference to the control on the block diagram of the main VI, creates a subVI that contains a control refnum wired to a Property Node, and wires the control reference on the main VI to the
control refnum input terminal of the new subVI.
Note: Select several Property Nodes at once to create a subVI with multiple control refnums and Property Nodes.
3.Double-click the subVI to open it. Modify the Property Node and other elements of the subVI as you do in any other VI.
4. If you want to change values of control then select "Value" property in Property node.
I've attached the examples.
Good luck.
Oleg Chutko.
Attachments:
Ref.zip 11 KB -
Can I pass a string value to a double numeric indicator?
I am doing a sequence of tests and saving each tests datas. When I bypass one of the tests, I need the string value 'BP' to get saved ( in the double numeric indicator ) for that particular test. Is there any possible way to do that?
Solved!
Go to Solution.The numeric indicator works like a "Format into String" function with a hardwired numeric input.
So it really is a string indicator in the end.
You can use the "Format String" property node to modify how the numeric is displayed.
(Also available in Display Format ... --> Advanced Edit Mode.)
I don't think you can avoid displaying the numeric value, but you can add text.
So you could, for example, display: "0 BP".
Format string normal = "%#.2f";
Format string adding " BP" text = "%#.2f BP";
Some of the suggestions by others on this thread might be easier to manage and give a better result.
(You have to swap Format Strings around and still have the numeric displayed.)
*Note however, that this technique can be used to do interesting things like add Units to your numeric indicator.*
steve
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help. -
Problem in sending XML input as String in BPEL
Hi,
We have a BPEL flow (assign, invoke, assign) which takes an XML input as String.
<RegisterCustomerOnVAS><CustomerID>100</CustomerID><MSISDN>9999999</MSISDN><CustomerName>sanjeev</CustomerName><customerInfo>new user</customerInfo></RegisterCustomerOnVAS>
Assignment is doing fine, but when Invoke calls partner link, the input is getting parsed and only the first text value (eg 100) is getting passed to the partner webservice instead of the entire XML as string.
Can any one please help us in fixing in this problem.
ThanksHi,
You should watch your assign activity (maybe a bad assigment level in copy rule). I think the probem is there.
Cyryl -
Switching between 2 string values
This is probably a trivial question, but how do I switch between 2 string values to be sent to one input terminal of a larger concatonated string function. The values need to be changed every 100ms or so.
Thanks
mhaque
Solved!
Go to Solution.Why so complicated???
You can do this particular string manipulation in a single atomic operation using "Append True/False String"
LabVIEW Champion . Do more with less code and in less time .
Attachments:
AppendTF.png 3 KB -
I need to validate Input List Of Values Field when Inserted From Bean
I've two view object EmployeeView and DepartmentsView
In Employee View I've changed Department_Id to Input List OF Values
I've created a bean to inset data into Employee Table
ApplicationModule am = ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
ViewObject importedVO = am.findViewObject("EmployeesView");
try {
newEmp.setEmployeeId(new Number("3424));
newEmp.setFirstName("Test Fname");
newEmp.setLastName("Test Lname");
newEmp.setEmail("[email protected]");
newEmp.setPhoneNumber("4643131345");
newEmp.setJobId("AD_VP");
newEmp.setDepartmentId(new oracle.jbo.domain.Number(999));
} catch (Exception e) {
// TODO: Add catch code
System.out.println("inside Catch");
e.printStackTrace();
}I know that ADF validate Input list of values when inserting new value on it
when I've enabled the debugger I've found that
<ViewObjectImpl><buildQuery> [604] SELECT DepartmentsEO.DEPARTMENT_ID, DepartmentsEO.DEPARTMENT_NAME, DepartmentsEO.MANAGER_ID, DepartmentsEO.LOCATION_ID, DepartmentsEO.ISDELETED FROM DEPARTMENTS DepartmentsEO WHERE ( ( (DepartmentsEO.DEPARTMENT_ID = :vc_temp_1 ) ) )
<ViewObjectImpl><bindParametersForCollection> [605] Bind params for ViewObject: [com.test.model.views.DepartmentsEOView]AppModule.__LOCAL_VIEW_USAGE_com_test_model_views_EmployeesEOView_DepartmentsView_findByVC_12_LOV_DepartmentId_lov__filterlist__vcr___
<OracleSQLBuilderImpl><bindParamValue> [606] Binding param "vc_temp_1": 999
<ViewObjectImpl><processViewCriteriaForRowMatch> [607] VCs converted to RowMatch: ( (DepartmentId = :vc_temp_1 ) )
<ViewRowImpl><handleListBindingMismatch> [608] No matching row found for list binding:LOV_DepartmentId for ViewRow:oracle.jbo.Key[34235 ]
<ViewRowImpl><handleListBindingMismatch> [609] --- filterList ValueMap key:DepartmentId, value:999
<DCBindingContainer><internalRefreshControl> [610] **** refreshControl() for BindingContainer :com_test_view_testInsertPageDef
<JUCtrlHierNodeBinding><release> [611] released: ROOT node binding:noCtrl_oracle_adfinternal_view_faces_model_binding_FacesCtrlHierNodeBinding_2, value:EmployeesViewIterator
<JUCtrlHierNodeBinding><release> [612] released: ROOT node binding:noCtrl_oracle_adfinternal_view_faces_model_binding_FacesCtrlHierNodeBinding_2, value:EmployeesViewIterator
<DCIteratorBinding><releaseDataInternal> [613] Releasing iterator binding:EmployeesViewIterator
<ApplicationPoolMessageHandler><doPoolMessage> [614] **** PoolMessage REQ ATTACH LWS
<ApplicationPoolMessageHandler><doPoolMessage> [615] **** PoolMessage REQ DETACH LWS
<DCJboDataControl><initializeApplicationModule> [616] (oracle.adf.model.bc4j.DataControlFactoryImpl.SyncMode = Immediate
<DCBindingContainer><internalRefreshControl> [617] **** refreshControl() for BindingContainer :com_test_view_testInsertPageDef
<DCBindingContainerState><validateToken> [618] Process BindingContainer state token(decompressed state):BCST:=0%V%=NEmployeesViewIterator=-D-,
<this means that ADF tries to validate the input list of values "Department_Id" and didn't found any match
I need to through exception when I try to set Department_ID with invalid value "value not on range" like
newEmp.setDepartmentId(new oracle.jbo.domain.Number(999));I don't want to validate it manually as I've a lot of fields.
I need to through exception when try to
newEmp.setDepartmentId(new oracle.jbo.domain.Number(999));Thanks Timo
this is the code that I use
ApplicationModule am = ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
ViewObject importedVO = am.findViewObject("EmployeesView");
EmployeesEOViewRowImpl newEmp = (EmployeesEOViewRowImpl)importedVO .createRow();
importedVO .insertRow(newEmp);
try {
newEmp.setEmployeeId(new Number("3424));
newEmp.setFirstName("Test Fname");
newEmp.setLastName("Test Lname");
newEmp.setEmail("[email protected]");
newEmp.setPhoneNumber("4643131345");
newEmp.setJobId("AD_VP");
newEmp.setDepartmentId(new oracle.jbo.domain.Number(999));
} catch (Exception e) {
// TODO: Add catch code
System.out.println("inside Catch");
e.printStackTrace();
} -
Parameters To Include Null Or Empty String Values
I have a table that has both Nulls & Empty Strings that I want to use as a Dynamic Parameter. Even though there is an indication of the Null/Empty String value when the parameter prompt comes up, selecting the value of Null/Empty String results in no records being returned. I have a formula to display the values in the report (where I substitute "Unknown" for the Null/Empty String values), but I am not able to do a parameter on that formula.
I guess in general, this is a situation of needing to be able to use a Dynamic Parameter based on a formula field.
Thanks for any assistance!
Edited by: Dragon77 on Apr 2, 2010 9:39 AMI'd use a SQL Command as the data source for the list of values. Something like this... (MS SQL Server)
SELECT DISTINCT
CASE WHEN t.StringField IS NULL OR t.StringField LIKE ''
THEN 'Unknown' ELSE t.StringField END AS StringField
FROM TableName AS t
ORDER BY StringField
Then use a formula like this in the selection criteria.
IF {?Parameter} = "Unknown"
THEN (ISNULL ({TableName.StringField}) OR {TableName.StringField} LIKE "")
ELSE {TableName.StringField} = {?Parameter}
HTH,
Jason -
How to get string value from xml in JSF??
In JSF How to get string value from xml, .ini and properties file. I want to get string value from xml or text to JSF
Just use the appropriate API's for that. There are enough API's out which can read/parse/write XML, ini and properties files. E.g. JAXP or DOM4J for xml files, INI4J for ini files and Sun's own java.util.Properties for propertiesfiles.
JSF supports properties files as message bundle and resource bundle so that you can use them for error messages and/or localization. -
How to get string value from database table using Visual Studio 2005?
Hi,
Im developing plugin in illustrator cs3 using visual studio 2005. I need to get the values eneterd in database. Im able to get the integer values. But while getting string values it is returning empty value.
Im using the below code to get the values from database table
bool Table::Get(char* FieldName,int& FieldValue)
try
_variant_t vtValue;
vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
FieldValue=vtValue.intVal;
CATCHERRGET
sprintf(m_ErrStr,"Success");
return 1;
Im using the below code to get the values.
AIErr getProjects()
char buf[5000];
int i;
std::string catName;
::CoInitialize(NULL);
Database db;
Table tbl;
errno_t err;
err = fopen(&file,"c:\\DBResult.txt","w");
fprintf(file, "Before Connection Established\n");
//MessageBox(NULL,CnnStr,"Connection String",0);
if(!db.Open(g->username,g->password,CnnStr))
db.GetErrorErrStr(ErrStr);
fprintf(file,"Error: %s\n",ErrStr);
fprintf(file, "After Connection Established\n");
if(!db.Execute("select ProjectID,ProjectName from projectsample",tbl))
db.GetErrorErrStr(ErrStr);
fprintf(file,"Error: %s\n",ErrStr);
int ProjectID;
int UserID;
int ProjectTitle;
char ProjectName[ProjectNameSize];
if(!tbl.ISEOF())
tbl.MoveFirst();
ProjectArrCnt=0;
for(i=0;i<128;i++)
buf[i]='\0';
int j=0;
while(!tbl.ISEOF())
if(tbl.Get("ProjectID",ProjectID))
fprintf(file,"Project ID: %d ",ProjectID);
ProjectInfo[ProjectArrCnt].ProjectID = ProjectID;
sprintf(buf,"%d",ProjectID);
//MessageBox(NULL, buf,"f ID", 0);
j++;
else
tbl.GetErrorErrStr(ErrStr);
fprintf(file,"Error: %s\n",ErrStr);
break;
//if(tbl.Get("ProjectTitle",ProjectName))
if(tbl.Get("ProjectName",ProjectName))
MessageBox(NULL,"Inside","",0);
fprintf(file,"ProjectTitle: %s\n",ProjectName);
//catName=CategoryName;
ProjectInfo[ProjectArrCnt].ProjectName=ProjectName;
//sprintf(buf,"%s",ProjectName);
MessageBox(NULL,(LPCSTR)ProjectName,"",0);
else
tbl.GetErrorErrStr(ErrStr);
fprintf(file,"Error: %s\n",ErrStr);
break;
ProjectArrCnt++;
//MessageBox(NULL, "While", "WIN API Test",0);
tbl.MoveNext();
//MessageBox(NULL, ProjectInfo[i].ProjectName.c_str(),"f Name", 0);
::CoUninitialize();
//sprintf(buf,"%s",file);
//MessageBox(NULL,buf,"File",0);
fprintf(file, "Connection closed\n");
fclose(file);
for(i=0;i<ProjectArrCnt;i++)
sprintf(buf,"%i",ProjectInfo[i].ProjectID);
//MessageBox(NULL,buf,"Proj ID",0);
//MessageBox(NULL,ProjectInfo[i].ProjectName.c_str(),"Project Name",0);
return 0;
In the above code im geeting project D which is an integer value. But not able to get the project name.
Please some one guide me.As I said in the other thread, this really isn't the place to ask questions about a database API unrelated to the Illustrator SDK. You're far more like to find people familliar with your problem on a forum that is dedicated to answering those kinds of questions instead.
-
Getting string values from DB query
I am using the following code:
<%@ page import="java.sql.*" %>
<%
String userName = request.getParameter("usernameField");
String password = request.getParameter("passwordField");
String connectionURL = "jdbc:mysql://localhost:3306/babbemployees?user=DBUser;password=MyPassword";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection (connectionURL, "DBUser", "MyPassword");
statement = connection.createStatement();
String queryString = "SELECT * FROM tbemployees where userID='"+userName+"'";
rs = statement.executeQuery(queryString);
String isAuthenticated;
if (userName == rs.getString("userID") && password == rs.getString("password")[0])
isAuthenticated = "AUTHENTICATED";
else
isAuthenticated = "NOT AUTHENTICATED";
rs.close();
%>
<html>
<body>
<h1><%= isAuthenticated %></h1>
<hr>
</body>
</html>I am trying to get a String value for rs.getString() but for some reason this is not working out. Is there anything I can do to get the values for the queries in a String value?
Thanks,
HarlinWhen a ResultSet is returned to you, it is always positioned before the first row.
You need to insert a rs.next(); after your executeQuery(). -
How to include input user parameter values in XML report output?
How can i include input user parameter values in XML report output. I a have a report which can be run by providing start date and end date. I would like to include value of these parameters in XML output to enable me to figure out dates for report, just by looking at XML output.
Rgds,
manishI think all the XML attributes can contain lexicals. If you bring up the property palette against the report object you can just set the following:
XML Tag Attributes: myParameter="&<P_1>"
where P_1 is your user parameter. -
How do I know if I can convert a String value to an int value or not?
Hi,
I want to know how to make the judgment that if I can convert a String value to an int value or not? Assume that I don't know the String is number or letters
Thank youEncephalopathic wrote
Again, why?One of the problems (have been dued) in my codelab asks us to write a class as follow
Write a class definition of a class named 'Value' with the following:
a constructor accepting a single integer paramter
a constructor with no parameters
a method 'setVal' that accepts a single parameter,
a boolean method, 'wasModified' that returns true if setVal was ever called for the object.
a method 'getVal' that returns an integer value as follows: if setVal has ever been called, it getVal returns the last value passed to setVal. Otherwise if the "single int parameter" constructor was used to create the object, getVal returns the value passed to that constructor. Otherwise getVal returns 0.
The setVal(int y) returns nothing, so how do I know whether it has been called or not?
Thank you -
Can't assign a string value to a member of type TEXT in Calculation Manager
I can assign a string value to that member of type TEXT using a run-time prompt of type StringToNumber.
Example: "My Text Member" = {string_rtp};
However, I need to accompllish the same function without using a run-time prompts.
I have a planning application and I know that text along with all other non-numeric
values are stored on the relational side in the planning application schema.
It seems reasonable to assume that if this can can accomplish
with a run-time prompt that I could do also do it without a run-time prompt.
What appears to be lacking is a function like:
"My Text Member" = @StringToNumber(<String Literal>);
Clearly, this is already being done "under the covers" for run-time prompts. If
would appear to be a minor enhancement to expose such a function to developers.
NOTE: I suppose you would also need to add new syntax/function to identify a string
literal from say a member name. I'm wondering if this is the more difficult challenge
from a product perspective????When executing a Calculation Manager rule in Planning, the run-time prompt (RTP) is populated by looking up the outline information present in the relational Planning application database. If the RTP is of type TEXT, the strings displayed in the member select are from the from the relational Planning application database too. Subsequently when executing the Rule, the RTP's value is in fact the record ID (a number) which is then saved into the appropriate intersection in Essbase.
You need to bear in mind, the Rule is executed in Essbase. If Essbase needs to "write" a text, it would then need to connect to the Planning relational database to create a new record. The newly created record ID then needs to be feed back to Essbase, in order to store it in the appropriate intersection.
What you are suggesting, comes with a big overhead causing Essbase and the rule to slow. Thus, the disadvantages outweighs the advantages.
Maybe you are looking for
-
I am unable to play streaming video, and can't download anything. I have removed or disabled all of my security programs. == This happened == Every time Firefox opened == About 2 weeks ago, downloaded most recent Windows service pack
-
How to make pdf files save protected
Hi, We have displayed some company policy documents on our portal, we want to make those pdf files save protected and print protected, i.e we want to make the save and print button disabled. Can you please help out with this issue.
-
Do you "defrag" apple computers like other computers? My laptop seems to be running slow, and someone suggested I defrag it to get rid of "cookies" that can slow it down.
-
I've shared my doc, sent links to people, but no one can open them
Can I really share my docs with just anyone, or just people I specify, or do you have to have an adobe online acct to read them, or what? This is very confusing . Everyone I send the link to tells me it just opens a page that tries to get them to sig
-
For a paid ibook account i need a us tax id, how to get it?
For a paid ibook account i need a us tax id, how to get it?