Splitting string with changing length length

Hi,
I am trying to read the position of an automatic stage in X,Y,Z axes. The stage returns a string of the three axes, and I would like to get the position of each axis separately. The thing is that the length of the string changes as the stage moves, so I cannot simply split at a predetermined offset.
Any help will be appreciated,
Gaby 
Solved!
Go to Solution.

There is an easier way.  Use the Spreadsheet String to Array primitive to do it in one node.  No loops required.  This primitive (and its inverse) is useful any time you have a token separated string to parse in a regular fashion.
Message Edited by DFGray on 11-25-2008 07:41 AM
This account is no longer active. Contact ShadesOfGray for current posts and information.
Attachments:
SpaceSeparatedNumbersToArray.png ‏1 KB
SpaceSeparatedNumbersToArray.vi ‏9 KB

Similar Messages

  • How to get a string with fixed length

    I want to implement something like movechar() of c in java. I want to return a string which has a fixed length that contains the given string and spaces for remaining length.
    Please let me know how can I implement it.
    Thanks & Regards,
    Nasrin.n

    Do you mean padding a String?
          * This method pads the string s to size n using char c to make up for missing characters.
         public static String padString(String s, int n, char c, boolean paddingLeft) {
              StringBuffer str = new StringBuffer(s);
              int strLength = str.length();
              if (n > 0 && n > strLength) {
                   for (int i = 0; i <= n; i++) {
                        if (paddingLeft) {
                             if (i < n - strLength) str.insert(0, c);
                        else {
                             if (i > strLength) str.append(c);
              return str.toString();
         }

  • [SQL 2012] split string with forbidden characters

    Hi all,
    I have an issue with a query
    I would like to find an equivalent of pivot function, but with a column that contains forbidden characters (like []&) and using delimiter (,), and when number of value on column could be different :
    colA              colB                   colC
    toto              titi                     [valeur].[membre].&[test1],[valeur].[membre].&[test2],[valeur].[membre].&[test3]
    tata              tutu                   [valeur].[membre].&[test4],[valeur].[membre].&[test5]
    fifi                fafa                    [valeur].[membre].&[test6]
    fofo              fufu                    [valeur].[membre].&[test7],[valeur].[membre].&[test7],[valeur].[membre].&[test9]
    what should give :
    colA              colB                   colC
    toto              titi                     [valeur].[membre].&[test1]
    toto              titi                     [valeur].[membre].&[test2]
    toto              titi                     [valeur].[membre].&[test3]
    tata              tutu                   [valeur].[membre].&[test4]
    tata              tutu                   [valeur].[membre].&[test5]
    fifi                fafa                    [valeur].[membre].&[test6]
    fofo              fufu                    [valeur].[membre].&[test7]
    fofo              fufu                    [valeur].[membre].&[test8]
    fofo              fufu                    [valeur].[membre].&[test9]
    I try with splitstring function, xml path, but nothing works.
    Thanks in advance.
    Xavier

    Xavier,
    check if this helps:
    simple usage of a split function which can then be cross applied with the table.
    --CREATE FUNCTION dbo.fn_sample_Split
    -- @RowData nvarchar(2000),
    -- @SplitOn nvarchar(5)
    --RETURNS @RtnValue table
    -- Id int identity(1,1),
    -- Data nvarchar(100)
    --AS
    --BEGIN
    -- Declare @Cnt int
    -- Set @Cnt = 1
    -- While (Charindex(@SplitOn,@RowData)>0)
    -- Begin
    -- Insert Into @RtnValue (data)
    -- Select
    -- Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))
    -- Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))
    -- Set @Cnt = @Cnt + 1
    -- End
    -- Insert Into @RtnValue (data)
    -- Select Data = ltrim(rtrim(@RowData))
    -- Return
    --END
    declare @tab table (cola varchar(20),colb varchar(20),colc varchar(100))
    INSERT @tab SELECT 'toto','titi','[valeur].[membre].&[test1],[valeur].[membre].&[test2],[valeur].[membre].&[test3]'
    INSERT @tab SELECT 'tata','tutu','[valeur].[membre].&[test4],[valeur].[membre].&[test5]'
    INSERT @tab SELECT 'fifi','fafa','[valeur].[membre].&[test6]'
    INSERT @tab SELECT 'fofo','fufu','[valeur].[membre].&[test7],[valeur].[membre].&[test7],[valeur].[membre].&[test9]'
    select t.cola,t.colb,fn.data
    From @tab t
    cross apply dbo.fn_sample_split(t.colc,',') fn
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • String with length 1 became 4 when nls_lang_semantics=CHAR

    Hi,
    We are using Oracle 9.2.0.1 database with charset = UTF-8, and we have set nls_lang_semantics=CHAR.
    We got a problem in our java program is that for a column with char(1), after I insert a java constant 'Y', the result I get back from select is a string of 'Y ', i.e. the string returned is not a string with length=1, but with length=4!! How can I correct the problem to get a string with length=1?
    Regards,
    Roy

    Hi,
    Thanks for the responses but I don't think you're quite right. Forms 6i should indeed work with Unicode as a database character set as long as it is UTF8 rather than AL32UTF8. This can be seen in various Metalink documents and also in the Release 6i Guidelines for Building Applications here (section 4.1.5):
    http://download-west.oracle.com/otn_hosted_doc/forms/forms/A73073_01.pdf
    The problems started when I changed NLS_LENGTH_SEMANTICS to CHAR. Its understandable if Forms 6i does not recognise this setting as it pre-dates it but I wanted to confirm this.
    We want to migrate our existing application to work with multibyte characters. Unfortunately there are table columns, PL/SQL variables etc. that are too small when defined as a length in bytes.
    I am looking for the least impact method to rectify this. On the server I can use NLS_LENGTH_SEMANTICS but if I can't get Forms to work with it then I may need to rethink.
    I realise that using Forms 9i or 10g would support the parameter but it is not possible to upgrade at the moment.
    Has anyone any other suggestions or methods for migrating an application to using multibyte characters?
    Thanks again,
    Kevin.

  • What does this error means? "Line 20 column 57: character content of element "language" invalid; must be a string with length equal to 3 (actual length was 7) at XPath /package/book/metadata/languages/language" "

    Hi there.
    I am about to publish a book in English and Chinese.
    What does this error means?
    Line 20 column 57: character content of element "language" invalid; must be a string with length equal to 3 (actual length was 7) at XPath /package/book/metadata/languages/language"
    And where is line 20, column 57?
    Thanks folks!

    Go into iTunes Producer and select from the dropdown, don't type.
    cs
    iBooks Author Guide

  • Split string into two based on end of word and max length

    I have the following procedure, which is passed a comma separated string as it input, and it has to split it into two, and the split has to occur at the end of a word, and the first split part can't be more than 15 in length.
    Is there an more efficient way of achieving this? I have a loop in my main code that calls this procedure and in effect a nested loop has been created here.
    e.g. Hello, everyone, welcome, to, split, string' would be split into 'Hello' and 'everyone, welcome, to, split, string'
    create or replace procedure split_str
                   (pi_str  in  varchar2,
                    po_str1 out nocopy varchar2,
                    po_str2 out nocopy varchar2) is
      i number;
    begin
      if (len(pi_str) <= 15) then
        po_str1 := pi_str;
        po_str2 := NULL;
      else
        i := 1;
        loop
          exit when len(SUBSTR(pi_str, 1 ,INSTR(pi_str, ',', 1, i)-1)) > 15;
          po_str1 := SUBSTR(pi_str, 1 ,INSTR(pi_str, ',', 1, i)-1);
          po_str2 := SUBSTR(pi_str, INSTR(pi_str, ',', 1, i)+2);
          i := i+1;
        end loop;
      end if;
    end split_str; 

    You want to find the last space character before the 15th character.
    x := INSTR ( SUBSTR ( pi_str, 1, 15) , ' ' , -1)Then the first string is SUBSTR(pi_str,1,x) and the second string is SUBSTR(pi_str,x+1)

  • Length of a String with new line

    Hello
    I have a Form that allows user to fill in. In that form, I have an address field (textarea).
    Now I want to know the length of this address. I uses
    String size = addressField.length();
    The size is correct if I have only one line in the address. But if I enter an adress with multi-line, the size is much more than what I count (by hand) even I add one value for each line.
    For example, if address "Wellington" has one line as:
    Wellington
    It can be seen that the size is: 10
    But if I enter this in multi lines:
    W
    e
    ll
    ing
    ton
    It can be seen that, by counting, the size is 14 (10+4=14)
    However, I get the value of addressField.length() is 18
    How I should get value for only 14
    Many thanks
    shoa

    You realize, of course, that you cannot use Javascript to execute Java code like that, right? Java runs on the server, Javascript runs in the browser, and there is no connection whatsoever between the 2. At best, you can use Java to write Javascript code into a page. But calling count() in Javascript will not execute that Java/JSTL code.

  • How to split a string with a delimiting regular expression like "\r"

    Hello!I am a fresh in java programming.Please don't deride my question.What I want to realize is to get the current caret lines and cols in a JTextPane. My question is :After I fetch the string content of the JTextPane and try to split it with the end-line token like "\r" or "\r\n",it always comes me an wrong position.
    here is my code:
    public void caretUpdate(CaretEvent e) {
    int ln,col;
    JTextPane textSource = (JTextPane)e.getSource();
    String sourceString = textSource.getText();
    String subString = sourceString.substring(0,
         (e.getDot() == 0) ? 0 : e.getDot()-1);
    String[] splitString = subString.split("\r",-1);
    ln = splitString.length;
    col = e.getDot() - subString.lastIndexOf("\r");
    setCaretPosition(ln,col); //display ln and col in a label
    I have got puzzled>_<.Please help me.Any help would be appreciated . (^-^)

    Swing text components always use "\n" to separate lines, not "\r" or "\r\n". When you read text in from a file or paste from the clipboard, the line separators are converted to "\n" if necessary. They save the info about what line separators were used in the source file, so if you write the text back to a file it converts them back.

  • How to split a string with regular expression

    Hi.
    I need to split a string with a regular expression.
    Example
    String = "this is; a test";rune haavik;12345;
    And I want the output to be:
    "this is; a test"
    rune haavik
    12345
    If I use this code:
    private void test1()
    String str = "\"this is; a test\";rune haavik;12345;";
    int i=0;
    String[] tmp = str.split(";");
    while(i<tmp.length)
    System.out.println(tmp);
    i++;
    Then it splits also in the "" text.
    Regards
    Rune haavik

    Rune haavik:
    The most effective way to achieve the end result is, I believe, to read the characters one by one, using a flag that indicates if we are inside quotation or not.
    Well, if we are in a mind game, then the following should do.
           String[] tmp = str.split(";(?![^\"]*\";)");

  • Send a flat file with fixed lengths to XI 3.0 using a Central File Adapter?

    Hello,
    I'm wondering if someone have experience setting up conversion for different record structures. The example shown,
    /people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter,
    (in a greate way) only picture one kind of structure.
    How should it be done if the file would contain
    10Mat1
    20100PCS
    The first record structure has columns
    ID(2),Material(10)
    The second redcord structure has columns
    ID(2),Quantity(3), Unit of messure (3)
    Brgds
    Kalle
    Message was edited by: Karl Bergstrom

    The configuration would be like follows:
    Content Conversion Parameters:
    Document Name: <your message type name>
    Document Namespace: <your message type namespace>
    Document Offset: <leave empty>
    Recordset Name: <any name>
    Recordset Namespace: <leave empty>
    Recordset Structure: row1,,row2,
    Recordset Sequence: any
    Recordsets per Message: *
    Key Field Name: ID
    Key Field Type: String
    Parameters for Recordset Structures:
    row1.fieldNames           ID,Material
    row1.fieldFixedLengths    2,10
    row1.keyFieldValue        10
    row2.fieldNames           ID,Quantity,UOM
    row2.fieldFixedLengths    2,3,3
    row2.keyFieldValue        20
    Instead of row1 and row2 you can choose any name.
    Regards
    Stefan

  • Error: "Invalid string or buffer length" when using SQLColumns!

    I am calling SQLColumns through the Oracle ODBC driver to get the column information of a table. The Client version is 9.0.1.0 and the ODBC driver version is 9.0.1.8. If I am querying a table that does not has a long table name, fine; if I am querying a long table name, failed and reporting:
    [Oracle][ODBC]Invalid string or buffer length.
    Tried with MS Oracle driver, no problem. Anybody can help?
    Thanks in advance.

    the name is very long, like 'aaaabbbbccccddddeeeeffffrrrrdddaaa'. Maybe more than 20 charactors. I haven't find the exact number, before which SQLcolumns works, after which SQLColumns stop working.

  • Querying CHAR columns with character length semantics unreliable

    Hi again,
    It appears that there is a bug in the JDBC drivers whereby it is highly unlikely that the values of CHAR columns that use character length semantics can be accurately queried using ResultSet.getString(). Instead, the drivers return the value padded with space (0x#20) characters out to a number of bytes equal to the number of characters multiplied by 4. The number of bytes varies depending on the number and size of any non-ascii characters stored in the column.
    For instance, if I have a CHAR(1) column, a value of 'a' will return 'a ' (4 characters/bytes are returned), a value of '\u00E0' will return '\u00E0 ' (3 characters / 4 bytes), and a value of '\uE000' will return '\uE000 ' (2 characters / 4 bytes).
    I'm currently using version 9.2.0.3 of the standalone drivers (ojdbc.jar) with JDK 1.4.1_04 on Redhat Linux 9, connecting to Oracle 9.2.0.2.0 running on Solaris.
    The following sample code can be used to demonstrate the problem (where the DDL at the top of the file must be executed first):
    import java.sql.*;
    import java.util.*;
    This sample generates another bug in the Oracle JDBC drivers where it is not
    possible to query the values of CHAR columns that use character length semantics
    and are NOT full of non-ascii characters. The inclusion of the VARCHAR2 column
    is just a control.
    CREATE TABLE TMP2
    TMP_ID NUMBER(10) NOT NULL PRIMARY KEY,
    TMP_CHAR CHAR(10 CHAR),
    TMP_VCHAR VARCHAR2(10 CHAR)
    public class ClsCharSelection
    private static String createString(char character, int length)
    char characters[] = new char[length];
    Arrays.fill(characters, character);
    return new String(characters);
    } // private static String createString(char, int)
    private static void insertRow(PreparedStatement ps,
    int key, char character)
    throws SQLException
    ps.setInt(1, key);
    ps.setString(2, createString(character, 10));
    ps.setString(3, createString(character, 10));
    ps.executeUpdate();
    } // private static String insertRow(PreparedStatement, int, char)
    private static void analyseResults(PreparedStatement ps, int key)
    throws SQLException
    ps.setInt(1, key);
    ResultSet results = ps.executeQuery();
    results.next();
    String tmpChar = results.getString(1);
    String tmpVChar = results.getString(2);
    System.out.println(key + ", " + tmpChar.length() + ", '" + tmpChar + "'");
    System.out.println(key + ", " + tmpVChar.length() + ", '" + tmpVChar + "'");
    results.close();
    } // private static void analyseResults(PreparedStatement, int)
    public static void main(String argv[])
    throws Exception
    Driver driver = (Driver)Class.forName(
    "oracle.jdbc.driver.OracleDriver").newInstance();
    DriverManager.registerDriver(driver);
    Connection connection = DriverManager.getConnection(
    argv[0], argv[1], argv[2]);
    PreparedStatement ps = null;
    try
    ps = connection.prepareStatement(
    "DELETE FROM tmp2");
    ps.executeUpdate();
    ps.close();
    ps = connection.prepareStatement(
    "INSERT INTO tmp2 ( tmp_id, tmp_char, tmp_vchar " +
    ") VALUES ( ?, ?, ? )");
    insertRow(ps, 1, 'a');
    insertRow(ps, 2, '\u00E0');
    insertRow(ps, 3, '\uE000');
    ps.close();
    ps = connection.prepareStatement(
    "SELECT tmp_char, tmp_vchar FROM tmp2 WHERE tmp_id = ?");
    analyseResults(ps, 1);
    analyseResults(ps, 2);
    analyseResults(ps, 3);
    ps.close();
    connection.commit();
    catch (SQLException e)
    e.printStackTrace();
    connection.close();
    } // public static void main(String[])
    } // public class ClsColumnInsertion

    FYI, this has been mentioned as early as November last year:
    String with length 1 became 4 when nls_lang_semantics=CHAR
    and was also brought up in Feburary:
    JDBC thin driver pads CHAR col to byte size when NLS_LENGTH_SEMANTICS=CHAR

  • How to compare text field length with the length of input characers

    I hae a problem with the length of text field
    I want to fix the length of TextField by taking the length of attribute to, whihc i have to use in text field
    Like i have set the max length of Attribut to 10 and set the length of textfield also 10.
    But the problem is that if i enter 10 'i' it dosn't fill even half the space in TextField
    And opposit if i enter 10 'W'
    I wonder if there is a solution for this problem
    i ma using True Type of Font

    * paint method in your own class that extends Canvas
    * @param g where to paint e.g. printer, screen, ram
    public void paint (Graphics g)
    // display word "today" centred at x,y
    FontMetrics fm = getFontMetrics( g.getFont( ) );
    String wording = "today" ;
    int xadj = fm.stringWidth( wording )/ 2;
    // position bottom left corner of the text
    g.drawString(wording , x-xadj, y );
    // draw a red line from x1,y1 to x2,y2
    g.setColor( Color .red );
    g.drawLine( x1 , y1, x2, y2);
    // draw an pre-existing Image. imX,imY is top left corner of the Image.
    g.drawImage ( image , imX, imY , imWidth, imHeight , this);
    } //end paint

  • Export with data length semantics

    Hello,
    I've following problem.
    I have a table abcd which contains 2 VARCHAR2 columns with different data length semantics (one with BYTE, one with CHAR). Charset is Single Byte; let's say WE8MSWIN1252, so data length semantics should not be a problem. should not. details later.
    So this would be:
    create table abcd (a_char VARCHAR2(2 CHAR), a_byte VARCHAR2(2 BYTE));after that I export the table via exp. I'm not setting NLS_LENGTH_SEMANTICS environment variable, so BYTE is used.
    In the dump file the data length semantics for the byte col is omitted, as I exported it with BYTE:
    create table abcd (a_char VARCHAR2(2 CHAR), a_byte VARCHAR2(2));after that, I "accidently" import it with data length semantics set to CHAR, and the table looks like this now
    abcd
    a_char VARCHAR2(2 CHAR)
    a_byte VARCHAR2(2 CHAR)Same happens vice versa when using CHAR for export and BYTE for import...
    In single byte charsets this might not be so much of a problem, as one CHAR is equal to one BYTE, but...
    If I compile plsql against the original table, and run against the outcoming table after export, I get an ORA-4062, and I have to recompile...
    Would not be a problem if the plsql I compile would be on the database...Big problem is that the ORA-4062 occurs in forms, where it's difficult for me to recompile (I would have to transfer all the sources to customer and compile there).
    Is there any possibility to export data length semantics regardless which environment variable is set?
    database version would be 9.2.0.6; but if there exists a solution in higher versions I would also be happy to hear them...
    many thanks,
    regards

    I can't reproduce your problem:
    SQL> show parameter nls_length_semantics
    NAME                                 TYPE        VALUE
    nls_length_semantics                 string      BYTE
    SQL> create table scott.demo( col1 varchar2(10 byte), col2 varchar2(10 char) );
    SQL> describe scott.demo
    Name                                      Null?    Type
    COL1                                               VARCHAR2(10)
    COL2                                               VARCHAR2(10 CHAR)
    $ export NLS_LENGTH_SEMANTICS=BYTE
    $ exp scott/tiger file=scott.dmp tables=demo
    SQL> drop table scott.demo;
    $ export NLS_LENGTH_SEMANTICS=CHAR
    $ imp scott/tiger file=scott.dmp
    SQL> describe scott.demo
    Name                                      Null?    Type
    COL1                                               VARCHAR2(10 BYTE)
    COL2                                               VARCHAR2(10)
    SQL> alter session set nls_length_semantics=byte;
    SQL> describe scott.demo
    Name                                      Null?    Type
    COL1                                               VARCHAR2(10)
    COL2                                               VARCHAR2(10 CHAR)Can you post a test like mine?
    Enrique
    PS If you have access to Metalink, read Note:144808.1 Examples and limits of BYTE and CHAR semantics usage. From 9i and up, imp doesn't read nls_length_semantics from the environment.
    Edited by: Enrique Orbegozo on Dec 16, 2008 12:50 PM
    Edited by: Enrique Orbegozo on Dec 16, 2008 12:53 PM

  • Problem with offset length

    Hi,
    i have a problem with offset length please see below code and suggest :
    data: content_new                LIKE soli-line.   "It has a length of 255 charecter
    content_new = 'MTE:SD0\nwssd01_SD0_00\CPU\CPU_Utilization'.
    content_new = content_new+4(251).
    it is giving result:
    content_new = SD0\nwssd01_SD0_00\CPU\CPU_Utiliza  "it is removing last 4 charecter of UTILIZATION also
    while i need :
    content_new = 'SD0\nwssd01_SD0_00\CPU\CPU_Utilization'.
    can anyone plz help me?
    regards.
    Moderator Message: Duplicate Post.
    Edited by: kishan P on Oct 28, 2010 9:44 AM

    You can find string length first. Subtract length by 4,  Then use like new = str+4(len), use condense if required.

Maybe you are looking for

  • Using multiple iCloud accounts on iPhone

    Can I have multiple icloud accounts for my iPhone? Iwant my wife to be able to sync with our network at home without changing her Apple ID

  • How to get field separator in flat file using GUI_DOWNLOAD function

    hi, how to get field separator in flat file using GUI_DOWNLOAD function.                                 thanking you.

  • How to define data-sources-alias.xml to use Oracle data source

    Hi, I created Oracle jdbc Data Source named "MYDS" in Visual Admin.  I added the alias = MYDS_ALIAS.  I set the Initial Connection to 2.  On the Monitor tab, I see a green line running across the screen.  The datasource MYDS is connected to the Oracl

  • DHCP: Some clients not getting IP address

    Recently setup a new DHCP server on Mac OS X Server 10.5.8 running on an Xserve.  We migrated from a Linux server. The Xserve was originally just a file server.  So the only services currently running are: AFP, DHCP, NFS, and SMB.  No additional soft

  • Overheating...but only on standby, lid closed!

    Many threads on overheating...However, my problem is that my MBP doesn't overheat when operating normally, but only when on standby, that is, with the lid closed and that little glowing light pulsating. It's a problem because I'm affraid of leaving i