Another JS query please - identifying paragraphs by length

Hi all
Based on all the new things I discovered yesterday I want to build upon on one of the code snippets and use it to identify all paragraphs up to 10 words in length and apply a "heading" paragraph style. I'm starting with
app.findGrepPreferences.findWhat = "^.+$";
myResult = app.activeDocument.findGrep ();
so myResult contains all paragraphs in the story and next I want to say something like
myHeadings = those paras whose myResult.length is between 1 and 10
but I don't know how. After that I think I know how to apply a style to the myHeadings paragraphs (myHeadings.appliedParagraphStyle="A head";).
Is this a job for a for loop to go through the contents of myResult? But if so what am I looping and how do I get the result of that into myHeadings?
thanks,
Iain

> app.findGrepPreferences.findWhat = "^.+$";
> myResult = app.activeDocument.findGrep ();
> so myResult contains all paragraphs in the story
This is not a very efficient approach. Also, it will get you all paragraphsi in the Document, not the story.
Additionaly, if you don't set the preferences, it will remember the preferences from whatever has run before, which could do almost anything...so you should always initialize them first:
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
Anyhow, the efficient way to get all the paragraphs is to use:
myResult = app.activeDocument.stories.everyItem().
               paragraphs.everyItem().getElements();
though that uses the .everyItem() syntax which is confusing to understand...
> myHeadings = those paras whose myResult.length is between 1 and 10
> but  I don't know how.
> Is  this a job for a for loop to go through the contents of myResult? But  if so what am I looping and how do I get the result of that into  myHeadings?
Yes, you're on the right track. Simply declare a looping variable, check the length of myResult.words.length, and loop over everything from 0 to myResult (minus 1, since you're starting to count at zero; if there are 2 items in myResult, myResult.length is 2 but myResult[0] and myResult[1] will be valid and myResult[2] will not).
Note that myResult.length is the length of myResult -- the number of results -- the number of paragraphs in the document. That's not what you want to check. If you want to check the number of words (as opposed to the number of characters or something else), you need to look at myResult[someNumber].words.length. Here I stick it in a variable, to avoid having to write it out twice:
var i, wordCount;
for (i=0; i<myResult.length; i++) {
  wordCount = myResult[i].words.length;
  if ((wordCount >= 1) && (wordCount <= 10)) {
    myResult[i].appliedParagraphStyle = "A head";

Similar Messages

  • How do I identify the maximum length of video in iMovie which can be made into a dvd in iDVD, please?

    How do I identify the maximum length of video in iMovie which can be made into a dvd in iDVD, please?
    I made a sellection of video clips  > pressed on "share" > on iDVD >  after one hour of formating the message was under "project duration"  : "Your project exceeds the maximum content duration. To burn your DVD, change the encoder setting in the Project Info window."
    I have edited out some of the clips and waited anothe hour or so bu the same message appeared !
    I want to know in advance how long can be the video clip sellection for the quality of video chosen ( the best before HD).
    please help if ou can.
    thank you very much indeed.
    Michael
    North London

    It's trying to tell you to change the encoding setting:
    iDVD encoding settings:
    http://docs.info.apple.com/article.html?path=iDVD/7.0/en/11417.html
    Short version:
    Best Performance is for videos of up to 60 minutes
    Best Quality is for videos of up to 120 minutes
    Professional Quality is also for up to 120 minutes but even higher quality (and takes much longer)
    That was for single-layer DVDs. Double these numbers for dual-layer DVDs.
    Professional Quality: The Professional Quality option uses advanced technology to encode your video, resulting in the best quality of video possible on your burned DVD. You can select this option regardless of your project’s duration (up to 2 hours of video for a single-layer disc and 4 hours for a double-layer disc). Because Professional Quality encoding is time-consuming (requiring about twice as much time to encode a project as the High Quality option, for example) choose it only if you are not concerned about the time taken.
    In both cases the maximum length includes titles, transitions and effects etc. Allow about 15 minutes for these.
    You can use the amount of video in your project as a rough determination of which method to choose. If your project has an hour or less of video (for a single-layer disc), choose Best Performance. If it has between 1 and 2 hours of video (for a single-layer disc), choose High Quality. If you want the best possible encoding quality for projects that are up to 2 hours (for a single-layer disc), choose Professional Quality. This option takes about twice as long as the High Quality option, so select it only if time is not an issue for you.
    Use the Capacity meter in the Project Info window (choose Project > Project Info) to determine how many minutes of video your project contains.
    NOTE: With the Best Performance setting, you can turn background encoding off by choosing Advanced > “Encode in Background.” The checkmark is removed to show it’s no longer selected. Turning off background encoding can help performance if your system seems sluggish.
    And whilst checking these settings in iDVD Preferences, make sure that the settings for NTSC/PAL and DV/DV Widescreen are also what you want.
    http://support.apple.com/kb/HT1502?viewlocale=en_US

  • Record has already been updated by another user. Please re-query and retry

    Hi,
    I want to uncheck the option Send e-mails for canceled notifications in Workflow mailer but getting error in fouth step in workflow Notification mailer:-
    1. Connect to Oracle Applications Manager with SYSADMIN.
    2. select Workflow manager.
    3. Click on EDIT button-->Advanced(Step 1)--->next(step 2)--->next(step 3)---"ERROR"
    This record has already been updated by another user. Please re-query and try again. ORA-06512: at "APPS.FND_SVC_COMP_PARAM_VALS_PKG", line 288 ORA-06512: at line 1
    Regards,

    Pl see if MOS Doc 286418.1 (ORA-06512: At Fnd_svc_comp_param_vals_pkg When Configuring The Java Mailer) can help
    HTH
    Srini

  • Please advise what is the query to identify a SQL executed time

    Hi all
    Please advise what is the query to identify a SQL executed time.
    eg, a DML executed at 16-Apr-2013 11:45hrs

    Try like..
    select LAST_LOAD_TIME, ELAPSED_TIME, MODULE, SQL_TEXT elasped from v$sql order by LAST_LOAD_TIME desc

  • How to Copy RPT of one BEX query to another Bex Query

    Hi,
    I have a Crystal Report-A1 based on one Bex Query ZABC_1. I also have another Bex Query with same output and source named ZABC_2.
    Now i want the to copy A1 to A2 and have A2 referring to ZABC_2.
    The only difference between the 2 queries is the selection option paramenters.
    Please let me know any way forward on this.
    Points will be awared for useful replies.

    Hi Rajesh J Salecha,
    What I understood is like :
    You have two queries and both gives same results but one of the query having a parameter.
    You have one report which is using query1.  Now you want that report to be copied as Report2 and use Query2 instead of Query1.
    If the this is the issue, then you copy Report1 as Report2 and go in Database and change the Data source location to Query2.
    Hope this will help you.  If my understanding is wrong then give us the work flow.
    Thanks,
    Sastry

  • Is their any function in sql to identify datatype and length of each column

    Hi
    i need to identify datatype and length of each column in a table by using SQL query.
    plz assist me reagard the same.
    thanks

    Try this:
    SELECT column_name,
           data_type,
           data_length,
           data_precision
    FROM   user_tab_columns
    WHERE  table_name = <table_name>

  • Another RAW Query

    Hi There.
    Another RAW query. I have PS CS4 Extended 11. I have tried to open RAW (NEF) pictures from my NIKON D3100. I get the error message 'Could not complete your request because it is not the right kind of document'. I have tried downloading the latest update. I currently have Camera RAW Version 5.7.0.213. I have also downloaded the DNG converter but I still get the same error. I am using Windows 7 on a laptop.
    Please help, otherwise no RAW Photography for me!
    Regards Mike.

    You need at least ACR 6.3 and you can not get there with CS4.  You either have to upgrade to CS6 or CC, or use the latest DNG converter. 

  • Query to Identify Compressed Tables?

    Is there a query to identify which tables are compressed? 
    Isn't the following query limited to just the partitioned tables that are compressed? 
          SELECT DISTINCT NAME
          FROM   sysobjects x
          WHERE  x.id IN (SELECT OBJECT_ID
                          FROM   sys.partitions
                          WHERE  data_compression <> 0)

    Hi,
    Does this query helps
    SELECT
    SCHEMA_NAME(sys.objects.schema_id) AS [SchemaName]
    ,OBJECT_NAME(sys.objects.object_id) AS [ObjectName]
    ,[rows]
    ,[data_compression_desc]
    ,[index_id] as [IndexID_on_Table]
    FROM sys.partitions
    INNER JOIN sys.objects
    ON sys.partitions.object_id = sys.objects.object_id
    WHERE data_compression > 0
    AND SCHEMA_NAME(sys.objects.schema_id) <> 'SYS'
    ORDER BY SchemaName, ObjectName
    Taken from
    Here
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • I want to bring over music from my iTunes library on iMac to an ipod touch with another apple id. please help

    I want to bring over music from my iTunes library on iMac to an ipod touch with another apple id. please help. Is this possible. In former versions of itunes this was posible. I can't find the solution is iTunes 11

    Perhaps those apps require a newer version of iOS than is compatible with your iPod.

  • How  to transfer data from one system to another by datamart please give de

    how  to transfer data from one system to another by datamart please give details

    Hi Deba,
    Find the below SAP help doc which may help u...
    http://help.sap.com/saphelp_nw70/helpdata/en/12/43074208ae2a38e10000000a1550b0/frameset.htm
    Also find the below threads...
    Loading data from one cube to another cube.
    data copy from infocube to infocube in two different BW systems
    Delta when loading from ODS to ODS
    reg datamart
    Data mart flag
    Regards,
    KK.

  • Error while updating PO - 'This document is locked by another user. Please

    All,
    While updating the PO through API (Oracle Version - 11i) we are getting the error message 'This document is locked by another user. Please try again later.' intermittently.
    We are using below API to update the PO through interface program.
    po_change_api1_s.update_po
    (x_po_number => <PO_NUMBER>,
    x_release_number => NULL,
    x_revision_number => v_revision_num,
    x_line_number => v_line_num,
    x_shipment_number => v_shipment_num,
    new_quantity => l_upd_price,
    new_price => NULL,
    new_promised_date => NULL,
    launch_approvals_flag => 'Y',
    update_source => NULL,
    VERSION => '1.0',
    x_override_date => SYSDATE,
    x_api_errors => v_api_errors,
    p_buyer_name => NULL
    Client is very keen to know the root cause of the error message, Does any has any idea ? Our concurrent program has been configured incompatibility, so one program will at a given time.
    It would be great if anyone can give me some valuable inputs to debug this error message.
    Thanks,

    Hello,
    I am also facing same issue. In my code I am updating PO lines using Update_PO API. Whenever I am trying to Update 2 Lines on same PO. One get successfully update and for second line getting same error 'This document is locked by another user.'
    Please help me for this..
    Thanks in advance.
    Thanks
    Ravi Raj.

  • Identifying the maximum length of a record in internal table

    Hi,
    Im using an internal table for a string for some requirement.
    Now, at later point of time i need to use for CHAR variable to copy the data from the above internal table.
    I need to identify the max length of the record stored in this internal table so that i can assign that much length to this CHAR variable.
    Is there any standard fm or any abap stmts.
    Thanks
    rohith

    You have to Loop the entire Itab to find the Maximum length of the record stored.
    Just like this:
    data: begin of itab occurs 0,
            v_str1 type string,
          end of itab.
    data: v_len type i.
    data: v_len1 type i.
    itab-v_str1 = 'mahesh sap abap'.
    append itab. clear itab.
    itab-v_str1 = 'mahesh'.
    append itab. clear itab.
    itab-v_str1 = 'mahesh sap'.
    append itab. clear itab.
    loop at itab.
      v_len = strlen( itab-v_str1 ).
      if v_len > v_len1.
        v_len1 = v_len.
      else.
        continue.
      endif.
      clear: v_len.
    endloop.
    write:/ 'Max Length', v_len1.

  • How to improve the performance of the attached query, Please help

    Hi,
    How to improve performance of the below query, Please help. also attached explain plan -
    SELECT Camp.Id,
    rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount,
    (SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
    rCam.AccountKey as AccountKey
    FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
    WHERE Camp.AccountKey = rCam.AccountKey
    AND Camp.AvCampaignKey = rCam.AvCampaignKey
    AND Camp.AccountKey = CamBilling.AccountKey
    AND Camp.CampaignKey = CamBilling.CampaignKey
    AND rCam.AccountKey = xSite.AccountKey
    AND rCam.AvSiteKey = xSite.AvSiteKey
    AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
    to_date('01-01-2011', 'DD-MM-YYYY')
    GROUP By rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount
    Explain Plan :-
    Description                    Object_owner          Object_name     Cost     Cardinality     Bytes     
    SELECT STATEMENT, GOAL = ALL_ROWS                              14     1     13
    SORT AGGREGATE                                                  1     13
    VIEW                         GEMINI_REPORTING               14     1     13
    HASH GROUP BY                                        14     1     103
    NESTED LOOPS                                        13     1     103
    HASH JOIN                                             12     1     85
    TABLE ACCESS BY INDEX ROWID     GEMINI_REPORTING     RCAMSIT          2     4     100
    NESTED LOOPS                                        9     5     325
    HASH JOIN                                        7     1     40
    SORT UNIQUE                                        2     1     18
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          SITE          2     1     18
    INDEX RANGE SCAN          GEMINI_PRIMARY          SITE_I0          1     1     
    TABLE ACCESS FULL          GEMINI_PRIMARY          SITE          3     27     594
    INDEX RANGE SCAN          GEMINI_REPORTING     RCAMSIT_I     1     1     5     
    TABLE ACCESS FULL     GEMINI_PRIMARY     CAMPAIGN                    3     127     2540
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          CAMBILLING     1     1     18
    INDEX UNIQUE SCAN     GEMINI_PRIMARY     CAMBILLING_U1                    0     1

    Hello,
    This has really nothing to do with the Oracle Forms product.
    Please, send the SQL or/and PL/SQL questions in the corresponding forums.
    Francois

  • Sql query to identify all the responsibilities attached to a form

    (oracle - apps) Can anyone help me by giving a sql query to identify all the responsibilities attached to a form and corresponding menu should not be in the menu exclusion.
    Thanks in advance
    Venki

    Bump

  • Suggest the query to this tricky query please

    Hi people,
    I just got a query which is a brain tease for me (not all).
    that is
    sql> select * from mytab;
    sql> no name
    1 asuri
    1 prasanth
    2 brian
    2 lara
    the above is query is returned by the sql;
    here 1 and 2 are duplicated values;
    now output required is
    sql>no name
    1 asuri prasanth
    2 brain lara
    Is this possible with a single sql query;
    please tell me solution
    regards
    prasanth

    How do find that it should be brian lara not lara brian..
    But any way the following will do ...SQL> select * from mytab;
    A NAME
    1 asuri
    1 prasanth
    2 brian
    2 lara
    SQL> select a,name||' '||name2 name from
    2 (
    3 select a,name,lead(name) over (partition by a order by a) name2 from mytab)
    4 where name2 is not null;
    A NAME
    1 asuri prasanth
    2 brian lara
    The names by above query can be returned as 'lara brian' and 'prasanth asuri' as there is no way telling which one is a surname..

Maybe you are looking for

  • My ipod touch 4th gen isn't showing up on my computer.

    I get error "usb device not recognised" (windows 7). The ipod charges but doesn't show up in My Computer and therefor doesn't show up in iTunes. Please help

  • How to make a mac managed in wgm

    Could anyone point me in the direction of a how to make a mac managed in workgroup manager, ive done it before, but i cant remember how to do it, all i can remember was that once the mac was managed it had a $ after it, then WGM can manage that macs

  • Release strategy will not be effected when reduce in amount or when item de

    Hi All, I have created the PO with three line Items out of 3 items 2 items got GR and Invoce done and 3rd is open NO GR and Invoice Whenever I delete the 3rd item ,PO is again going for release.Our Client wants that whenever Item will be deleted or P

  • Solution for the Camera Raw 8.2 update installation problem

    Hi. Adobe Camera Raw 8.2 for CC & CS6 was released two months ago. http://blogs.adobe.com/lightroomjournal/2013/09/camera-raw-8-2-and-dng-converter-8-2-now-a vailable.html But many people got problem in updating Camera Raw 8.2. I tried to inspect the

  • Quicktime doesn't switch to external audio

    Hey guys, The problem I have is with QuicktimeX on ML is it not sending any audio to my external soundcard and my external speakers. If I turn my soundcard ON then iTunes, Safari, etc. will all play audio to my external speakers (switching over prope