Output strings from loop into one string
im trying my best to explain my problem so ber in mind:)
hey having a bit of trouble with outputing strings from loop
example
i typed ab into the textbox
the output should be 12
but since it is in a loop it would only output the last string and in this case is 2
im trying to get both strings from the loop and output strings from loop into one string.
here is some of my code to understand my problem
// characters a to f
char[] charword = {'a','b','c','d','e','f'};
String charchange ;
// get text from password textbox
stringpassword = passwordTextbox.getText();
try {
// loop to show password length
for ( int i = 0; i < stringpassword.length(); i++ ){
// loop to go through alfabet
for (int it = 0; it < charword.length; it++){
// if char equals stringwords
if (stringpassword.charAt(i) == charword[it]){
System.out.print("it worked");
// change characters start with a
if (charword[it] == 'a'){
charchange = "1";
// change to 2
if (charword[it] == 'b'){
charchange = "2";
}
Not sure how you are displaying the result but you could display each value as soon as you find it.
if (charword[it] == 'a'){
System.out.print("1");
}If it is in a text field then use append. Or if you really need a String with the entire result then use concatenation.
if (charword[it] == 'a'){
charchange += "1";
}
Similar Messages
-
Combining string array elements into one string
Right, I have an string array called str which stores 1 character in each of its 16 elements. It gets this character from another array, strArray. Now, what I want to be able to do is to take all 16 elements and combine them into one string called keyString. Using the code below keyString only prints out the last character. The code is shown below:
for (x=0; x<16; x++) {
str = new String[16];
str[x] = "";
str[x] += (strArray[(index+x)%16].charAt(strChar[x]));
keyString = str[x];
System.out.print(keyString);
}Any help would be very much appreciated.
Edited by: Paragon96 on May 20, 2008 7:32 AMyour logic is wrong ; if you want to concatenate the content of the array, you have to loop (what you did), and concatenate keyString for each index, meaning:
keyString += str[x];you can also use a StringBuilder for such kind of operations -
Split a multiline string from TextEdit into multiple strings
Hi all,
I have a small question. I have a string that comes from a multiline TextEdit used for comments. This string has to be split into multiple strings with max 72 chars. The wrapping is set to "hard".
Can anybody help me on this?
Thanks
FranciscoHi Francisco,
this is the complete code I tested, a bit ugly concerning the println etc... (****, not formatting here?):
package com.btexx;
import java.util.StringTokenizer;
import com.sapportals.htmlb.Button;
import com.sapportals.htmlb.Form;
import com.sapportals.htmlb.TextEdit;
import com.sapportals.htmlb.enum.TextWrapping;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.rendering.IPageContext;
import com.sapportals.htmlb.rendering.PageContextFactory;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class TextEditExample extends AbstractPortalComponent
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
IPageContext pageCtx = PageContextFactory.createPageContext(request, response);
Event lastEvent = pageCtx.getCurrentEvent();
if (lastEvent == null) {
Form form = pageCtx.createFormDocument("myFormDocument");
TextEdit te = new TextEdit("Edit_Text");
te.setId("TextEditID");
te.setText("Text to change - or just add text");
te.setWrapping(TextWrapping.HARD);
te.setTooltip("Edit and/or add text");
te.setRows(10);
te.setCols(72);
form.addComponent(te);
Button btn = new Button("MyButton");
btn.setOnClick("react");
form.addComponent(btn);
pageCtx.render();
} else {
TextEdit te = (TextEdit) pageCtx.getComponentForId("TextEditID");
String text = te.getText();
// for (int j = 0; j < text.length(); j++) {
// System.out.println(text.getBytes()[j] + " - " + text.substring(j, j+1));
StringTokenizer st = new StringTokenizer(text, "nr");
String[] texts = new String[st.countTokens()];
while (st.hasMoreTokens()) {
System.out.println("Line : " + st.nextToken());
I swear, I did not press Return within the TextEdit box, and after that, 13/10 appeared within the text. If just this code does not work the same on your machine, then it seems to be a bug in (your) htmlb (because my P/HF are the most actual, at least they have been yesterday).
Hope it helps
Detlev
Message was edited by: Mark Finnern
added the [code ] [/code ] (without the blanks) -
Need to concatonate multiple values for same key columns into one string
Hi...I'm attempting to use PL/SQL to read through a table containing more than one column value for a set of keys, and concatonate those values together into one string. For example, in the STUDENT table, for a STUDENT_ID there are multiple MAJORS_ACCOMPLISHED such as History, Biology and Mathematics. Each of the majors is stored in a different row with the same STUDENT_ID due to different faculty DEPARTMENT values.
I want to read through the table and write out a single row for the STUDENT_ID and
concatonate the values for MAJORS_ACCOMPLISHED. The next row should be another STUDENT_ID and the MAJORS ACCOMPLISHED for that student..etc.
I've hit a wall trying to use cursors and WHILE loops to get the results I want. I'm hoping someone may have run across this before and have a suggestion. Tks!!I think you are looking for string aggregation.
The following are the replies posted by me in the forum recently on the same case.
they might help you.
Re: Concatenating multiple rows in a table - Very urgent - pls help
Re: Doubt in a query ( Urgent )
Re: How to remove words which consist of max 2 letters?
Re: output like Name1,Name2,Name3... -
Concatenate multiple columns into one string
Hello,
I am using Oracle 11.2, how can I concatenate the value of multiple columns into one string with one SQL:
create table testTb(classId number(5), classRoom varchar2(32));
insert into testTb value(101, 'room101');
insert into testTb value(101, 'room201');
insert into testTb value(101, 'room301');
insert into testTb value(202, 'room444');
insert into testTb value(202, 'room555');
I would like to generate the result as followings:
Class 101 is in room101, room201, room301
Class 202 is in room444, room555
Thanks,Hi,
Since you're using Oracle 11.2, you can use the aggregate LISTAGG function:
SELECT 'Class ' || classid
|| ' is in '
|| LISTAGG ( classroom
) WITHIN GROUP (ORDER BY classroom)
AS txt
FROM testtb
GROUP BY classid
;The generic name for concatenating all the strings in a group is String Aggregation . This page shows several ways to do it, suitable for different versions of Oracle. -
Hello,
In Graphical mapping, Could anyone pls tell me in detail about how to achieve One whole xml into one string element. This XML file i want to send to DATABASE.Thi blog might be of some help
/people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping -
Inserting multiple selection from checkbox into one column of the database
Hi,
How to insert multiple selection values from checkbox into one column of the database.
Anyone can u help me
Thanxhi
try to use request.getParameterValues("fieldname") -
Preventing select-string from adding additional undesired strings in the output file
Hi friends
in PS 4.0 i am trying to write a function which
step1: export the list of all eventlogs ----> wevtutil el > "$home\documents\\loglist1.txt"
step2: deleted the following two lines from loglist1.txt
DebugChannel
Microsoft-RMS-MSIPC
( the reeson of deleting these two lines is wevtutil cl command, can't clear these two evenlogs among approximately 1000 logs)
in fact via select-string with -pattern -notmatch parameters, we select anything except these two line
step3: pastes the select-string contents into the same file ("$home\documents\loglist1.txt") or into new text file (for example
"$home\documents\loglist2.txt")
here is my code:
function MycleareventsAll {
cls
Wevtutil el > "$home\documents\loglist1.txt"
$mycontents = select-string "$home\documents\loglist1.txt" -pattern DebugChannel, Microsoft-RMS-MSIPC -NotMatch
cd "$home\documents\"
$mycontents | out-file loglist2.txt"
# also i tried ---> $mycontents | set-content "loglist2.txt"# also i tried ---> $mycontents | set-content "loglist1.txt"
but the problem is, in addition of deletion, unfortunatelly additional strings (filepath, filename, line number) are added into the final text file so wevtutil will fail clearing logs listed in text file.
here is contents of the final text file
C:\Users\Administrator\documents\loglist.txt:1:Analytic
C:\Users\Administrator\documents\loglist.txt:2:Application
C:\Users\Administrator\documents\loglist.txt:4:DirectShowFilterGraph
but i need the contents be the same as original file without that two specific line:
Analytic
Application
DirectShowFilterGraph
i searched but i didn't find a way to prevent select-string cmdlet from adding these edditional strings
(filepath, filename, line number) into output file while keeping the original contents.
note: -quiet parameter is not what i want. it removes all contents & simply inserts a true or false.
any help?don't forget that Guys here know the basics of security such as clearing event logs & ...
how odd if you don't know this.
clearing all events is useful in test environment for example when i ma teaching my students & need to see all newly created events & work on them
Then you are teching your students how not to use an event log. We use filters and queries to access event logs. We also use event log CmdLets in PowerShell. WEVTUTIL is ok but it does not marry wellwith PowerShell as you have seen.
I have found very few people who are not certified in WIndows administration that know much about eventlogs when it should be a ver important part of administration. PowerShell has mmade EL management much easier but few take the time to learn how
to use the EL support in PowerShell.
I see no point inclearing event logs. It accomplishes nothing.
¯\_(ツ)_/¯
oh your are introducing me filters & queries in event viewer !! please stop Laughing me this way.
your problem is you judge about people's knowledge & you persist on your absurd judgments.
look at your sentence:
"Then you are teaching your students how not to use an event log"
where from you tell this? have you been present in my classes to see what i teach to my students?
have you seen that i told to my students not to use event viewer?
my goal of clearing events is related to myself. it's non of your businesses.
people are not interested to here concurrent irrelevant advises from you like a grandmother. they are searching for a solution. their intent of doing tasks is not up to you. -
How do you store input from keyboard into a string array
I am trying to learn java and one of the programs I am trying to write needs to be able to accept a machine hostname at the keyboard and stuff it into a string array element. I am sure I will be using something along the lines of:
BufferedReader in = new BufferedReader(new InputStreamReader(
System.in));
String str = "";
System.out.print("Enter a FQDN to look up: ");
str = in.readLine();
but how do I get the input stuffed into hostname[ ].
Any hints or assistance will be appreciated.
MichaelWell part of. I need to be able to take a random number of hostnames (ie. mblack.mkblack.com, fred.mblack.com, joe.mblack.com, ...) and after the user presses the enter key between each entry, the inputted information is stored in an array element. for example with the three shown above the array would look like this after the user finished.
hostname {"mblack.mblack.com","fred.mblack.com","joe.mblack.com"};
the algorithm would be
Prompt for hostname
get user input and press enter
store hostname into array element
prompt for next hostname or enter with no input to complete entry and execute lookup.class methods.
I have the program written and working fine if I use a static array where I put the hostnames in the list, but cannot figure out how to get the information from the keyboard to the array element.
Thanks for the help though, the response is very much appreciated.
Michael -
Reading any value from table into a string (Especially date etc..)
How would I read any value from a table into a string?
Currently doing the following...
data ret_val type string.
select single (wa_map-qes_field) from z_qekko into ret_val
where
angnr = _angnr.
When the source field is a date it bombs though.
The result goes into a BDCDATA-fval.
regards
Dylan.Tried...
1 DATA: lp_data TYPE REF TO DATA.
2 FIELD-SYMBOLS: <value> TYPE ANY.
3 CREATE DATA lp_data LIKE (wa_map-qes_field).
4 ASSIGN lp_data->* TO <value>.
5 SELECT SINGLE (wa_map-qes_field) FROM zquadrem_qekko INTO <value> WHERE angnr = _angnr.
Complains that (wa_map-qes_field) is not defined in line 3.
Think that the bracket thing is only available via SQL.
What about CREATE DATA lp_data type ref to object. ?
Would the above declaration work?
regards -
SSRS Report Returning Double Quote string from a Single Quote String
Hi, I'm getting weird thing in resultset from SSRS report when executed. When I pass parameter to a report, which passes String that has single quote value to a split function , it returns rows with double quote.
For example following string:
'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
Returns:
''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
through SSRS report.
Here is the split function Im using in a report.
CREATE Function [dbo].[fnSplit] (
@List varchar(8000),
@Delimiter char(1)
Returns @Temp1 Table (
ItemId int Identity(1, 1) NOT NULL PRIMARY KEY ,
Item varchar(8000) NULL
As
Begin
Declare @item varchar(4000),
@iPos int
Set @Delimiter = ISNULL(@Delimiter, ';' )
Set @List = RTrim(LTrim(@List))
-- check for final delimiter
If Right( @List, 1 ) <> @Delimiter -- append final delimiter
Select @List = @List + @Delimiter -- get position of first element
Select @iPos = Charindex( @Delimiter, @List, 1 )
While @iPos > 0
Begin
-- get item
Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) )
If @@ERROR <> 0 Break -- remove item form list
Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 )
If @@ERROR <> 0 Break -- insert item
Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break
-- get position pf next item
Select @iPos = Charindex( @Delimiter, @List, 1 )
If @@ERROR <> 0 Break
End
Return
End
FYI: I'm getting @List value from a table and passing it as a string to split function.
Any help would be appreciated!
ZKAnother user from TSQL forum posted this code which is returning the same resultset but when I execute both codes in SQL server it works and return single quote as expected.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8d5c96f5-c498-4f43-b2fb-284b0e83b205/passing-string-which-has-single-quote-rowvalue-to-a-function-returns-double-quoate?forum=transactsql
CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
AS
BEGIN
WHILE CHARINDEX(@delim,@string) > 0
BEGIN
INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
END
INSERT INTO @result (value) VALUES (@string)
RETURN
END
GO
ZK -
Combining output of 2 spools into one
Hi guys,
I have 2 program which are called by main program both are generating spools.
I want to combine the outputs of both the spools into one file(eg pdf).
Can anyone suggest how to do this if possible.
Regards,
Guruhi
good
If you create repeated spool requests in the same transaction, you can combine them into one spool request. For you to be able to do this, this option must be deactivated for the spool request to which you want to add the others.
If you do not select this field, the spool system automatically adds additional spool requests that have the same attributes (user, title, output device, client from which the request was issued, number of copies, priority, cover sheet setting, archiving mode, and ABAP session number).
For a spool request to be added to another, you must deactivate the New Spool Request option when creating the spool request.
If you are combining requests, note the following rules:
- If the expiration dates of combined spool requests are not the same, the spool system uses the latest date for the entire spool request.
- To print out a "combined" spool request, set the Print immediately option on the last of the spool requests that is to be added. The spool system adds the last spool request and then sends the entire "combined" spool request to the output device.
If the following situations exist, you cannot add any additional requests:
- A request is "completed" and cannot have additional jobs added to it when it has been sent to the host spooler for printing.
- No other spool requests can be added to a spool request you generated with the Print immediately option set or that you sent to the printer from the output controller.
For more information, see Adding Spool Requests to Another Spool Request.
· Delete After Printing if No Errors: If this field is selected, the spool request, output request, and output data are deleted automatically after the request has been successfully printed.
The spool system retains spool requests that contain errors. You need to delete requests of this type manually. Otherwise, they are automatically deleted during a reorganization of the spool database after the expiration date.
The delete option is set in a user's master record and can be changed:
- When a spool request is created
- In the request attributes () for the spool request
thanks
mrutyun^ -
Facing problem to upload MRP output PO from more than one user
We have 11 users in our company. but we can upload MRP output PO from only one user. we need to upload from more users... please help
Hi Hitul,
Query is not clear.
MRP output will be planned order or purchase requsition. Purchase requsition further converted to purchase order. Are you using any Z developed program for uploading the Purchase Orders (PO) in system ? If so there might be some restriction coded in the program for upload by authorized user id which colud be maintained in any Ztable. Please check and come back. If my understanding is wrong please eleborate your requirement.
Thanks & Regards,
Ramagiri -
Output results from loop inside query
Hi
Im having an issue outputting vars from a table with multiple
ID’s
Basically heres and example of what I I am trying to display
Show All Project” with the Proj ID of 146 AND 147
My results should return 2 vars.
But none are shown…
Please can someone help me here….
Thanks again
DelonChange this:
WHERE ProjID = 146 AND ProjID = 147
to this
WHERE ProjID in (146,147) -
Mapping question: n recordsets with m fields into one string
Hi,
My input message will look like
<customer>
<name>name</name>
</customer>
<row1>
<customer>name</customer>
<field11>111</field11>
<field12>122</field12>
</row1>
<row2>
<customer>name</customer>
<field21>211</field21>
<field22>222</field22>
</row2>
<rown>
<customer>name</customer>
<fieldn1>n11</fieldn1>
<fieldn2>n22</fieldn2>
</row1>
and i need an output like
<customer>
<name>name</name>
</customer>
<rowx>
<fieldx>111222211222.........n11n22</fieldx>
</rowx>
in short all fields from row1 to rowx need to be concatened in one big string.
What is the best way to do this?
Kr
RobertSurely Using UDF/ Java Mapping it is easy .
What version are u working on .
IF 7.1 , try Using Global Variable ( Graphical variable ) on receiver side.
Lets see if it worked.
try Like this
field11 -> Concat -> Graphical Variable
Graphical Variable ->
I am expecting every time value of field11 will be conactinated with previously store Graphical Variable .
Similarly for all other fields .
and in last Concate them all fields to One Output Final String.
Check this link . If you want to know the working of Graphical variable .
SAP PI 7.1 Mapping Enhancements Series: Graphical Variables.
/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable
Regards
PS
Maybe you are looking for
-
HP Pavilion DV8000 Dead?
Help! My laptop appears to be dead. When I turn it on the lights for hard drive and cd drive blink in unison and cd drive sounds(grinds) during blink. Most importantly the screen remains black and the power button does not turn it off.
-
Can I use Oracle 10g XE in my production enviroment
Hello All, Please can somebody help me here. I would like to know if I can use Oracle 10g XE for my Production Software Development? If yes, can somebody help with the following: a) Can I access the oracle database XE from a remote system without ins
-
How to reposition subtitles in Quicktime?
Hello community, I am wondering if there is a way to reposition subtitles in Quicktime player and then re-export as an MP4 file for the iPad. Currently the subtitles appear at the bottom of the screen, and I want them to appear at the top. Does any
-
Placing a animated GIF pic with .Mac mail
Hello, I am a pretty experienced user and cannot find a way to attach an animated GIF to my email. I use .Mac mail and downloaded a program to make animated pictures. The only program I can animate my pics in is Text Edit. I did a thorough search and
-
Hi Sap Community, I am trying to load Sales and Cost prices using COND_A. However i receive an error message status "51" stating the following: No authorization for Create for condition type PB00 Message no. VK085 When i run the failed created IDOC f