Search strings / with some applied condition

Hello comrades,.

I am writing an extendscript which is supposed to loop through all of the PGF and find all the strings / with a certain condition applied (say, comment).

The problem is that in the script guide, I couldn't find a function that retrieves the status of character property. I tried to use the function "charAt() (i)" js, but it doesn't seem to work in ARE. No idea how to implement such a function?

Here's the 1st draft of the script.

var doc is app. ActiveDoc;

If doc. {ObjectValid()}

checkCondFMt (doc);

}

else {}

Alert ("no open section");

}

function checkCondFMt (doc) {}

FMP var is doc. MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

var CondObj is doc. GetNamedObject ("Comment");

While (FMP. {ObjectValid()})

var textItems is bmp. GetText(Constants.FTI_String |) Constants.FTI_LineEnd);

var b = new TextRange();

TR. Beg.obj = tr.end.obj = textItems;

TR. Beg.offset = 0;

for (var i = 0; i < tr.len; i ++) {}

var c = tr.charAt (i);

var PgfProps is doc. GetTextVal c [i], Constants.FO_CondFmt;

Alert (PgfProps.Name);

}

PGF = bmp. NextPgfInFlow;

}

}

Thanks in advance for your comments!

OK, I see the problem now. JavaScript doesn't have a "block scope" for its variables. She carried the function, so your 'i' variable is used in more than a loop. You must use a different variable for the inner loop:

for (var j = 0; j < oCond.length; j += 1) {
    if (oCond[j].Name == CondObj.Name) {
        applyCharFmt(textRange, doc);
    }
}

In the code example above, I use 'j' for a counter for the inner loop.

In general, you can avoid problems of this kind to declare all your variables at the top of the function:

function functionName (param1, param2) {

    var i, j, textlist; // etc.

    // function code...
}

That makes it easier to 'follow' variables and make sure that you do not use one more than once.

-Rick

Tags: Adobe FrameMaker

Similar Questions

  • Loop through the string with multiple replaced Conditions

    I'm looking for loop through a url string to enter analysis of http:// , www.twitter.com and twitter.com.

    I thought first use this:

    < cfset form.mystring = REPLACENOCASE (form.mystring, "http://","", 'One' "")

    AND REPLACENOCASE (form.mystring, "www.twitter.com", "", 'One') >.

    I realized that this won't work of course.

    In addition, using a cfif-cfelseif you will remove in this case a a condtion, but not several condition.

    You will need to use a cfloop, I think. Any suggestions on the syntax.  Thank you

    If you can not do:

    replacelist (LCase (Form.myString), 'http://, www.twitter.com, twitter.com', ',')

    ?

  • REF Cursor with search string

    Hello all,.

    I'm trying to implement a procedure that returns records in the hr.employees table when search strings are passed.

    Here is the package:
    create or replace package search_app 
    IS
    --
    TYPE emp_rec IS RECORD (last_name     hr.employees.last_name%TYPE
                                         ,first_name    hr.employees.first_name%TYPE
                                         ,job_id        hr.employees.first_name%TYPE
                                         ,salary        hr.employees.salary%TYPE
                                         ,dept          hr.departments.department_name%TYPE
                                         );
    --
    TYPE emp_curs  IS REF CURSOR RETURN emp_rec;
    --
    PROCEDURE  get_employees (p_last_name_search   IN  hr.employees.last_name%TYPE
                                             ,p_first_name_search  IN  hr.employees.first_name%TYPE
                                             ,p_job_id_search      IN  hr.employees.job_id%TYPE
                                             ,pr_emps              OUT emp_curs
                                             ,p_error              OUT VARCHAR2
                                             );
    --
    END search_app;
    /
    --
    create or replace package body search_app
    IS
    --
    PROCEDURE get_employees (p_last_name_search    IN  hr.employees.last_name%TYPE
                                            ,p_first_name_search  IN  hr.employees.first_name%TYPE
                                            ,p_job_id_search      IN  hr.employees.job_id%TYPE
                                            ,pr_emps              OUT emp_curs
                                            ,p_error              OUT VARCHAR2
                                            )
    IS
    --
      v_last_name_search       hr.employees.last_name%TYPE;
      v_first_name_search       hr.employees.first_name%TYPE;
      v_job_id_search             VARCHAR2(100);
      v_error_msg                  VARCHAR2(200);
    --
    BEGIN
    --
      OPEN  pr_emps FOR
    --
          SELECT e.last_name
                     ,e.first_name
                     ,e.job_id
                     ,e.salary
                     ,d.department_name as dept
          FROM hr.employees    e
                  ,hr.departments d
          WHERE (e.first_name LIKE p_first_name_search
                       AND
                     --OR   
                      e.last_name  LIKE p_last_name_search
                       AND 
                    --OR  
                       e.job_id     IN   p_job_id_search
                     )
          AND    d.department_id = e.department_id;
    --
        p_error := v_error_msg;
    --
    EXCEPTION
    --
    WHEN OTHERS THEN
       v_error_msg := SUBSTR(SQLERRM,1,200);
    END get_employees;
    --
    END search_app;
    /
    sho error
    
    ---
    here is the stub I am using to test.
    --
    set serveroutput on size 1000000
    spool search_app_OR.log
    --
    DECLARE
    --
      v_first_name_search     hr.employees.first_name%TYPE;
      v_last_name_search      hr.employees.last_name%TYPE;
      v_job_id_search           VARCHAR2(100);
      my_emps                    search_app.emp_curs;
    --
      v_first_name            hr.employees.first_name%TYPE;
      v_last_name             hr.employees.last_name%TYPE;
      v_job_id                  VARCHAR2(100);
      v_salary                   hr.employees.salary%TYPE;
      v_dept_name           hr.departments.department_name%TYPE;
      v_error_msg             VARCHAR2(200);
    --
      v_count                   PLS_INTEGER;
    --
    BEGIN
    --
        v_first_name_search := '%';
        v_last_name_search  := 'De%';
    --        v_job_id_search := '%';
        v_job_id_search     := chr(40)||chr(39)||'AD_VP'||chr(39)||','||chr(39)||'SH_CLERK'||chr(39)||chr(41);
    
    --
         search_app.get_employees(p_last_name_search   => v_last_name_search
                                 ,p_first_name_search  => v_first_name_search
                                 ,p_job_id_search      => v_job_id_search
                                 ,pr_emps              => my_emps
                                 ,p_error              => v_error_msg
                                  );
    --
         LOOP
    --
            FETCH my_emps INTO v_last_name, v_first_name,v_job_id, v_salary, v_dept_name;
                EXIT when my_emps%NOTFOUND;
    --
            DBMS_OUTPUT.PUT_LINE ('...last_name : '||v_last_name);
            DBMS_OUTPUT.PUT_LINE ('...first_name: '||v_first_name);
            DBMS_OUTPUT.PUT_LINE ('...job_id    : '||v_job_id);
            DBMS_OUTPUT.PUT_LINE ('...salary    : '||v_salary);
            DBMS_OUTPUT.PUT_LINE ('...dept      : '||v_dept_name);
            DBMS_OUTPUT.PUT_LINE ('...error_msg : '||v_error_msg);
    --
         END LOOP;
    --
         v_count := my_emps%ROWCOUNT;
    --
         CLOSE my_emps;
    --
            DBMS_OUTPUT.PUT_LINE ('v_last_name_search : '||v_last_name_search);
            DBMS_OUTPUT.PUT_LINE ('v_first_name_search : '||v_first_name_search);
            DBMS_OUTPUT.PUT_LINE ('v_job_id_search       : '||v_job_id_search);
            DBMS_OUTPUT.PUT_LINE ('num rec fetched      : '||v_count);
    --
     EXCEPTION
         WHEN OTHERS THEN
           v_error_msg := SUBSTR(SQLERRM,1,200);
           DBMS_OUTPUT.PUT_LINE ('error: '||v_error_msg);
    END;
    /
    spool off
    The results I get are as follows:

    When I OR in the request for get_employees for search parameters, 106 records are returned.

    When I AND in the application, not of records returned is 0. It should return 2 records. Why is it not return all records? Any suggestion on how this procedure should be applied?

    Thank you

    Raman

    Published by: rxshah on June 8, 2010 12:52 AM

    Hello

    The problem is that you try to implement a dynamic list in a static SQL statement:

    job_id IN '(''AD_VP'',''SH_CLERK'')'
    

    It will not work like that.

    Check out these links for some tips:
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:1242571115131928:P11_QUESTION_ID:110612348061

  • There are a few problems with some of my tiles (Mail, games, music, etc.).

    Original title: Windows Mail (tile)

    Hello everyone.

    I had a few problems with some of my tiles (Mail, games, music, etc.) so I have WSReset.exe and since then I could not find one of these tiles. I searched the Store and tried to re - install, but it says that I must admit. I don't know what to do. Please help me...
    Thank you...

    Hi rap.

    Thanks for the reply with the status of the issue.

    Here in this scenario, you need to refresh your computer after the backup of your data. Refresh your PC reinstall Windows and keep your personal files and settings. It also keeps the applications provided with your PC and applications that you have installed in the Windows store.

    How to refresh, reset or restore your PC:

    http://Windows.Microsoft.com/en-us/Windows-8/restore-refresh-reset-PC

    Note: refer to the section "refresh your PC without affecting your files.

    Warning: Apps that you have installed Web sites and DVD is deleted. The applications provided with your PC and applications that you have installed in the Windows store will be resettled. Windows puts a list of apps removed on your desktop after you refresh your PC.

    If you do not have installation media, you can see the following article from Microsoft Help to create installation media.

    http://Windows.Microsoft.com/en-us/Windows-8/create-reset-refresh-media

    Note: The steps also apply to Windows 8.

    Please reply with the status of the issue, so that we can confirm that the issue is resolved.

  • Is it not possible to get (or use) a search string that includes a reference object?

    Hello world

    I try to get the full search string property for the property "xl" seen below at the bottom of the image.

    I can go as far as the other results [0] (which is a reference), but after that, it seems not possible to access the "xl".

    "TS. SequenceCall.ResultList [0]. TS. SequenceCall.ResultList [0]. TS. SequenceCall.ResultList [0]. "AdditionalResults [0].

    If I get the interface for the object of 'xl' and then ask 'place' in what concerns the "MainSequenceResults", I get an empty string.

    Get the property for container objects and properties in the object "xl" also give the same result when I call «GetLocation (...)» with the MasterSequenceResults the TopObject property.

    Is it not possible to have a search string that includes a reference object?

    Thank you

    Ronnie

    Hi Ronnie,.

    It is possible, but to get this value, you can use the TestStand API. I have attached a sequence file that shows how to get the values of reference of object using AsPropertyObject, and then the associated GetVal method. It is much easier to understand with an example. Let me know if you have any questions about the sample file of sequence.

  • Search string and shorten

    Hi all! I'm kinda new to labview, but I learn right.

    I get a response from a picoammeter in the form of a string that contains the current and then of junk that I subsequently. Every thing is separated by a comma if I want to search the string to the comma and then cut the comma and after that all keeping the data that comes before the comma. I am struggling to find a good way to do it. Someone point me in the right direction? Thank you!

    Use 'match model' in the range of string with a comma as a model, and then use the exit 'before the substring"(the top terminal) for the purpose.

  • How to concatenate strings with the lines of a text file

    Hello
    I tried concatenate strings with the lines of a text file, but something is wrong with my code and I belive is the agruments I use in the cycle for. If anyone can help me I will appreciate it very much.
    My code is:
    [code]@echo off
    the value "input=C:\Users\123\Desktop\List.txt".
    for /f "usebackq tokens = *" % in (' input % ') do)
    the value 'str1 = C:\some directory\ ".
    the value ' str2 = %% ~ F '.
    the value "str3 = .pdf".
    the value "str4 = str1% str2% str3%.
    echo.%STR4%
    ) [/ code]
    and the text file is something like:
    121122 [code]
    122233
    123344
    124455 [/ code]
    But I get only one wrong answer and I have to run it like 3 times to get a real result and it is a mistake, the first two are empty spaces and gives the third one as the last line of the text file but repeated n times, where n is the number of lines in the text file.
    Result:
    [code] C:\Users\123\Desktop>concatenate.bat
    C:\Users\123\Desktop>concatenate.bat
    C:\Users\123\Desktop>concatenate.bat
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\Users\123\Desktop>[/code]
    So if anyone has an idea about what is wrong please let me know.
    Concerning
    -Victor-

    Hi Victor,

    This forum is dedicated to the support of the Office of consumer Windows (fonts, colors, personal settings).  Since your question is about programming and usually outside the context of most of the customers, I suggest you post your question in the forums as http://msdn.microsoft.com - the Microsoft network to users will be more adapted to help you in your quest.
  • Search text with variables

    I am facing the following problem:

    I have a point I want to replace a text from him.

    Say I want to search for text "Hello everyone my friend Jonathan Foyl" and replace it with another text.

    When I use the function F_ApiFind to find the text, it does not work because the "Jonathan Foyl' is a variable Frame Maker!

    If it's a simple text then the F_ApiFind works correctly and that he finds the text.

    How can I handle this?

    All variables are defined in the catalog of documents FM. You can analyze this variable list first and assign channels (& random) unique variables. By iteration do replacements as Russ suggests. Finish with another passage which replaces the corresponding unique strings with their original variables.

  • Boolean search string limitation

    When we enter a search string more than 10 words to Boolean searching for example chicken gun to GOLD OR ask brother GOLD flooding of the housing or the curry house GOLD OR GOLD OR fish Apple GOLD dog OR bird OR duck OR the request fails. Is there a way to fix this?

    You get an error message?  Or not the query returns simply no result?

    There is a dgraph flag that controls the maximum number of terms to assess when a search is called search_max.  This default value is 10, which makes me think that she might be related to your problem.  In a standard search mode, I thought it all starts with the 11th ignored word but Boolean may behave differently.

    If you try to add a - search_max 20-your dgraph and test again, I would be curious what your results are.

    Patrick Rafferty

    http://branchbird.com

  • A search string / number fields

    Hello! What I'm trying to do is create a page to request for my users that allows them to enter a search string (var = #string #), and then click the check boxes that correspond to the values that they want to search for the string in field (var = #paramSelect #). Unfortunately I have not been able to do this job properly and was hoping that someone here might be able to help me with this. So far, I have tried the following methods:

    If paramselect is not set, or a list?
    And you know how to loop through a list?
    And you know what you want to do if it is not set?

    If you answer Yes to these three questions, which is the part that you are having problems with? Also, a list can contain a single element and still be considered a list.

  • Another site took my home page, I got the homepage of Google search now with Firefox logo, but all the tabs at the top of the page are missing

    When I downloaded Java, the Funmoods took over the home page. I have now search Google with Firefox logo as home page, but all the usual Firefox tabs (Tools, bookmarks, assistance, etc.) are missing. How can I get back them? Directions very basic if you please, we, the elderly are not very computer savvy!

    Closing Firefox, then hold down the SHIFT key and double-click the Firefox icon to open it. Click the button to Reset firefox.

  • Just recently, I receive the following error message when you try to access the web sites. I get a pop-up window indicating "Exc in ev handl: TypeError: c.location is null" then I have to click ok. There is a problem with some plugin?

    Just recently, I receive the following error message when you try to access the web sites. I use Firefox browser version 10.0.2. I get a pop-up window indicating "Exc in ev handl: TypeError: c.location is null" as the web site page is displayed in the browser winder. So, I have to click ok. Any link/website I go to what happens. There is a problem with some plugin?

    It is only a problem for the SiteAdvisor users who are still on 3.4. This problem is resolved in the latest version of SiteAdvisor, which is 3.4.1.195. Go to http://siteadvisor.com and click on download. This will fix the problem.

    Meanwhile, SiteAdvisor team will push down a JS update in the coming days 1-2 to automatically resolve this problem in version 3.4.

  • Satellite L870 - 16 c - display problems with some games

    Hello

    I bought this laptop recently and it turns out that I have problems with some games of tearing.
    But with all the games, only some of them (ex: the Triune Witcher, borderlands,...).

    So I was wondering what could be the problem?
    So far, I've heard that could be a problem of v-sync, but everything I made this topic has not changed a thing.

    Is this just a software problem or would it be a hardware problem with the graphics card?
    I plan to send my laptop for Toshiba, so I wanted to know if it was the only solution (and if it was indeed a solution).

    For more information, this is a C with an ati radeon HD 7670 L870 m graphics card - 16 (driver version: 12.10 - 130101 a - 151427E - ATI), running on 64-bit windows 8.

    Someone at - it indexes?

    Thank you

    Post edited by: Bakappoi

    What game problems do you have exactly?
    Could you be more specific?

    You said that you have some problems, but NOT with all the games.
    That is why I don't think you have a hardware problem

    In most of the games (all) cases problems are related to drivers of graphics card in my long game experience, all the questions that I had in the past were related to problems of compatibility between the driver and the game.

  • Where is the support for the iPhone with some of these issues?  It's amazing that none of the iphone Tech responded to the unanswered questions.

    Where is the support for the iPhone with some of these issues?  It's amazing that none of the iphone Tech responded to the unanswered questions.

    This is a user forum. You to read the terms of use to which you agreed to when registering, you would have been aware that the participation of Apple here is minimal.

  • Satellite Pro M10 freeze and crash with some programs

    Hello

    I have a M10 Pro Satellite...
    A few weeks ago it's freeze and crash with some programs like wmpayer, messenger... I delivered to the authorized agent and they had not detected any problems.
    Already I have formatted several times, but the problem persists.

    Any idea what this may be?

    Thank you

    Hello

    For me it looks like you might have a motherboard problem. Formatting removes the chance that it is a software problem. Try taking 1 stick of RAM and test with it. If she continues to crash, remove that stick and try it. If she does it with the two RAM then those who are ok. HARD drive is not the culprit, so now he could either be processor or MB. Find a program to measure the heat from the laptop and run some heavy programs do overheat. If the temperature goes up and then it crashes, it could just be overheating. If it continues without overheating you either have a CPU or MB problem. I hope this helps.

Maybe you are looking for