I need to "read" a string....

Please, excuse my poor engilsh...
I have one txt file with some variables. I want to choose
dynamic what variable from them i want to use. Lets say that the
txt file has the following:
&t1=0&
&t2=1&
If I want to place the t2 into a textbox (calld textbox1) i
can simply do:
LoadvariablesNum ("file.txt", 0);
this.tetxtbox1.text=_root.t2
Now I'm creating a variable with some calculations to define
what from t1or t2 i need .. f.e.
var page=2
var iwant="_root.t"+page
the problem i have is that when now i'm trying
this.textbox1.text=iwant
instead to have the t2 result i'm getting "_root.t2"
I need your help. How i can declare that the "iwant" is
something that i want to read? not just write?
Thank you very much for your timeText

use:

Similar Messages

  • Need to read Unicode in a file

    Hi,
    My need to read Unicode from a file (on a Windows box) is due to the fact my software is used in different countries and on different keyboard naturally. All the users are not computer literate but, like me, they are all lazy and want to put their username and password in a config file my application reads. If their username or password contain Unicode characters I have a problem reading.
    They are simple users that I would like to advise them to open the config file using Windows Notepad, then type in their username and password, and save the file as Unicode. Notepad has four ways to save a file, ANSI, Unicode, Unicode big endian, and UTF-8 (I've tried them all except ANSI of course). Saving a file in a different format is as complicated as I would like it to get for them, some will have trouble even with this.
    I read the file like so:
    BufferedReader rdr =
        new BufferedReader(
            new InputStreamReader(new FileInputStream(file_name), "UTF-16"));
    String line;
    while ((line = rdr.readLine()) != null) {
        String[] pieces = line.split("[=:]");
        if (pieces.length == 2) {
            if (pieces[0].equals("PASSWORD")) {
                byte[] possibleUnicode = pieces[1].getBytes("various encodings");
                pieces[1] = new String(possibleUnicode, "various encodings");
            propertyTable.setProperty(pieces[0], pieces[1]);
    }All reading is perfect except for a username or password which can contain a real multi-byte character. I have used many variations of converting the string I get into a byte[] using string_in.getBytes("various encodings tried") and then back to a string but nothing has worked.
    I tried a regular FileReader to a BufferedReader and that didn't work. I tried a FileInputStreamto a DataInputStream and that didn't work. I accomplished the most with what I described above, FileInputStream to InputStreamReader to BufferedReader.
    Does anyone know how to read Unicode in a file on a Windows file system?
    hopi

    I have used the byte conversion technique before
    successfully when I loaded a set of properties
    from a URL openStream(). The properties load()
    method takes an InputStream and assumes ISO-8859-1
    so I converted the bytes from ISO-8859-1 to UTF-8.
    Garbage characters were cleared up perfectly.I think you just got lucky that time. For characters up to U+007F, the UTF-8 encoding is the same as ISO-8859-1 (and most other encodings, for that matter). Characters in the range U+0080 to U+00FF will be encoded with one byte in ISO-8859-1, and with two bytes in UTF-8. In most cases, each of the two bytes in the UTF-8 representation will have values that are valid in ISO-8859-1. The decoded characters will be incorrect (and there will be too many of them), but they effectively preserve the original byte values, making it possible for you to re-encode the characters and then decode them correctly. But there's a big gap in the middle where the UTF-8 bytes produce garbage when decoded as IS)-8859-1. Run the included program to see what I mean.
    I don't know what's going wrong with your application, but I do know that changing the encoding retroactively is not the solution. I also think you're right about asking users save files in a certain encoding. Considering how much trouble programmers have with this stuff, it's definitely too much to ask of users.
    import java.awt.Font;
    import javax.swing.*;
    public class Test
      public static void main(String... args) throws Exception
        JTextArea ta = new JTextArea();
        ta.setFont(new Font("monospaced", Font.PLAIN, 14));
        JFrame frame = new JFrame();
        frame.add(new JScrollPane(ta));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        StringBuilder sb = new StringBuilder();
        for (int i = 0xA0; i <= 0xFF; i++)
          sb.append((char)i);
        String str1 = sb.toString();
        byte[] utfBytes = str1.getBytes("UTF-8");
        String str2 = new String(utfBytes, "ISO-8859-1");
        for (int i = 0, j = 0; i < str1.length(); i++, j += 2)
          char ch = str1.charAt(i);
          byte b1 = utfBytes[j];
          byte b2 = utfBytes[j+1];
          String s1 = Integer.toBinaryString(b1 & 0xFF);
          String s2 = Integer.toBinaryString(b2 & 0xFF);
          char ch1 = str2.charAt(j);
          char ch2 = str2.charAt(j+1);
          ta.append(String.format("%2c%10s%10s%3x%3x%3c%3c\n",
              ch, s1, s2, b1, b2, ch1, ch2));
        frame.setSize(400, 700);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

  • Reading a String with dynamic format.

    Hello,
    I'm learning Java and I'm relatively new to the scene. I decided to make a small free utility with the hope that it will help somebody. The utility is a Game Server (Call of Duty 4) connector that will help Administrators to connect to the server and execute commands without the need of running the game.
    I have made a progress so far by searching these (very useful) forums but I came across a point that I can't by pass.
    The only way to learn "Who Is" from the server is the rcon command "status". Using this command the server returns you the current map and the players playing with all their information. This is the part of the code that I need help at:
    public static void StatusReader(String StatusInput) throws IOException {
                     ArrayList line = new ArrayList();
                        BufferedReader br = new BufferedReader(new StringReader(StatusInput));
                       String s = null;
                       int l=0;
                  dokimi = StatusInput.split("\n");
             //    for(int j=0;j<9;j++){
              //        int i=0;
              //        dokimi2 = new String[0][0];
              //        dokimi2[0][0] = dokimi[0];
              //        System.out.println(dokimi2[0][0]);
                  System.arraycopy(dokimi, 0, dokimi2, 0, 1);
                for(int i=0;i<(dokimi.length/9);i++){
                        for(int j=0;j<9;j++){    
                       dokimi2 = new String[i][j];
                       System.arraycopy(dokimi, 0, dokimi2[i][j], 0, 1);
                       System.out.println(dokimi2[i][j]);
             //     while ((s = br.readLine()) != null)
                  //     line.add(s);
                   //  StatusOutput = new String[line.size()][];
                  //     for (int i = 0; i < StatusOutput.length; i++) {
                  //               s = (String) line.get(i);
                       //          StringTokenizer st = new StringTokenizer(s, "");
                  //               String[] arr = new String[st.countTokens()];
    //                       for (int j = 0; j < arr.length; j++)
      //                                arr[j] = st.nextToken();
            //               StatusOutput[i] = arr;
               //          for (int i = 0; i < StatusOutput.length; i++) {
          //                    for (int j = 0; j < StatusOutput.length; j++)
    //                         System.out.print(StatusOutput[i][j] + " ");
         //                    System.out.println();
    }I've been messing a lot with the code. +_What I want to do is to read this string that the server is sending,split it, and then place it in a 2D Array that I will attach on a table._+ So far I've made the StringTokenizer method to be able to , kind of, sort that String and put it in an array. However I usually get outofbounds errors because not always the lines have the same length. This is an example of the format that the server sends after executing the "status" command:map: mp_crossfire
    num score ping guid name lastmsg address qport rate
    2 1 84 b5e9d93e88670c6f811a033a7f925117 Davis^7 0 84.185.183.210:-1482 21249 25000
    4 15 100 e0d7c91fa7ba9549444ccab3a0e3de62 =HPX= Anogianos^7 0 91.140.25.93:28960 -10752 25000
    5 5 68 5d68298d9e16d7491d5700e6e236214f AsChIkUtAbU^7 50 84.60.215.190:17502 26401 25000
    6 115 44 cc503f50d990e27eeb990826c2cf1193 Donnergroll^7 50 91.64.153.240:28960 10086 25000
    7 141 79 cbd095d37abdc728671e2923296aa9cf souL^7 50 87.78.179.242:-10509 8432 25000
    8 116 83 4d0d1a067179516e209ef89cb0a79755 suodeth^7 0 84.250.214.156:27185 -29970 25000
    9 11 117 fc3c6777b3d9bf99df1e55b321b75e9e shpalman^7 50 62.101.126.209:-17420 -25455 25000
    10 5 82 fb2f20a9f46a212b896baf9ab4ea3eb0 =HPX=Gringo^7 50 213.5.170.94:-619 20175 25000
    11 95 68 d3d542b17ab56d9fbf107da39f245269 aga^7 50 78.2.42.253:28960 22173 25000
    12 10 100 8e6d08aec08591fb319081d0b40dedd2 madmax^7 0 79.166.47.145:2960 -7933 25000
    13 110 77 4fc4d0e24faa634dbce5c4bb4131bc4a Thunderstorm^7 50 87.78.113.218:28960 4512 25000
    14 55 67 f789227fcb95853b857115e68741df8d Robbino^7 0 89.217.12.113:28960 -192 25000
    15 118 85 b7be8ce58324d0f25c45f5cb372b30a1 Paranoid^7 50 78.1.26.32:28960 27294 25000
    16 11 90 38b59f3bbd3aa0ce3c95fccb26858931 $Hockz^7 50 87.181.101.96:-2984 24219 25000
    19 16 45 720f2abf81189890851d3e41fcbe4e21 ERASER^7 50 83.236.63.150:-32135 24704 25000
    20 145 37 a78f43bc3d3705743a190de45d37fc6a KintaKunte^7 50 88.68.237.239:28960 23539 25000
    21 60 49 a96d6a55049d11c5d7cd1c35c4d497c3 #sD|-HaZarD-^7 50 87.78.179.242:-10509 8432 25000
    8 116 83 4d0d1a067179516e209ef89cb0a79755 suodeth^7 0 84.250.214.156:27185 -29970 25000
    9 11 117 fc3c6777b3d9bf99df1e55b321b75e9e shpalman^7 50 62.101.126.209:-17420 -25455 25000
    10 5 82 fb2f20a9f46a212b896baf9ab4ea3eb0 =HPX=Gringo^7 50 213.5.170.94:-619 20175 25000
    11 95 68 d3d542b17ab56d9fbf107da39f245269 aga^7 50 78.2.42.253:28960 22173 25000
    12 10 100 8e6d08aec08591fb319081d0b40dedd2 madmax^7 0 79.166.47.145:2 0 91.3.110.248:-1185 6274 25000
    23 116 109 bfffdf9ff93425d284796532ef214bd0 ze_meedles^7 50 85.243.221.116:28960 24936 25000
    95853b857115e68741df8d Robbino^7 0 89.217.12.113:28960 -192 25000
    15 118 85 b7be8ce58324d0f25c45f5cb372b30a1 Paranoid^7 50 78.1.26.32:28960 27294 25000
    16 11 90 38b59f3bbd3aa0ce3c95fccb26858931 $Hockz^7 50 87.181.101.96:-2984 24219 25000
    19 16 45 720f2abf81189890851d3e41fcbe4e21 ERASER^7 50 83.236.63.150:-32135 24704 25000
    20 145 37 a78f43bc3d3705743a190de45d37fc6a KintaKunte^7 50 88.68.237.239:28960 23539 25000
    21 60 49 a96d6a55049d11c5d7cd1c35c4d497c3 #sD|-HaZarD-^7 50 87.78.179.242:-10509 8432 25000
    8 116 83 4d0d1a067179516e209ef89cb0a79755 suodeth^7 0 84.250.214.156:27185 -29970 25000
    9 11 117 fc3c6777b3d9bf99df1e55b321b75e9e shpalman^7 50 62.101.126.209:-17420 -25455 25000
    10 5 82 fb2f20a9f46a212b896baf9ab4ea3eb0 =HPX=Gringo^7 50 213.5.170.94:-619 20175 25000
    11 95 68 d3d542b17ab56d9fbf107da39f245269 aga^7 50 78.2.42.253:28960 22173 25000
    12 10 100 8e6d08aec08591fb319081d0b40dedd2 madmax^7 0 79.166.47.145:2As you can see the problem is that the server sends some information twice *but* it splits them with a blank line. In addition some nicknames contain spaces something that makes me wonder how I can set the nicknames to belong to the same position of the array. Something that i know is that all nicknames end with "^7" which is the in-game colour definition. Any help would be much appreciated. Thanks in advance.
    Edited by: m33ts4k0z on Dec 21, 2007 11:36 AM
    Edited by: m33ts4k0z on Dec 21, 2007 11:43 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    m33ts4k0z wrote:
    Hello DeltaGeek and thanks for your answer.
    I have 2 questions for you since you mentioned what the real problem is. The first question is how can I join 2 cells that will contain the 2 parts of the nickname in case of a space? Can I just check if the cell number x,y contains "^7" and then just copy that cell the x,y-1? Ive tried that but then I also have to move the rest of the columns to y-1 as well. Any idea how to do that?
    I was assuming you'd be processing the split string anyways, and not just tossing it into your 2-d structure. If you want to use .split(), yes. you would need to merge those cells into the original name. System.arrayCopy() would likely be useful for doing most of the heavy lifting.
    Another option you have is to tokenize the string using Scanner. That would let you pull each column out of the string individually. You'll need to populate the array manually (instead of just using what .split() gives you), but allows you to change the token delimiter between pulls.
    As for the junk lines, I can just check if they don't much the tokens number and then just not add them to the array I suppose, am I right or....?That's certainly one option. I don't know what's being given back to you, it may be important.

  • Reading a String with Scanner and ignoring whitespace

    Hi,
    This has probably been asked a million times, and I've searched Google and these forums, but I haven't found an answer that works for me.
    I have some class that needs to read user input from the command line, so I figured I'd use Scanner, since I've seen it used umpteen-hundred times in all the "do my homework" threads. I want to print out some line to the terminal, which will prompt the user to enter something. The user should then enter something and hit enter, and the Scanner should store the input in a variable of sorts.
    I've tried using Scanner.nextLine(), but that does not block for user input and the program terminates. I've tried Scanner.next() which does block for user input and allows the user to input something, but I cannot find a way to read the entire String; it will stop reading when it reaches whitespace. I've tried using a delimiter, but that seems to terminate the program when I prompt for the input, similar to Scanner.nextLine().
    Here's what I have at the moment:
    Scanner scanner = new Scanner(System.in); //I have also tried useDelimiter("\\s")
    System.out.print("Enter the desired command: ");
    String name = scanner.next();
    System.out.println("Command entered: " + name);The above code will work if the command is only one word, e.g. "connect". If the command is more than one word, it will only store the first word in the name variable. Again, I've tried using a delimiter for whitespace, but that hasn't worked.
    Is there a way to solve this problem? Perhaps I need to use another tool to read user input from the terminal? Am I just missing something? Do I need to explain more?
    Any advice is appreciated.
    Thanks

    I don't know why scanner.nextLine() doesn't work for you, it does for me with the following (copied) code:
    import java.util.Scanner;
    class Z
        public static void main(String[] args)
            Scanner scanner = new Scanner(System.in); //I have also tried useDelimiter("\\s")
            System.out.print("Enter the desired command: ");
            String name = scanner.nextLine();
            System.out.println("Command entered: " + name);
        }

  • Reading a string containing special character from a result set

    My Code....
    PrintStream p = new PrintStream(fout);
    if (connection == null)
    connection = getConnection();
    CallableStatement proc = connection.prepareCall("{call testing_read()}");
    rs = proc.executeQuery();
    while ( rs.next() )
    String page2 = rs.getString(1);
    System.out.println(page2);
    rs.getString(1); is a string value eg. 'Rebekah \n Govender' that is being set in a stored procedure.
    The output of my program is :'Rebekah \n Govender' , i need for it to read the special characters, and produce this output :
    Rebekah
    Govender
    Without using a result set , it works fine.
    eg.
    String page2 = 'Rebekah \n Govender'
    System.out.println(page2);
    Will give an output of :
    Rebekah
    Govender
    I need to read values from the results set, pls help me someone....
    Please help....

    String page2 = rs.getString(1).replace("\\n", "\n"); When you include source code in your posts, please enclose it in CODE tags. There's a button for that above the input textarea.
    ThE-MaRaC wrote:
    Hi,
    you can try something like this:
    import java.io.UnsupportedEncodingException;;
    *  Main class, manages the complete game
    public class Main {
    public static void main(String[] args) {
    String page2 = "Rebekah \n Govender";
    try {
    page2 = new String(page2.getBytes("ISO-8859-1"), "ETF-8");
    } catch (UnsupportedEncodingException e) {}
    System.out.println(page2);
    }Regards,
    Hercog MarioThat is a disgusting hack which you shouldn't be recommending to anyone, and it's totally irrelevant here anyway. Also, as written, it does absolutely nothing because you misspelled "UTF-8" and you swallowed the exception that would have told you so.

  • Need to read data from a jsp and insert in other jsp

    Hi,
    I have a jsp where i need to read from another jsp(which has data " header ---insert -----footer") and find a string "insert" in it and replace that string with a some value in the current jsp.
    Thanx in Advance.
    Sridhar.

    I have a jsp
    which needs to take headers and footers dynamically and insert them into my jsp.
    currently what i am doing is, using a script to get these header and footer and using document.write
    MYJSP.jsp looks this way
    <script src="/../Headerfooter.jsp"/>
    <script language="javascript">
    document.write(header); -->defined in -> /HeaderFooter.jsp
    document.write("<table>...</table>");
    document.write(footer);-->defined in -> /HeaderFooter.jsp
    </script>
    /HeaderFooter.jsp looks this way
    header = "<html>...<table width=\"100\">....";
    footer ="....</html">
    i dont want to use script bcoz i am getting problems in nestcape...

  • How can i read a string with nextToken() of StreamTokenizer

    I need for my class paper to read a string from a file and i used the StreamTokenizer's method nextToken but i can not read a string with it. my code is:
    StreamTokenizer st = new StreamTokenizer(the code that gets the input from the file)
    String line;
    while ((line !=br.readLine()) != null) {
    String surname = (st.nextToken()).trim();
    but it gets me some error of:
    int can not be dereferenced
    what should I do to get the string i need?

    Look at the API for java.io.StreamTokenizer. In particular, look at the return type for nextToken().
    Good luck.

  • Need to read Hex data format for Handheld device. (SAP AII RFID )

    Hello,
    we developed a custom screens for packing, unpacking, tag commission.. etc for handheld device for my client. the Serial number field  type is /ain/barcode. Its working fine. but for the new system need to read the Hex format. I created a new field in the screen. but the handheld device is not reading the Serial number in Hex format.
    Could anyone suggest me how to read Hex data in Handheld devices. We are using Motorola MC9090 Series.
    Regards,
    Kamal

    Hi
    Are you using the reader to read an RFID tag or for reading barcodes.
    Ideally, if you read an EPC Gen2 RFID tag, for example, the 96 bit encoded EPC is read and that can be converted to its equivalent  HEX format for posting the observation to SAP AII.
    In case of barcodes, the string is read as is printed on the barcode.

  • Java.io.Reader to String conversion

    I am working on a SOAP project with Jaxm and I retreive the result as a Reader, but I need to convert it into a String.
    I did the following code but it is incredibely slow with a big reply (280kb) as I retrieve each character one after each other.
    Does a faster solution exist ?
    // Soap call
    SOAPMessage reply = m_conn.call(message, endpoint);
    java.util.Iterator it = reply.getAttachments();
    // First attachment returned by the server hold my result
    AttachmentPart resultAttachment = (AttachmentPart) it.next();
    StreamSource resultStreamSource = (StreamSource) resultAttachment.getContent();
    // Converts java.io.Reader to String
    java.io.Reader resultReader = resultStreamSource.getReader();
    String result = "";
    int charValue = 0;
    while ((charValue = resultReader.read()) != -1) {
       result = result + (char) charValue;

    use a BufferedReader and create a large char[] (64k or something)
    then use
    char[] cbuf = new char[65536];
    StringBuffer stringbuf = new StringBuffer();
    int read_this_time = 0;
    while (read_this_time != -1) {
    read_this_time = BufferedReader.read(cbuf,0,65536);
    stringbuf.append(cbuf,0,read_this_time);
    }//end while
    StringBuffer is faster than String concatenation because when java concatenates strings it creates a new object every time. StringBuffer just stores and appends the string without creating new objects.

  • How to read a string character by character and pass it into an array

    Hi,
    I have a requirement to write a function.The thing is,i need to read string,replace space with a NULL,return in the form of an arrayy.
    for this what i thought is,if the character is not a space,i need to put that into array,if its space,put a NULL for that.
    the string is of type varchar2.
    ex:XX XX XX
    i need some suggestions for this.
    thanks

    Well, you can just use a loop that runs for the length of the string.
    Then for each iteration of the loop, take the next character of the string (substr or similar) and add it to the array. If it's a space, then add a NULL to the array (if that's what you want).
    Easy :)

  • Need help in handling string of characters

    Hi,
    I am trying to scan string and separate different text based on business logic. For example:
    String = 'My bus comes at 999 F Street at 8 am'
    Now I need to scan the string and break the sentence into multiple words like:
    - First occurrence of number which is 999 goes into var1 variable.
    - Last occurrence of number which is 8 goes into var2 variable.
    I am wondering if this can be achieve with regular expression of any oracle internal function.
    Thanks,
    Edited by: skas on Jun 6, 2013 10:34 PM

    nkvkashyap wrote:
    or you can even try like this...
    with data(str) as
    (select 'My bus comes at 999 F Street at 8 am' from dual),
    data1 as
    (select regexp_replace(str, '[^[:digit:]]+', ' ') a from data)
    select regexp_substr(a,'[^ ]+',1,1) var1,regexp_substr(a,'[^ ]+',1,2) var2 from data1;
    Output:
    var1         var2
    999     8
    No need to make this complicated ;)
    SQL> with data(str) as
      2  (
      3   select 'My bus comes at 999 F Street at 8 am'
      4   from dual
      5  )
      6  select     regexp_sUBsTR(str, '\d+') VAR1,
      7     regexp_sUBSTR(str, '\d+',1,2) VAR2
      8  from data;
    VAR V
    999 8Edited by: jeneesh on Jun 7, 2013 11:11 AM
    Missed David's post.. This is the same as his post..

  • PL/SQL function to read a string of characters into an array

    I was wondering if there is an easier way than using the substr function multiple times. Here is the example:
    Suppose you have a varchar2 variable that contains the word 'Apple'. The function should take it and produce an array. We would invoke it like this:
    <what data structure?> a := stringunpackerfunction(x);
    // x is the varchar2 containing 'Apple'.
    The resulting a would be such that a[0] is 'A', a[1] is 'p', a[2] is 'p', a[3] is 'l' and a[4] is 'e'.
    If there is no direct function to do this in a single invocation, is there a function to simply read a string of characters and return 'the next character'?
    Thanks,
    Regards,
    Srini

    There is a procedure out there called PS_PARSE which takes a string and converts to an array provided with an identified separator. Works for us pretty well.
    I just grabbed this off of google. I am presuming this should work fine. It has been sometime since we implemented ours that I forget if there were any additional modifications that we made. I think there was one regarding the size of the string that could be handled. I forget precisely. Anyways... take a peek at it. Its makes things easy in that your logic is pretty streamlined.
    Barry C
    http://www.myoracleportal.com
    create or replace PACKAGE PS_Parse
    IS
         || PL/SQL table structures to hold atomics retrieved by parse_string.
         || This includes the table type definition, a table (though you can
         || declare your own as well, and an empty table, which you can use
         || to clear out your table which contains atomics.
         TYPE atoms_tabtype IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;
         atoms_table atoms_tabtype;
         empty_atoms_table atoms_tabtype;
         || The standard list of delimiters. You can over-ride these with
         || your own list when you call the procedures and functions below.
         || This list is a pretty standard set of delimiters, though.
         std_delimiters VARCHAR2 (50) := ' !@#$%^&*()-_=+\|`~{{]};:''",<.>/?';
         /* Display contents of table using DBMS_OUTPUT */
         PROCEDURE display_atomics
              (table_in IN atoms_tabtype, num_rows_in IN NUMBER);
         || The parse_string procedure: I provide two, overloaded definitions.
         || The first version puts all atomics into a PL/SQL table and would
         || be used in a PL/SQL Version 2 environment. The second version places
         || all atomics into a string, separating each atomic by a vertical bar.
         || (My code does NOT do any special handling when it finds a "|" in
         || the string. You have to deal with that when you extract the atomics.
         ||
         || See the program definition for more details on other parameters.
         PROCEDURE parse_string
              (string_in IN VARCHAR2,
              atomics_list_out OUT atoms_tabtype,
              num_atomics_out IN OUT NUMBER,
              delimiters_in IN VARCHAR2 := std_delimiters);
         PROCEDURE parse_string
              (string_in IN VARCHAR2,
              atomics_list_out IN OUT VARCHAR2,
              num_atomics_out IN OUT NUMBER,
              delimiters_in IN VARCHAR2 := std_delimiters);
         /* Count the number of atomics in a string */
         FUNCTION number_of_atomics
              (string_in IN VARCHAR2,
              count_type_in IN VARCHAR2 := 'ALL',
              delimiters_in IN VARCHAR2 := std_delimiters)
         RETURN INTEGER;
         /* Return the Nth atomic in the string */
         FUNCTION nth_atomic
              (string_in IN VARCHAR2,
              nth_in IN NUMBER,
              count_type_in IN VARCHAR2 := 'ALL',
              delimiters_in IN VARCHAR2 := std_delimiters)
         RETURN VARCHAR2;
    END PS_Parse;
    create or replace PACKAGE BODY PS_Parse
    IS
    /* Package variables used repeatedly throughout the body. */
    len_string     NUMBER;
    start_loc     NUMBER;
    next_loc     NUMBER;     
    || Since the PUT_LINE procedure regards a string of one or more
    || spaces as NULL, it will not display a space, which is in
    || PS_Parse a valid atomic. So I save a_blank in the PL/SQL
    || table instead of the space itself.
    a_blank CONSTANT VARCHAR2(3) := '" "';
    /*--------------------- Private Modules ---------------------------
    || The following functions are available only to other modules in
    || package. No user of PS_Parse can see or use these functions.
    FUNCTION a_delimiter
    (character_in IN VARCHAR2,
    delimiters_in IN VARCHAR2 := std_delimiters)
    RETURN BOOLEAN
    || Returns TRUE if the character passsed into the function is found
    || in the list of delimiters.
    IS
    BEGIN
    RETURN INSTR (delimiters_in, character_in) > 0;
    END;
    FUNCTION string_length (string_in IN VARCHAR2)
    RETURN INTEGER
    IS
    BEGIN
    RETURN LENGTH (LTRIM (RTRIM (string_in)));
    END;
    FUNCTION next_atom_loc
    (string_in IN VARCHAR2,
    start_loc_in IN NUMBER,
    scan_increment_in IN NUMBER := +1)      
    || The next_atom_loc function returns the location
    || in the string of the starting point of the next atomic (from the
    || start location). The function scans forward if scan_increment_in is
    || +1, otherwise it scans backwards through the string. Here is the
    || logic to determine when the next atomic starts:
    ||
    ||          1. If current atomic is a delimiter (if, that is, the character
    ||               at the start_loc_in of the string is a delimiter), then the
    ||               the next character starts the next atomic since all
    ||               delimiters are a single character in length.
    ||
    ||          2. If current atomic is a word (if, that is, the character
    ||               at the start_loc_in of the string is a delimiter), then the
    ||               next atomic starts at the next delimiter. Any letters or
    ||               numbers in between are part of the current atomic.
    ||
    || So I loop through the string a character at a time and apply these
    || tests. I also have to check for end of string. If I scan forward
    || the end of string comes when the SUBSTR which pulls out the next
    || character returns NULL. If I scan backward, then the end of the
    || string comes when the location is less than 0.
    RETURN NUMBER
    IS
    /* Boolean variable which uses private function to determine
    || if the current character is a delimiter or not.
    was_a_delimiter BOOLEAN :=
    PS_Parse.a_delimiter (SUBSTR (string_in, start_loc_in, 1));     
    /* If not a delimiter, then it was a word. */
    was_a_word BOOLEAN := NOT was_a_delimiter;
    /* The next character scanned in the string */
              next_char VARCHAR2(1);
    || The value returned by the function. This location is the start
    || of the next atomic found. Initialize it to next character,
    || forward or backward depending on increment.
    return_value NUMBER := start_loc_in + scan_increment_in;
    BEGIN
    LOOP
    -- Extract the next character.
    next_char := SUBSTR (string_in, return_value, 1);
    -- Exit the loop if:
    EXIT WHEN
    /* On a delimiter, since that is always an atomic */
    a_delimiter (next_char)
    OR
    /* Was a delimiter, but am now in a word. */
    (was_a_delimiter AND NOT a_delimiter (next_char))
    OR
    /* Reached end of string scanning forward. */
    next_char IS NULL
    OR
    /* Reached beginning of string scanning backward. */
    return_value < 0;
    /* Shift return_value to move the next character. */
    return_value := return_value + scan_increment_in;
    END LOOP;
    -- If the return_value is negative, return 0, else the return_value
    RETURN GREATEST (return_value, 0);
    END;
    PROCEDURE increment_counter
    (counter_inout IN OUT NUMBER,
    count_type_in IN VARCHAR2,
    atomic_in IN CHAR)
    || The increment_counter procedure is used by nth_atomic and
    || number_of_atomics to add to the count of of atomics. Since you
    || can request a count by ALL atomics, just the WORD atomics or
    || just the DELIMITER atomics. I use the a_delimiter function to
    || decide whether I should add to the counter. This is not a terribly
    || complex procedure. I bury this logic into a separate module,
    however,
    || to make it easier to read and debug the main body of the programs.
    IS
    BEGIN
    IF count_type_in = 'ALL' OR
    (count_type_in = 'WORD' AND NOT a_delimiter (atomic_in)) OR
    (count_type_in = 'DELIMITER' AND a_delimiter (atomic_in))
    THEN
    counter_inout := counter_inout + 1;
    END IF;
    END increment_counter;
    /* ------------------------- Public Modules -----------------------*/
    PROCEDURE display_atomics
    (table_in IN atoms_tabtype, num_rows_in IN NUMBER)
    || Program to dump out contents of table. Notice I must also pass in
    || the number of rows in the table so that I know when to stop the
    || loop. Otherwise I will raise a NO_DATA_FOUND exception. For a more
    || elaborate display_table module, see Chapter 7 on PL/SQL tables.
    IS
    BEGIN
    FOR table_row IN 1 .. num_rows_in
    LOOP
    DBMS_OUTPUT.PUT_LINE (NVL (table_in (table_row), 'NULL'));
    END LOOP;
    END;
    PROCEDURE parse_string
    (string_in IN VARCHAR2,
    atomics_list_out OUT atoms_tabtype,
    num_atomics_out IN OUT NUMBER,
    delimiters_in IN VARCHAR2 := std_delimiters)
    || Version of parse_string which stores the list of atomics
    || in a PL/SQL table.
    ||
    || Parameters:
    ||          string_in - the string to be parsed.
    ||          atomics_list_out - the table of atomics.
    ||          num_atomics_out - the number of atomics found.
    ||          delimiters_in - the set of delimiters used in parse.
    IS
    BEGIN
    /* Initialize variables. */
    num_atomics_out := 0;
    len_string := string_length (string_in);
    IF len_string IS NOT NULL
    THEN
    || Only scan the string if made of something more than blanks.
    || Start at first non-blank character. Remember: INSTR returns 0
    || if a space is not found. Stop scanning if at end of string.
    start_loc := LEAST (1, INSTR (string_in, ' ') + 1);
    WHILE start_loc <= len_string
    LOOP
    || Find the starting point of the NEXT atomic. Go ahead and
    || increment counter for the number of atomics. Then have to
    || actually pull out the atomic. Two cases to consider:
    ||          1. Last atomic goes to end of string.
    ||          2. The atomic is a single blank. Use special constant.
    ||          3. Anything else.
    next_loc := next_atom_loc (string_in, start_loc);
    num_atomics_out := num_atomics_out + 1;
    IF next_loc > len_string
    THEN
    -- Atomic is all characters right to the end of the string.
    atomics_list_out (num_atomics_out) :=
    SUBSTR (string_in, start_loc);
    ELSE
    || Internal atomic. If RTRIMs to NULL, have a blank
    || Use special-case string to stuff a " " in the table.
    atomics_list_out (num_atomics_out) :=
    NVL (RTRIM (SUBSTR (string_in,
    start_loc, next_loc-start_loc)),
                                       a_blank);
    END IF;
    -- Move starting point of scan for next atomic.
    start_loc := next_loc;
    END LOOP;
    END IF;
    END parse_string;
    PROCEDURE parse_string
    (string_in IN VARCHAR2,
    atomics_list_out IN OUT VARCHAR2,
    num_atomics_out IN OUT NUMBER,
    delimiters_in IN VARCHAR2 := std_delimiters)
    || The version of parse_string which writes the atomics out to a packed
    || list in the format "|A|,|C|". I do not repeat any of the comments
    || from the first iteration of parse_string.
    IS
    BEGIN
    /* Initialize variables */
    num_atomics_out := 0;
    atomics_list_out := NULL;
    len_string := string_length (string_in);
    IF len_string IS NOT NULL
    THEN
    start_loc := LEAST (1, INSTR (string_in, ' ') + 1);
    WHILE start_loc <= len_string
    LOOP
    next_loc := next_atom_loc (string_in, start_loc);
    num_atomics_out := num_atomics_out + 1;
    IF next_loc > len_string
    THEN
    atomics_list_out := atomics_list_out || '|' ||      
    SUBSTR (string_in, start_loc);
    ELSE
    atomics_list_out :=
    atomics_list_out || '|' ||      
    NVL (RTRIM (SUBSTR (string_in,
    start_loc, next_loc-start_loc)),
                                       a_blank);
    END IF;
    start_loc := next_loc;
    END LOOP;
    /* Apply terminating delimiter to the string. */
    atomics_list_out := atomics_list_out || '|' ;
    END IF;
    END parse_string;
    FUNCTION number_of_atomics
    (string_in IN VARCHAR2,
    count_type_in IN VARCHAR2 := 'ALL',
    delimiters_in IN VARCHAR2 := std_delimiters)
    RETURN INTEGER
    || Counts the number of atomics in the string_in. You can specify the
    || type of count you want: ALL for all atomics, WORD to count only the
    || words and DELIMITER to count only the delimiters. You can optionally
    || pass your own set of delimiters into the function.
    IS
    return_value INTEGER := 0;
    BEGIN
    /* Initialize variables. */
    len_string := string_length (string_in);
    IF len_string IS NOT NULL
    THEN
    || This loop is much simpler than parse_string. Call the
    || next_atom_loc to move to the next atomic and increment the
    || counter if appropriate. Everything complicated is shifted into
    || sub-programs so that you can read the program "top-down",
    || understand it layer by layer.
    start_loc := LEAST (1, INSTR (string_in, ' ') + 1);
    WHILE start_loc <= len_string
    LOOP
    increment_counter (return_value, UPPER (count_type_in),
    SUBSTR (string_in, start_loc, 1));
    start_loc := next_atom_loc (string_in, start_loc);
    END LOOP;
    END IF;
    RETURN return_value;
    END number_of_atomics;
    FUNCTION nth_atomic
    (string_in IN VARCHAR2,
    nth_in IN NUMBER,
    count_type_in IN VARCHAR2 := 'ALL',
    delimiters_in IN VARCHAR2 := std_delimiters)
    RETURN VARCHAR2
    || Find and return the nth atomic in a string. If nth_in is greater
    || the number of atomics, then return NULL. If nth_in is negative the
    || function counts from the back of the string. You can again request
    || a retrieval by ALL atomics, just the WORDs or just the DELIMITER.
    || So you can ask for the third atomic, or the second word from the end
    || of the string. You can pass your own list of delimiters as well.
    IS
    /* Local copy of string. Supports up to 1000 characters. */
    local_string VARCHAR2 (1000) :=
    LTRIM (RTRIM (SUBSTR (string_in, 1, 1000)));
    /* Running count of atomics so far counted. */
    atomic_count NUMBER := 1;
    /* Boolean variable which controls the looping logic. */
    still_scanning BOOLEAN :=
    local_string IS NOT NULL AND nth_in != 0;
    /* The amount by which I increment the counter. */
    scan_increment INTEGER;
    /* Return value of function, maximum length of 100 characters. */
    return_value VARCHAR2 (100):= NULL;
    BEGIN
    IF nth_in = 0
    THEN
    /* Not much to do here. Find 0th atomic? */
    RETURN NULL;
    ELSE
    /* Initialize the loop variables. */
    len_string := string_length (local_string);
    IF nth_in > 0
    THEN
    /* Start at first non-blank character and scan forward. */
    next_loc := 1;
    scan_increment := 1;
    ELSE
    /* Start at last non-blank character and scan backward. */
    next_loc := len_string;
    scan_increment := -1;
    END IF;
    /* Loop through the string until the Boolean is FALSE. */
    WHILE still_scanning
    LOOP
    /* Move start of scan in string to loc of last atomic. */
    start_loc := next_loc;
    /* Find the starting point of the next atomic. */
    next_loc      :=
    next_atom_loc (local_string, start_loc, scan_increment);
    /* Increment the count of atomics. */
    increment_counter
    (atomic_count,
    UPPER (count_type_in),
    SUBSTR (local_string, start_loc, 1));
    || Keep scanning if my count hasn't exceeded the request
    || and I am neither at the beginning nor end of the string.
    still_scanning :=
    atomic_count <= ABS (nth_in) AND
    next_loc <= len_string AND
    next_loc >= 1;
    END LOOP;
    || Done with the loop. If my count has not exceeded the requested
    || amount, then there weren't enough atomics in the string to
    || satisfy the request.
    IF atomic_count <= ABS (nth_in)
    THEN
    RETURN NULL;
    ELSE
    || I need to extract the atomic from the string. If scanning
    || forward, then I start at start_loc and SUBSTR forward.
    || If I am scanning backwards, I start at next_loc+1 (next_loc
    || is the starting point of the NEXT atomic and I want the
    || current one) and SUBSTR forward (when scanning in
    || reverse, next_loc comes before start_loc in the string.
    IF scan_increment = +1
    THEN
    RETURN
    SUBSTR (local_string, start_loc, next_loc - start_loc);
    ELSE
    RETURN
    SUBSTR (local_string, next_loc+1, start_loc - next_loc);
    END IF;
    END IF;
    END IF;
    END nth_atomic;
    END PS_Parse;
    /

  • Function module needed to read all the BOM statuses

    Dear Friends,
    In a report we are using CS_BOM_EXPL_MAT_V2 function module to get the dispaly the BOMs. But it is displaying only the BOMs which are in Active stauts e.g 1 & 3.
    My requirement is needs to read both active and inactive BOMs. Inactive BOM status is 2.
    suggest me if there is any another FM or any another way to get all the BOM status materials.
    Thanks for your help.
    Srinivas.

    You need to supply another application for alternative determination (field CAPID). It should be possible to customize one for your needs using "Define Order of Priority for BOM Usages" and "Define Applications" under "Production->Basic Data->Bill of Material->Alternative Determination"
    Edited by: Carsten Grafflage on Aug 5, 2010 1:44 PM: Corrected one string from customizing - sorry.

  • Read 2 Strings from EXCEL with GOOP or ActiveX?

    Hello,
    i use Labview 5.1 with WIN NT4.0 SP6a and i programm a fuzzy Logic tool for a exam in Computer Science.
    Now i have a problem, and i read something about the GOOP and the EXCEL Toolkit. I download it and try more times to install but i can't link the *.llb in the Function Palette. Is this GOOP and Excel Toolkit only for Labview 6.x ?
    I solve it with ActiveX and Excel, but my very big Problem is, i need to read2 string from the Excel table from the same time, and with ActiveX i don't find any method how can i do that.
    I don't know how can i read 2 Strings from a Excel table, Can i do it with the Excel Toolkit,if yes how, maybe anyone make it or any helpfiles?
    Thanks for your answer in advance ,
    Ender
    Ekinci

    "fuzzylogic" wrote in message
    news:[email protected]..
    > Hello,
    > i use Labview 5.1 with WIN NT4.0 SP6a and i programm a fuzzy Logic
    > tool for a exam in Computer Science.
    > Now i have a problem, and i read something about the GOOP and the
    > EXCEL Toolkit. I download it and try more times to install but i can't
    > link the *.llb in the Function Palette. Is this GOOP and Excel Toolkit
    > only for Labview 6.x ?
    >
    > I solve it with ActiveX and Excel, but my very big Problem is, i need
    > to read2 string from the Excel table from the same time, and with
    > ActiveX i don't find any method how can i do that.
    >
    > I don't know how can i read 2 Strings from a Excel table, Can i do it
    > with the Excel Toolkit,if yes how, m
    aybe anyone make it or any
    > helpfiles?
    I'm pretty sure the excel toolkit is written for 5.1, and don't know why it
    would give you problems. Do you have excel installed? I'm not sure what
    you mean that you cant link the *.llb in function pallette. Have you tried
    opening the llb using '\functions\select a vi' ? As to how to read two
    cells at once, you could read a block of cells including both cells (ie:
    A5..D10) and then pull the data out of the array.

  • Need to read each sheet of an excel file and pass it to XI

    Hi
    Actually i need to read each sheet of an excel file and pass it to XI and will create one xml file .I am able to read the excel file by writting a custom module and it is generating the xml output from XI.But my requierment is to read the excel file and create the xml with the sheet name of the excel.suppose sheet name is sheet1, the xml file name will be  sheet1.xml.if sheet name is sheet2 the xml file name will be  sheet2 and so on....how can i pass this parameter from NWDS to SAP XI s i am passing the string which contains the sheet data.

    If I understood correct you are already reading the XLS and creating the XML (not sure if this is a separate executing body out side of XI). Are you using any sort of Object Modal in Java to read the XML? I am aware of Visual Basic object modal for Excel but not sure if one is available in Java from Microsoft.
    The Object modal that you are using must be providing an iterator to loop through each of the sheet in the Excel workbook and you should be able to create the XMLs as you desired.
    I would be glad to look at you module if you are doing it once the XI file adapter has picked up the excel file.
    VJ

Maybe you are looking for