[CS2/CS3 JS] Finding the first character of each paragraph

Hi,
Can anybody help with my script below:
for (h=0; myParaCount>h; h++){
myChars = myStory.paragraphs.item(h).contents;
if (myChars.characters.item(0) == "l" && myChars.characters.item(0).appliedCharacterStyle == CharStyleWin){
myStory.paragraphs.item(h).appliedParagraphStyle = "L-B";
This script is supposed to test if the first character is an "l" with my character style "Wingdings" applied to it. I could not test whether the character style is "Wingdings" or not. What could be wrong with my script. Thanks.

// You need to have a textFrame selected
var myFrame = app.selection[0];
var myParaCount = myFrame.paragraphs.length;
// There must exist a paragraphStyle name L-B
var myApplyStyle = app.activeDocument.paragraphStyles.item("L-B")
for (h=0; h < myParaCount; h++){
var myChar = myFrame.paragraphs.item(h).characters.firstItem();
// check if first char is "l" and if its applied charstyle name is CharStyleWin
if (myChar.contents == "l" && myChar.appliedCharacterStyle.name == "CharStyleWin"){
myFrame.paragraphs.item(h).appliedParagraphStyle = myApplyStyle;
/* Edited at 11.21 */

Similar Messages

  • 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

  • TestStand database logging problem: only the first character is put in the table.

    I am using TestStand 2.0.1 and Microsoft SQL server database. There is a weird problem when I use database logging. At first, all the database logging ran good.
    Then one day after I moved the test equipment to production line, TestStand only logs the first character of each string field in the tables! There is no error message.
    I setup another SQL server running locally on the same machine as the TestStand is and move the database to the local server, database logging has no problem. Schemas in TestStand Dabasebase Options are the same.
    I tried to run TestStand from another computer on the network. There was no problem before, too.  But now, TestStand always shows a Run-time error message like this:
    Details:
    An exception occurred calling 'LogResults' in 'ITSDBLog' of 'DBLog 1.0 Type Library'
    An error occurred executing a statement.
    Schema: New.
    Statement: STEP_RESULT.
    Connection failureMultiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
    Source: TSDBLog
    Error Code:
    -2147467259; User-defined error code.
    Location:
    Step 'Log Results to Database' of sequence 'Log To Database' in 'Database.seq'
    I have checked that the connection is good and also the table UUT_RESULT has been logged correctly.
    Anyone can help?
    Thanks.

    Thank you very much, Santiago.
    Yes, I have a customized schema, but it is based on the pre-existing schema. I tried the schema:TS 1.x Access/SQL (NI), which  came with TestStand, the results were the same. 
    I have tried to run different sequences. On one computer, I always get only the first character of each string entry logged in the remote database, however for the local server, everything is fine. On the other computer, there is no local SQL server, I always get similar error message as I mentioned in my post. The sequence step reports error is  "Log Results to Database".
    Any more suggestion?
    Thanks again.
    Best regards,
    Jaso

  • First character in each word

    Hello All,
    I want to get the first character of each word:
    If I have "Statement To Be Parsed" so i want a query to return STBP.
    Your help please

    Hi,
    NB wrote:
    Hello Franck,
    One more thing i have the below case which is not covered
    "Test STMT Func/ Brg E.O.D Act ON LINE/ Ext" i want it to be TSF/BEAOL/E
    please your help againINITCAP conisders '.' to mark the end of a word, so INITCAP ('E.O.D.') returns 'E.O.D.' (all capital letters). If you want to ignore '.'s, so that you get 'Eod' (only 'E' capitalized) as a result, then use REPLACE (or some other string manipulation function) to get rid of the '.'s before calling INITCAP.
    REGEXP_REPLACE (str, '[^A-Z]') returns a copy of str with all characters except those indicated inside the square brackets removed. If you want other characters (such as '/') kept, then just add them to the list inside the square brackets, like this:
    SELECT     REGEXP_REPLACE ( INITCAP ( REPLACE ( 'Test STMT Func/ Brg E.O.D Act ON LINE/ Ex'
                     , '[^A-Z/]'
                     )     AS inits
    FROM    dual;Output:
    INITS
    TSF/BEAOL/E

  • The first character in a string

    I need to return the first character of a string, convert it to an integer, and compare it with another integer to see if they're the same. Sounds simple, even for me, but it won't work!!!
    // First question >
    Object userValue1 = JOptionPane.showInputDialog("Blah Blah Blah", JOptionPane.PLAIN_MESSAGE, null, options1, options1[0]);
    Variables.placeholder = (int) userValue1.charAt(0);This is the error I get
    C:\Documents and Settings\imholt\My Documents\OOPAttempt\21_Questions\Engine.java:170: cannot resolve symbol
    symbol : method charAt (int)
    location: class java.lang.Object
              Variables.placeholder = (int) userValue1.charAt(0);
    ^
    1 error
    I have a sneaky suspicion that once I find out what the problem was, I will ask myself why I didn't see it before...

    Try this
    Object userValue1 = JOptionPane.showInputDialog("Blah Blah Blah", JOptionPane.PLAIN_MESSAGE, null, options1, options1[0]);
    String str = userValue1.toString();
    Variables.placeholder = (int) str.charAt(0);

  • How can a  variable display the first character that's on the page?

    I'm creating a telephone directory and want each page to display the alphabet of the first listing on the page on the top - only one character.
    Can you tell me how to do this?

    Hmmmmm, seems I was wrong about the GREP styles. I just tried it and they don't get picked up. I consider that a bug, but it's probably "as designed."
    That leaves you having to work with nested styles only, or Find/Change. I think what you'll need to do is redefine the Paragraph style so it has two nested styles that apply the correct style to whatever needs to be styled at the start of the paragraph, one for the first character and the second for the rest of the word(s) if you can figure out a trigger (can InData add an end nested style character or is thew some punctuation you can use?), then find/change to remove the applied character style. For that I'd serach for ^.+ with the find format set to the character style that InData applied and the chane format set to [None], which will only remove it from the beginning of your paragraphs. If this is done correctly there will be no change in appearance since the redefined paragraph style will do the formatting.
    If that won't work, you can use find/change to apply a new style to the first characters. Search for ^. and set the change format to the new character style that you'll use in the variable. It needs to have the same attributes as the style applied by InData or the appearance will change.
    The second method is probably easier since you don't need to redfine the paragraph style, but both methods require you to use find/change to alter the text, which means if more text is added you'll need to re-do the find/change. Not a big deal, but don't forget. I'd be tempted to wait until the last minute and just ignore the headers for the moment, if editing is ongoing. I'd also test this on a copy of the file for safety.

  • Find the last character in an aplhanumreic string

    Hi guys first time poster long time hiding in the shadows,
    hopefully someone can help me
    I have set of username stored and I need to find the last
    character before the number for example
    abc123 I would want to find c
    ab123 I would want to find b
    any suggestions as to how I would do this?
    Thanks in advance

    Here's one way:
    <CFSET YourString = "abc123")>
    <CFSET LastChar = "">
    <CFSET Pos = 1>
    <CFSET CharLen = Len(YourString)>
    <CFLOOP from="1" to="#CharLen#" step="1">
    <CFSET Char = right(left(YourString,Pos),1)>
    <CFIF Not IsNumeric(Char)>
    <CFSET LastChar = Char>
    <CFSET Pos = Pos + 1>
    <CFELSE>
    <CFBREAK>
    <CFIF>
    </CFLOOP>

  • 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

  • Can not run the calc scripts by mxl, if the first character is Number

    I found that if you create the calc scrpt like 1abc.csc. You can not run it by mxl. I tried for times but do not know the reason for that. I found that you can use number in the name of the calc scripts(like abc1.csc, a1bc.csc), but not for the first character(like 1abc.csc).
    Below is my mxl scripts:
    ×××××××××××××××××××××××××××××××××××
    login admin identified by password on localhost;
    spool on to 'C:\abc.log' ;
    execute calculation sample.basic.1abc;
    spool off;
    logout;
    ×××××××××××××××××××××××××××××××××××
    I write a bat file below:
    ×××××××××××××××××××××××××××××××××××
    D:\Hyperion\AnalyticServices\bin\essmsh C:\abc.mxl
    ×××××××××××××××××××××××××××××××××××
    I can run the scripts if I change the name "1abc" to "abc1"or "a1bc".
    Of course I can run this calc in EAS, no matter the name is "1abc" or "abc1".
    Anybody find the same problem with me?

    I agree, if ever there was a "best practice" to developing scripts (especially when using variables) it is to enclose in single quotes. I actually use double quote, single quote.
    execute calculation "'$4'"."'$5'"."'$6'";

  • 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"?*/

  • Only display the first character issue

    Hi,
    I'm using CR 2008 to generate reports.
    I use oracle database.
    I use a stored procedure to get data and everything working fine ,it return correct data.
    I have five details section but i display one details section and i suppress others
    My issue is execute the rpt file to presssig F5 key;   string type record is only able to print the first character on the preview.
    eg: record with value 'ABCDE', after printed on rpt file, only character 'A' was printed on the preview.
    if i verify database, it display correct data but a few times later problem occurs again
    Anyone know how to fix it?

    if you create a blank report as follows , you will take same error
    my reports section;
    section - formula fieds 
    a - - - - a b f g
    b - - - - a b e f g
    c - - - - a b c e f g
    d - - - - c f g
    e - - - - d e f g
    my details sections suppress formula;
    if {CR_TEST.CODE}=1 then false else true
    if {CR_TEST.CODE}=2 then false else true
    if {CR_TEST.CODE}=3then false else true
    if {CR_TEST.CODE}=4 then false else true
    if {CR_TEST.CODE}=5 then false else true
    my procedure is just like this;
    CREATE OR REPLACE PROCEDURE CR_TEST(
       P_MONTH IN VARCHAR2
    , P_YEAR IN VARCHAR2
    , CODE IN NUMBER
    , P_CURSOR OUT GP.REF_CURSOR
    IS
    BEGIN
       IF CODE = 1
       THEN
          OPEN P_CURSOR FOR
             SELECT A
                  , B
                  , 'X' C
                  , 'X' D
                  , 'X' E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 2
       THEN
          --A, B, E, F, G
          OPEN P_CURSOR FOR
             SELECT A
                  , B
                  , 'X' C
                  , 'X' D
                  , E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 3
       THEN
          OPEN P_CURSOR FOR
             SELECT A
                  , B
                  , C
                  , 'X' D
                  , E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 4
       THEN
          OPEN P_CURSOR FOR
             SELECT 'X' A
                  , 'X' B
                  , C
                  , 'X' D
                  , 'X' E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       ELSIF CODE = 5
       THEN
          OPEN P_CURSOR FOR
             SELECT 'X' A
                  , 'X' B
                  , 'X' C
                  , D
                  , E
                  , F
                  , G
                  , CODE CODE
               FROM CR_TEST_TABLE
                                 --WHERE conditions
       END IF;
    END;
    Edited by: assaulter on Oct 12, 2011 11:50 AM
    Edited by: assaulter on Oct 19, 2011 1:50 PM

  • Delay when typing in Safari, the first character is always missing.

    Recently when I go to type in a address or text in the search window, the first first character is always gone. Resulting in me having to back space to the beginning to re-type the first character.
    My father is a Mac user too and he experiences the same thing.
    Any suggestions?

    Hi,
    The problem you described sounds reminiscent of a problem many MacBook, MacBook Pro and even PowerBook G4 users have been experiencing. If you do a Discussions-wide search for the phrase "first key" in quotation marks, you'll get an idea of how wide-spread the problem is. Apple recently released a firmware update for the MacBook and MacBook Pros, but reports of first-key-unrecognition persists.
    While I hope your problem isn't of this variety, the point I'm trying to illustrate is that if it is, Apple has yet to pin down a proper fix for it. Until they do though, perhaps some workarounds you can try are banging on a modifier key before typing anything, or clicking twice to ensure focus has been given to a window element and not just the window.
    Yang

  • 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

  • Getting zero to display as the first character

    I know this should be simple, but I'm trying to get a zero to display as the first character in a field when necessary.  For example last 4 of SSN.  Any help would be appreciated.

    Hi,
    You can achieve this in the Patterns dialog. Select the object and go to the Object > Field palette. There you can click the Patterns button and edit the Display Pattern.
    For example, this would display a number without leading zeros: 12
    num{zzz9}
    Whereas if you use 9 it will display leading zeros: 0012
    num{9999}
    Hope that helps,
    Niall

Maybe you are looking for

  • ListBox Search with AS 2.0

    This is getting me crazy, although I know there should be a solution since I found one in Actionscript 1.0; however, I would like to use AS 2.0. I have a listbox component that loads XML labels and values successfully; I added a search field to filte

  • Firmware upgrade on Nokia 6610i

    Hi, I own a Nokia 6610i. I did *#0000# on the phone and I get this output: v 4.10 08-10-04 RM-37 Now is there a way to check if that is the latest firmware? Seems that this phone is too old for the Nokia Software Updater Some sites on the net report

  • Message: "The product distribution not could file verified"

    when I try to buy Mountain Lion appears a message: "The product distribution not could file verified. It may be damaged or not was signed" I use Lion 7.4, MabBook 2010.

  • Don't have iPhoto 9.1 for update? I already had one......

    I cannot update my iPhoto version 9.1.1 to 9.2.2 ...... It says that unless I have iPhoto 9.1 but I already had it....... Why??????Do

  • Restore w/o wall adapter!!

    4th Generation iPod (Photo) This is not my iPod... it's for a Windows user (not by choice). I want to restore it, then eventually plug it BACK into a windows machine and format it in windows and update to latest version, because he has a slow interne