Find the first occurance of a word

I have a script which finds and counts ALL occurances of a word.
I need the script to find the FIRST instance of a word only.
Can any one please advise how to modify the script to find the first instance of the word?
Script as follows:
var numWords = this.getPageNumWords(0);
for (var i=0; i<numWords; i++)
var ckWord = this.getPageNthWord(0,i);
if ( ckWord == "MATERIAL")
/*Script will go here based on finding the first instance of the word "MATERIAL"*/
I have tried var CKWord = this.getPageNthWord(0,0); but console reports back is UNDEFINED?

Thanks for your help.  Script now returns the first occurance of the word "MATERIAL".
I know have to add to the script to find the SECOND OCCURANCE of the word "ISSUED".
Can you please advise how I would code the script for this, ie would this have something to do with the break command?
var numWords = this.getPageNumWords(0);
for (var i=0; i<numWords; i++)
var ckWord = this.getPageNthWord(0,i);
if ( ckWord == "ISSUED")
var coord = this.mouseX;
var annot = this.addAnnot({
page: 0,
type: "Stamp",
name: "AppStamp",
rect: [coord+1000, 2300, 30, 2820],
rotate: 90,
AP: "#C94cHAFFa42U1gTH5Tug5C" }); 
/*break; how can this be modified to break for the second occurance of the word "ISSUED"?*/

Similar Messages

  • How to capitalize the first letter of each  word in a sentence?

    Can anyone please explain how to split a sentence at a comma, or space or hyphen in to words and capitalize the first letter of each word. But I don't know how many words the sentence contains.

    HI,
    data : begin of itab occurs 0,
             words(40),
             end of itab.
    data : v_sentence(1000).
    data : lv_firstchar.
    split v_sentence at ',' into table itab.
    loop at itab.
    translate itab-words+0(1) to upper case.
    modify itab index sy-tabix.
    endloop.

  • I am trying to write a grep search for the first instance of a word in a paragraph.

    How can I identify only the first instance of 'FREE' in a paragraph and apply a style to it, without also styling the 2nd or more instance of the word?
    Thanks

    (?i)^(.+?)FREE should find the first instance in a paragraph. The (?i) makes the search case insensitive in case it wasn't typed as all caps, the ? inside the second grouping makes the shortest match for cases when there is more than one instance in a paragraph, and I've not added any quotes since I presumed those aren't actually in the text.
    I would deal with the formatting by typing FREE exactly as you want it someplace on the pastebord, then copy to the clipboard. Change to $1~c which replaces the found string with the text found in the first subexpression (.+?), which is the stuff before the first FREE, and the the formatted contents of the clipboard for the FREE.

  • How to Capitalize the First Letter in Every Word in Mysql

    Hi,
    I have been trying to tidy up a massive database where visitors have been sloppy when entering text. The main thing I want to do is to Capitalize The First Letter In Every Word In Mysql.
    I have found the code below in PHP but it keeps finding an error on the WHILE line:
    <?php ini_set('display_errors', '1'); ?>
    <?php require_once('Connections/maison_connection.php'); ?>
    <?php
    $result = mysql_query ("SELECT column, id FROM table");
    while ($row = mysql_fetch_array($result)) {
    $id = $row["id"];
    $column2 = ucwords($row["column"]);
    $query2 = "UPDATE table SET column = '$column2′ WHERE id = '$id'";
    mysql_query($query2);
    ?>
    My table is called MailingList and the Column is called Name, so I have altered the script to this: but it still shows the same WHILE error:
    <?php ini_set('display_errors', '1'); ?>
    <?php require_once('Connections/maison_connection.php'); ?>
    <?php
    $result = mysql_query ("SELECT Name, id FROM MailingList");
    while ($row = mysql_fetch_array($result)) {
    $id = $row["id"];
    $Name2 = ucwords($row["Name"]);
    $query2 = "UPDATE MailingList SET Name = '$Name2′ WHERE id = '$id'";
    mysql_query($query2);
    ?>
    Any ideas??

    I got it to work this way in SQL: I am SURE there is an abbreviated way to do it, but at least it works
    UPDATE MailingList SET Name = replace(Name," a"," A");
    UPDATE MailingList SET Name = replace(Name," b"," B");
    UPDATE MailingList SET Name = replace(Name," c"," C");
    UPDATE MailingList SET Name = replace(Name," d"," D");
    UPDATE MailingList SET Name = replace(Name," e"," E");
    UPDATE MailingList SET Name = replace(Name," f"," F");
    UPDATE MailingList SET Name = replace(Name," g"," G");
    UPDATE MailingList SET Name = replace(Name," h"," H");
    UPDATE MailingList SET Name = replace(Name," i"," I");
    UPDATE MailingList SET Name = replace(Name," j"," J");
    UPDATE MailingList SET Name = replace(Name," k"," K");
    UPDATE MailingList SET Name = replace(Name," l"," L");
    UPDATE MailingList SET Name = replace(Name," m"," M");
    UPDATE MailingList SET Name = replace(Name," n"," N");
    UPDATE MailingList SET Name = replace(Name," o"," O");
    UPDATE MailingList SET Name = replace(Name," p"," P");
    UPDATE MailingList SET Name = replace(Name," q"," Q");
    UPDATE MailingList SET Name = replace(Name," r"," R");
    UPDATE MailingList SET Name = replace(Name," s"," S");
    UPDATE MailingList SET Name = replace(Name," t"," T");
    UPDATE MailingList SET Name = replace(Name," u"," U");
    UPDATE MailingList SET Name = replace(Name," v"," V");
    UPDATE MailingList SET Name = replace(Name," w"," W");
    UPDATE MailingList SET Name = replace(Name," x"," X");
    UPDATE MailingList SET Name = replace(Name," y"," Y");
    UPDATE MailingList SET Name = replace(Name," z"," Z");

  • Is there a command to capitalize the first letter of each word?

    That is to say, can you capitalize the first letter of each word in a document like say, word? Or using the net?
    Thanks guys.
    (hope that makes sense.)

    Select the text, then Format->Change Case->Title Case (Word 2004).

  • Making the first letter of every word a capital

    hello CF oracles
    could you guys please advise me the best way to make the
    first letter in every word of a string a capital letter. (and make
    all the other letters lower case).
    eg. convert "the quick brown fox" into "The Quick Brown Fox"
    or convert "THE QUICK BROWN FOX" into "The Quick Brown Fox"
    I am taking form data and inserting it into my table, so i
    want to get it right as the data is inserted.
    i found a "UDF" on CFLIb.org that proports to do this, but i
    don't know how to set up a UDF, are there other ways or is this
    considered the best approach.
    http://www.cflib.org/udf.cfm?id=9&enable=1
    thanks for any help you can give me

    found it, here's the top info, Titlecase is what you want for
    this.:
    changecase.cfm
    Rev 1.01
    cf_changecase is a simple custom tag to format case in given
    string.
    (c) 2001, Rizal Firmansyah, [email protected]
    Input var:
    * case (mandatory)
    possible inputs are
    - sentencecase: Sentence case (default)
    - titlecase: Title Case
    - lowercase: lowercase
    - uppercase: UPPER CASE
    "happysailingdude" <[email protected]> wrote
    in message
    news:e46tjv$e30$[email protected]..
    > hi Dan thanks very much. I have made an executive
    decision to do a bit of
    > a
    > hack for now as my site is only small so if a user
    enters something in the
    > wrong way i can quickly manually update it myself.
    >
    > so now i have this which works 9 times out of ten if the
    user enters a one
    > word name eg "bill" or "fred" of "jane" then it works
    just fine
    >
    > the only time it doesnt work is if the user's name is
    more than 1 word (or
    > is
    > hyphenated) eg "mary anne" or "anne-marie" hence the
    first cfif line - in
    > these
    > cases i can manually update
    >
    > i put this here in case it is of use to anyone else
    >
    > cheers
    >
    > <cfif not (FORM.firstName contains " " or
    FORM.firstname contains "-")>
    > '#Left( UCase( "#FORM.firstName#" ), 1 )##Right( LCase(
    > "#FORM.firstName#" ), Len("#FORM.firstName#" ) - 1 )#'
    > <cfelse>
    > '#FORM.firstName#'
    > </cfif>
    >

  • Is there a way to auto capitalize the first letter of every word?

    I Like To Type In This Way. I Was Wondering If There Is A Setting That Will Automatically Capitalize The First Letter Of Each Word So That I Don't Have To Keep Hitting Shift Before Each First Letter.
    Thank You

    AdamMarshall wrote:
    Nice to see so many 'helpful' responses.
    This casing is useful for example, on an Address field. It would be good if the OS had this option for developers.
    I'm pretty sure it does as I've certainly had apps that, in certain fields, do use title case.

  • How to map only the first occurance to the op in graphical mapping

    Hi,
    i have a record whose occurance is ' * '.But to the output i need to only map the value of the field which comes in the first occurance of the record.Can anyone help me in this.its very urgent.
    For ex :
    my input is
    <header>
    <inp1>123</inp1>
    <inp2>hello</inp1>
    </header>
    <header>
    <inp1>456</inp1>
    <inp2>hello</inp1>
    </header>
    To the output field <op1> i have to Map ' inp1 ' field but it has to take the value of the first inp1 i.e "123" only always.Any help on how to do this.
    Thanks in advance,
    Bhargav
    Message was edited by:
            bhargav gundabolu

    Hi Raj,
    My inp structure is:
    <header>
    <inp1>123</inp1>
    <inp2>hello</inp1>
    </header>
    <header>
    <inp1>456</inp1>
    <inp2>hello</inp1>
    </header>
    This has to me mapped to the output structure
    <result>
    </op1>
    </result>
    After Mapping inp1 to op1 my structure should appear as
    <result>
    <op1>123</op1>
    </result>
    <result>
    <op1>123</op1>
    </result>
    where <Header> node is mapped to </result>.As <result> has to appear as many times as Header appears.But the <op1> value has to be same as that of the <inp1> of the first <Header>

  • How to find the First block....in a multi block form

    hi
    How i can find which is the first block in a multi block form....
    ( there are n number of forms with multi blocks...so
    i need to generalise the code to find the first block in all of
    the forms)
    regards
    Kris

    If you searched in the on-line help for "First", you would find that the Get_Form_Property built-in provides two: First_Block and First_Navigation_Block.

  • HT203167 i have purchased 100 songs in last 2 years on itunes  now i am able to find the first 50 songs i am using the original id in all my devices.i even got the invoice of my purchase where can find them all?

    i have purchased 100 songs in last 2 years on itunes  now i am able to find the first 50 songs, i am using the origial id in all my devices.i even got the invoice of my purshace where can find them all?
    ITS NOT EVEN SHOWING UP IN PURCHASED SECTION

    1. iTunes won't offer cloud downloads for songs that it "thinks" are in your library, even if it "knows" the files are missing. If you've exhaustively searched for the missing files and there is no prospect of repair by restoring to them to their original locations, or connecting to new ones, then delete that tracks that display both the missing exclamation mark and are of media kind Purchased/Protected AAC audio file. Don't hide from iTunes in the cloud when asked, close iTunes, then reopen. You can download from the cloud links or iTunes Store > Quicklinks > Purchased > Music > Not on this computer > All songs > Download all.
    2. Why? Not sure, perhaps 3rd party tools or accidental key presses combined with previously hidden warning messages when trying to organize the library. There is a hint that using the feature to downsample media as it is synced to a device may also be involved, though I've not replicated it. Whatever the reason a backup would protect your media.
    tt2

  • UDF for Find the First letter from Input

    Hi Masters,
    I want find the first letter from input, Can any one help me on this..UDF or any solution.
    Ex: E2HB means - Alpha Letter is the first
    Ex: 1234 means - Number is the first
    Thanks,
    Siva

    Hi Siva,
                I just want to clarify this doubt, you want the first character of the string you pass to the UDF i.e if input="E2HB"  output="E"   and if input="1234"   output="1". If my assumption is correct you can try the UDF "firstChar" I have shown below this gives exactly the output you want
    public class firstLetter {
         public static String firstChar(String s)
              if(s==null)
                   return null;
              if(s.equals(""))
                   return s;
              String t="";
              t+=s.charAt(0);
              return t;
         public static void main(String[] args) {
              String s1="E2HB",s2="1234";
              s1=firstChar(s1);
              System.out.println(s1);
              s2=firstChar(s2);
              System.out.println(s2);
    Regards
    Anupam

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • Finding the first unused number in a column

    I am attempting to write a single SQL statement that can find the first unused number for a column. For example, for a column called BLOCKID, that contains these values...1,2,3,4,6,7,8...I would like to be able to insert a record with BlockID equal to 5. I can do this by writting a loop, but that seems quite inefficient (may have to loop hundreds of times or more to find the first available hole).
    Any ideas? Thanks, Kieren
    null

    Here's one way
    1. Get a list of row numbers for the table
    2. Add an item to the list for 1 more than the largest id
    3. Remove from the list all numbers already used
    4. Use the smallest value of the list that is left.
    As a query this would be:
    SELECT MIN(BLOCKID) FROM
    (SELECT MAX(BLOCKID) + 1 BLOCKID
    FROM mytable UNION ALL
    SELECT ROWNUM BLOCKID
    FROM mytable MINUS
    SELECT BLOCKID FROM mytable
    Needless to say there should be a primary key or index on the BLOCKID column of 'mytable'.
    Good luck!
    null

  • Where can i find the first iPhoto

    Where can i find the first iphoto?

    Best if you try and explain what you are trying to acheive.
    Iphoto is a different paradigm than you're used to. I don't understand why you are trying to transfer your edited photos back to an external disk.
    There are tutorials here
    http://www.apple.com/findouthow/photos/
    Regards
    TD

  • IDOCS - Finding the first error message when reprocess has been done 17000 times

    I was hoping for some assistance. We have an automated reprocessing of our iDocs in one interface. I would like to find the first error message at status 51 in order to see the failure messge. Since the idocs have been reprocessed so many times, it cannot be found in the iDoc handler. Please advise if you have tips.

    This message looks like homemade. And the message will not change, no matter how often you repost the same IDOC without having changed anything.
    So you should at least see the message number to this message in the EDIDS table
    You can search SCN using this number, you can search for OSS notes with this number, or you get active yourself in SAP and check the where used list from SE91 transaction to know in which program this error is triggered and under what circumstances

Maybe you are looking for

  • Getting applets to work in Firefox or IE7!!

    Hi folks. I've been reading Jason Hunters excellet book on Java Servlet Programming and become rather stuck on being able to get applets to work in a browser. 1) I managed to briefly get an Applet to work in IE7. Then things went astray (I say work,

  • Error message in configurin​g profession​nal email account (Invalid\e​scape: line 1 column 271 (char 271).)

    Hi, I have an issue I am not able to solve. When configuring a pro email in the advanced menu, I have the below error message : Invalid\escape: line 1 column 271 (char 271). I have checked the email information (server adress, password and so on), ev

  • Process Chains with Event Trigger

    Hi Experts, Happy Valentine day. I have a requirement to run a Process Chain using Event IDs. Now these Evenrt ID should be triggered by a Program which raises this Eovent. Then this Program should be scheduled in BAckground to run periodically. Has

  • What is the Best Practice for A1000 LUN Configuration

    I have a fully populated 12 X 18GB A1000 array, What is the optimal LUN configuration for a A1000 Array running RAID5 in a read intensive oracle financials environment. 1. 1 (10 X 18GB + 2 X 18GB HS ) (Use format to split at OS level) - Current Setti

  • How to hire new employee (BAPI, BDC, IDoc/ALE...???)

    Dear ladies and gentlemen, I was asked to create an interface that would "hire employee" and I failed to find nice function module that would do that. Could you, please, share your ideas/experience about how to solve this? Best regards Momkic Message