How to calculate the length of a string

Hi everyone,
A simple question. How to calculate the length of a string?
Thanks!

Hi Wuyia Nata,
  As everyone has suggested you search the forum before posting a question, i guess for basic questions u never have to post a question, you will get the answer in your search. Anyways see the code below for string lenght.
Data:
  w_string type string,
  w_lenght type i.
w_string = 'vhdskbvsdkbvdsvnsknvs'.
w_lenght = strlen( w_string ).
Write:
  w_lenght.
With luck,
Pritam.

Similar Messages

  • How is the length of a string calculated in Java?  and JavaScript?

    Hi all,
    Do any of you know how the length of a string is being calculated in Java and JavaScript? For example, a regular char is just counted as 1 char, but sometimes other chars such as CR, LF, and CR LF are counted as two. I know there are differences in the way Java and JavaScript calculate the length of a string, but I can't find any sort of "rules" on those anywhere online.
    Thanks,
    Yim

    What's Unicode 4 got to do with it? 1 characteris 1
    character is 1 character.
    strings now contain (and Java chars also) is
    UTF-16 code units rather than Unicode characters
    or
    code points. Unicode characters outside the BMPare
    encoded in Java as two or more code units. So it would seem that in some cases, a single
    "character" on the screen, will require two charsto
    represent it.So... you're saying that String.length() doesn't
    account for that? That sux. I don't know. I'm just making infrerences (==WAGs) based on what DrClap said.
    I assume it would return the number of chars in the array, rather than the number of symbols (glyphs?) this translates into. But I might have it bass ackwards.

  • How to get the length in bytes of a string

    My string has both latin (1 byte) and chinese (2 bytes).
    My program is in unicode system.
    How to measure the length in bytes of the string?
    the xlen function does not work.

    Hello,
    parameters : p_str type string.
    data : len type i.
    len = strlen( p_str ).
    write : / len.
    With Regards,
    BVS
    Hi BSV, your code return the number of characters not bytes.
    Remember chinese character in US are encoded with 2 bytes.
    And my string contain both latin and chinese characters.
    thanks

  • How to calculate the total  length of a Line

    Hi,
    We are using Mapviewer for representing for spatial data in form of a Image .
    We are using Mapviwer.addLinearFeaure for drawing lines on the Image( browser)
    Thsese lines are drawn .
    Now our requirement is we need to calculate the length of the lines in our Image .Please tell me how to do this .
    Thanks in advance
    Edited by: user672373773 on Nov 11, 2009 9:11 AM

    You can do this by two ways.
    1) create SDO_GEOMETRY from your coordinates and use SDO_GEOM.SDO_LENGTH to get length of the line.
    Or
    2) iterate your line points coordinate array and calculate distance between points add it to final length.
    Here is snippet to calculate length of line (not tested)
    length = 0;
    for( i=0; i<coordpts.length-2; i++) {
    length = length + getDistance(coordpts[0], coordpts[1]);
    to calculate distance between 2 points use below code (getDistance() source code)
    double dblDistance = Math.sqrt(Math.pow((dblPt2[0] - dblPt1[0]), 2) + Math.pow((dblPt2[1] - dblPt1[1]), 2));
    In both case you need to convert screen coordinate to map coordinate.
    Sujnan

  • How to calculate the frequency of the search string in a row

    Hi,
    I would like to find the frequency of the number of the occurences of a search string in a row which is of type of xmltype content.
    For ex: I would like to find the frequency of the word "oracle" in a row which is of type xmltype content.
    Is there any fuction called frequency or freq...
    Thanks in advance....

    Oh!
    Then How to calculate the frequency of occurences in a row ?
    I hope the Score formula is S=3f(1+log(N/n))
    I want to calculate the f value alone, how is it possible.
    Thanks in advance.....

  • How to calculate the costs of every item categary in costing run

    Hello Experts,
    Could anyone explain how to calculate the costs of every item categary when I carry out the costing run. For example, item categary: M, E, G.
    Thank you in advance.
    Maria

    This Applesctipt will add comma's to the file count:
    (Copy into Applescript Editor, and Save as File Format: App, then just click the App to run)
    set x to choose folder with prompt "Choose Folder to Count Files" default location alias (the path to pictures folder as text)
    set filecount to do shell script "find " & POSIX path of x & " ! -type d ! \\( -name \".*\" -or -name \"Icon*\" \\) | wc -l"
    display dialog "File Count: " & comma_delimit(trim(filecount))
    on trim(someText)
              repeat until someText does not start with " "
                        set someText to text 2 thru -1 of someText
              end repeat
              repeat until someText does not end with " "
                        set someText to text 1 thru -2 of someText
              end repeat
              return someText
    end trim
    on comma_delimit(this_number)
              set this_number to this_number as string
              if this_number contains "E" then set this_number to number_to_text(this_number)
              set the num_length to the length of this_number
              set the this_number to (the reverse of every character of this_number) as string
              set the new_num to ""
              repeat with i from 1 to the num_length
                        if i is the num_length or (i mod 3) is not 0 then
                                  set the new_num to (character i of this_number & the new_num) as string
                        else
                                  set the new_num to ("," & character i of this_number & the new_num) as string
                        end if
              end repeat
              return the new_num
    end comma_delimit

  • How to measure the size of a string

    windows app store how to measure the size of a string?
    string str = "Hello word windows app store";

    if you need the actual width the string occupies in pixels than use (see
    this MSDN link for more details):
    Graphics.MeasureString(String, Font)
    if you only need the "length" of the string i.e. no. of characters than use (see
    this MSDN link for more details):
    str.Length
    dont forget to bing / google :)
    hope this helps!
    Graphics.MeasureString(String, Font) can not use in windows store app.
    TextBlock has Measure()
    method, as following:
    Size MeasureString(string content, Size availableSize, double fontSize, string fontFamily="Segoe UI")
        TextBlock tb = new TextBlock();
        tb.TextWrapping = TextWrapping.Wrap;
        tb.Text = content;
        tb.FontFamily = new Windows.UI.Xaml.Media.FontFamily(fontFamily);
        tb.FontSize = fontSize;
        tb.Measure(availableSize);
        return tb.DesiredSize;
    Test:
    string str = "Hello word windows app store";
    Size size = MeasureString(str, new Size(800, 600), 40);

  • How to Increase the Length of Condition table in OV20

    While creating a condition table in T.code OV20 if fields length is more that 50 bytes table is not getting generated.it gives error as Too Many Fields Selected(More than 50 Bytes).
    Actually i need to create a tabel with Basic Material(WRKST) which has length of 48 bytes.
    Is there a solution on how to increase the length so that error is avoided.
    There is no such error occuring while crating condition table in V/03

    Hi,
         You can try to use the type string:
    form like zscr_data_hdr-form,
    werks like zscr_data_hdr-werks,
    matnr like zscr_data_hdr-matnr,
    verid like zscr_data_hdr-verid,
    lot like zscr_data_hdr-lot,
    lot_qty like zscr_data_hdr-lot_qty,
    udate like zscr_data_hdr-udate,
    utime like zscr_data_hdr-utime,
    zuser like zscr_data_hdr-zuser,
    processed like zscr_data_hdr-processed,
    defect like zscr_defect_data-defect,
    vornr like zscr_route_data-vornr,
    fieldxx type string,
    dayst like zscr_data_hdr-dayst,
    end of t_data.
    So you can save you informations of every fld<n> concatenating their values into fieldxx.
    Regards

  • How to increase the length of internal table dynamically

    How to increase the length of internal table dynamically depending on the number of fields fetched into the internal table ?
    The requirement code :
    types: begin of t_data,
             form          like zscr_data_hdr-form,
             werks         like zscr_data_hdr-werks,
             matnr         like zscr_data_hdr-matnr,
             verid         like zscr_data_hdr-verid,
             lot           like zscr_data_hdr-lot,
             lot_qty       like zscr_data_hdr-lot_qty,
             udate         like zscr_data_hdr-udate,
             utime         like zscr_data_hdr-utime,
             zuser         like zscr_data_hdr-zuser,
             processed     like zscr_data_hdr-processed,
             defect        like zscr_defect_data-defect,
             vornr         like zscr_route_data-vornr,
             fld1          like zscr_defect_data-defect_val,
             fld2          like zscr_defect_data-defect_val,
             fld3          like zscr_defect_data-defect_val,
             fld4          like zscr_defect_data-defect_val,
             fld5          like zscr_defect_data-defect_val,
             fld6          like zscr_defect_data-defect_val,
             fld7          like zscr_defect_data-defect_val,
             fld8          like zscr_defect_data-defect_val,
             fld9          like zscr_defect_data-defect_val,
             fld10         like zscr_defect_data-defect_val,
             fld11         like zscr_defect_data-defect_val,
             fld12         like zscr_defect_data-defect_val,
             fld13         like zscr_defect_data-defect_val,
             fld14         like zscr_defect_data-defect_val,
             fld15         like zscr_defect_data-defect_val,
             fld16         like zscr_defect_data-defect_val,
             fld17         like zscr_defect_data-defect_val,
             fld18         like zscr_defect_data-defect_val,
             fld19         like zscr_defect_data-defect_val,
             fld20         like zscr_defect_data-defect_val,
             fld21         like zscr_defect_data-defect_val,
             fld22         like zscr_defect_data-defect_val,
             fld23         like zscr_defect_data-defect_val,
             fld24         like zscr_defect_data-defect_val,
             fld25         like zscr_defect_data-defect_val,
             fld26         like zscr_defect_data-defect_val,
             fld27         like zscr_defect_data-defect_val,
             fld28         like zscr_defect_data-defect_val,
             fld29         like zscr_defect_data-defect_val,
             fld30         like zscr_defect_data-defect_val,
             fld31         like zscr_defect_data-defect_val,
             fld32         like zscr_defect_data-defect_val,
             fld33         like zscr_defect_data-defect_val,
             fld34         like zscr_defect_data-defect_val,
             fld35         like zscr_defect_data-defect_val,
             fld36         like zscr_defect_data-defect_val,
             fld37         like zscr_defect_data-defect_val,
             fld38         like zscr_defect_data-defect_val,
             fld39         like zscr_defect_data-defect_val,
             fld40         like zscr_defect_data-defect_val,
             fld41         like zscr_defect_data-defect_val,
             fld42         like zscr_defect_data-defect_val,
             fld43         like zscr_defect_data-defect_val,
             fld44         like zscr_defect_data-defect_val,
             fld45         like zscr_defect_data-defect_val,
             fld46         like zscr_defect_data-defect_val,
             fld47         like zscr_defect_data-defect_val,
             fld48         like zscr_defect_data-defect_val,
             fld49         like zscr_defect_data-defect_val,
             fld50         like zscr_defect_data-defect_val,
             fld51         like zscr_defect_data-defect_val,
             fld52         like zscr_defect_data-defect_val,
             fld53         like zscr_defect_data-defect_val,
             fld54         like zscr_defect_data-defect_val,
             fld55         like zscr_defect_data-defect_val,
             fld56         like zscr_defect_data-defect_val,
             fld57         like zscr_defect_data-defect_val,
             fld58         like zscr_defect_data-defect_val,
             fld59         like zscr_defect_data-defect_val,
             fld60         like zscr_defect_data-defect_val,
             fld61         like zscr_defect_data-defect_val,
             fld62         like zscr_defect_data-defect_val,
             fld63         like zscr_defect_data-defect_val,
             fld64         like zscr_defect_data-defect_val,
             fld65         like zscr_defect_data-defect_val,
             fld66         like zscr_defect_data-defect_val,
             fld67         like zscr_defect_data-defect_val,
             fld68         like zscr_defect_data-defect_val,
             fld69         like zscr_defect_data-defect_val,
             fld70         like zscr_defect_data-defect_val,
             fld71         like zscr_defect_data-defect_val,
             fld72         like zscr_defect_data-defect_val,
             fld73         like zscr_defect_data-defect_val,
             fld74         like zscr_defect_data-defect_val,
             fld75         like zscr_defect_data-defect_val,
             fld76         like zscr_defect_data-defect_val,
             fld77         like zscr_defect_data-defect_val,
             fld78         like zscr_defect_data-defect_val,
             fld79         like zscr_defect_data-defect_val,
             fld80         like zscr_defect_data-defect_val,
             fld81         like zscr_defect_data-defect_val,
             fld82         like zscr_defect_data-defect_val,
             fld83         like zscr_defect_data-defect_val,
             fld84         like zscr_defect_data-defect_val,
             fld85         like zscr_defect_data-defect_val,
             fld86         like zscr_defect_data-defect_val,
             fld87         like zscr_defect_data-defect_val,
             fld88         like zscr_defect_data-defect_val,
             fld89         like zscr_defect_data-defect_val,
             fld90         like zscr_defect_data-defect_val,
             fld91         like zscr_defect_data-defect_val,
             fld92         like zscr_defect_data-defect_val,
             fld93         like zscr_defect_data-defect_val,
             fld94         like zscr_defect_data-defect_val,
             fld95         like zscr_defect_data-defect_val,
             fld96         like zscr_defect_data-defect_val,
             fld97         like zscr_defect_data-defect_val,
             fld98         like zscr_defect_data-defect_val,
             fld99         like zscr_defect_data-defect_val,
             fld100         like zscr_defect_data-defect_val,
             fld101         like zscr_defect_data-defect_val,
             fld102         like zscr_defect_data-defect_val,
             fld103         like zscr_defect_data-defect_val,
             fld104         like zscr_defect_data-defect_val,
             fld105         like zscr_defect_data-defect_val,
             fld106         like zscr_defect_data-defect_val,
             fld107         like zscr_defect_data-defect_val,
             fld108         like zscr_defect_data-defect_val,
             fld109         like zscr_defect_data-defect_val,
             fld110         like zscr_defect_data-defect_val,
             fld111         like zscr_defect_data-defect_val,
             fld112         like zscr_defect_data-defect_val,
             fld113         like zscr_defect_data-defect_val,
             fld114         like zscr_defect_data-defect_val,
             fld115         like zscr_defect_data-defect_val,
             fld116         like zscr_defect_data-defect_val,
             fld117         like zscr_defect_data-defect_val,
             fld118         like zscr_defect_data-defect_val,
             fld119         like zscr_defect_data-defect_val,
             fld120         like zscr_defect_data-defect_val,
             fld121         like zscr_defect_data-defect_val,
             fld122         like zscr_defect_data-defect_val,
             fld123         like zscr_defect_data-defect_val,
             fld124         like zscr_defect_data-defect_val,
             fld125         like zscr_defect_data-defect_val,
             fld126         like zscr_defect_data-defect_val,
             fld127         like zscr_defect_data-defect_val,
             fld128         like zscr_defect_data-defect_val,
             fld129         like zscr_defect_data-defect_val,
             fld130         like zscr_defect_data-defect_val,
             fld131         like zscr_defect_data-defect_val,
             fld132         like zscr_defect_data-defect_val,
             fld133         like zscr_defect_data-defect_val,
             fld134         like zscr_defect_data-defect_val,
             fld135         like zscr_defect_data-defect_val,
             dayst         like zscr_data_hdr-dayst,
           end of t_data.
    In this fld1 to fld135 are defined in internal table.
    But if the number of fields are more than 135 then the program is going to short dump.
    Some times fld1 to fid170 or more fields will be there in my internal table.
    Please suggest me how to make my requirement dynamic and display this data fetched into this internal table onto a .XLS file in the presentation server ?

    Hi
    You can try to use the type string:
    form like zscr_data_hdr-form,
    werks like zscr_data_hdr-werks,
    matnr like zscr_data_hdr-matnr,
    verid like zscr_data_hdr-verid,
    lot like zscr_data_hdr-lot,
    lot_qty like zscr_data_hdr-lot_qty,
    udate like zscr_data_hdr-udate,
    utime like zscr_data_hdr-utime,
    zuser like zscr_data_hdr-zuser,
    processed like zscr_data_hdr-processed,
    defect like zscr_defect_data-defect,
    vornr like zscr_route_data-vornr,
    fieldxx type string,
    dayst like zscr_data_hdr-dayst,
    end of t_data.
    So you can save you informations of every fld<n> concatenating their values into fieldxx.
    Max

  • How to restrict the length of the input?

    Hi all, could any one tell me how to restrict the length of the input string? My SOA Suite is 10.1.3.1
    I tried the following; getting an error.
    <element name="RestrictLengthProcessRequest">
    <simpleType name="SSN">
    <restriction base="string">
    <length value="10"/>
    </restriction>
    </simpleType>
    where RestrictLengthProcessRequest is the message name of the corresponding .wsdl and SSN is the input whose length is to be restricted.
    The error is : 'Attribute name not defined on element simpleType'
    Thanks in advance.
    Edited by: user11275112 on Aug 27, 2009 11:44 PM

    Hi swathi,
    For this you have to create a simple data type. No need of writing a code.
    Go to Dictionaries -> Local Dictionary -> Data Type - > Simple Type - > Right click and "Create Simple Type".
    Here you should create a Simple type with String as built-in Type. Here you will also see the Length Constraints option.
    Set the value of maximum length and minimum length. In your case set the value of maximum length to 10. At runtime this will not allow the user to enter more than 10 characters.
    Now create an attribute and bind it to this newly created simple type. Bind the value of the input field with this particular attribute.
    Regards
    Manohar

  • How to calculate the row size

    Hi,
    I am having a table of 4 column. First column is varchar2(10), Second column is Number(5), Third column is char(10) and Fourth column is Number(12,2).
    Now how to calculate the size of each row. I want to know how much space it will take for each row.
    Thanx & Regards,
    Swarup

    For a complete discussion of storage requirements for different datatypes see the Oracle 8i Concepts manual.
    All Oracle documentation is available on-line via the 'Documentation' link on the OTN home page.
    Your Col2 NUMBER(5) will take 4 bytes if it holds a 5 digit positive or negative number.
    Your Col4 NUMBER(12,2) will take 7 bytes if it holds a number with 12 digits that is positive and will take 8 bytes if it holds a number with 12 digits that is negative.
    The following is from the Concepts manual Chapter 12 (Copyright by Oracle)
    Built-In Datatypes 12-9
    Internal Numeric Format
    Oracle stores numeric data in variable-length format. Each value is stored in
    scientific notation, with one byte used to store the exponent and up to 20 bytes to
    store the mantissa. The resulting value is limited to 38 digits of precision. Oracle
    does not store leading and trailing zeros. For example, the number 412 is stored in a
    format similar to 4.12 x 10 2 , with one byte used to store the exponent (2) and two
    bytes used to store the three significant digits of the mantissa (4, 1, 2). Negative
    numbers include the sign in their length.
    Taking this into account, the column size in bytes for a particular numeric data
    value NUMBER ( p), where p is the precision of a given value, can be calculated
    using the following formula:
    ROUND((length( p)+ s)/2))+1
    where s equals zero if the number is positive and s equals 1 if the number is
    negative.
    Zero and positive and negative infinity (only generated on import from Version 5
    Oracle databases) are stored using unique representations. Zero and negative
    infinity each require one byte; positive infinity requires two bytes.
    null

  • How to determine the length of variable based on the character contents

    Hi Experts,
    I need to determine the length of variable based on the character contents I am looking for.
    Example;
        lv = 'FENCE - Construction bond'
    Where I need to know the exact field length of 'FENCE -'.
    It's possible that variable will have different values in different lengths.
    Thanks.
    Kath

    Kathy Amion  ,
    hello Will you please elaborate ...!
    The suggestion for your proble as i understood it is you will have to split the string at seperator '-' in two say variable name and conten. and then  you will calculate the length of the VARIable name by using string function.

  • How to calculate the RMS level of a signal with its spectral representation

    hi!
    how to calculate the RMS level of a signal with its spectral representation
    thanks

    1. Find the length, N, of the spectral signal.
    2. Convolve the magnitude of the signal with itself.
    3. Take the Nth element of the resulting signal
    4. Take the square root.
    5. This should be the RMS value of your signal.
    Randall Pursley
    Attachments:
    RMS.bmp ‏616 KB

  • How to restrict the length of input field

    Hi,
    How to restrict the length of input field. That is we should not be able to enter more thatn 10 charecters.
    Regards,
    H.V.Swathi

    Hi swathi,
    For this you have to create a simple data type. No need of writing a code.
    Go to Dictionaries -> Local Dictionary -> Data Type - > Simple Type - > Right click and "Create Simple Type".
    Here you should create a Simple type with String as built-in Type. Here you will also see the Length Constraints option.
    Set the value of maximum length and minimum length. In your case set the value of maximum length to 10. At runtime this will not allow the user to enter more than 10 characters.
    Now create an attribute and bind it to this newly created simple type. Bind the value of the input field with this particular attribute.
    Regards
    Manohar

  • How to calculate the unit for RATE?

    Hey All,
    I am not sure if there is something standard for this or not.
    I am calculating the 'Rate' by using 'Value/Amount' and 'Quantity' as follows -
    Rate == Value /  Quantity
    I need to calculate the unit for the rate as below -
    Rate unit == Value unit (Currency) /  Quantity unit (Base_uom) 
    (for example -
    if value is 1000 USD and quantity is 10 TO then Rate should come out as 100 USD / TO)
    Could anyone please suggest how to calculate the unit in this case?
    Many Thanks!
    Tanu

    Hi,
    Go through the below link it may give some idea
    http://help.sap.com/saphelp_nw04/Helpdata/EN/19/1d7abc80ca4817a72009998cdeebe0/content.htm
    Regards,
    Marasa.

Maybe you are looking for