Most elegant way to accept a variable number of files?

I am writing a program where I would like to accept a variable number of files to process. In my inexperience with LabVIEW I can think of several ways to do this, which aren't as user friendly as I'd like it to be.
I tried an array of file path controls. This will be the easiest to implement, but what I don't like is that you can't really see all the files you've inputted at once and if you select a file and want to erase it, it will query you for a file.
I tried a while loop with an empty file path to my Read Characters from File.vi, but I would like it so that the user can just specify which files they'd like to load without having to wait inbetween. Also, as I mentioned before, I would prefer it if the use
r could see which files they've decided to load and have the option of taking a file out if they should so choose.
I could try just fixing the number of files and have like 5 or so file path controls and do it like that. That seems like it would be clumsy and obviously has the problem of not being variable.
I'm just wondering if there is something that I haven't thought of, or if I have and which avenue would be the best. I feel fine about using an array of file path indicators, but wonder how I can remove indicies that are empty.

Dan, use the special path constant called "Temporary Directory".
Another problem is the fact that you hardwire the path as a string ("c:\temp\...") instead of a path constant. This will make the code useless on any platform except windows.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • Disable or suppress List output: Most elegant way?

    Hi Experts,
    Initial SItuation in Short:
    I have modified the Standard Report RPCEDTX0 to our specifications for outputting an XML Stream (which is later processed to a PDF-Payslip). The Standard SAP List is not modified (also a specification) and is outputted normally. For our ESS scenario class CL_HRXSS_REM Method L_PRODUCE_FORM has been modified --> replaced BAPI_GET_PAYSLIP with a customer Function Module which SUBMITS the reactivates the Conversion to PDF and returns it to the Method L_PRODUCE_FORM.
    My "Problem" is:
    In my Customer Function Module, the Report RPCEDTX0 is submitted and generates its standard list which must not happen here; because there won't be any user interaction. I figured I could use submit as per
    SUBMIT rpcedtd0 USING SELECTION-SET lv_var_name
                        WITH SELECTION-TABLE lt_rspar
                        EXPORTING LIST TO MEMORY
                        AND RETURN.
    or as per
    SUBMIT rpcedtd0 USING SELECTION-SET lv_var_name
                        WITH SELECTION-TABLE lt_rspar
                        TO SAP-SPOOL
                         WITHOUT SPOOL DYNPRO
                        AND RETURN.
    to evade getting the standard list displayed. But I wonder if it is a problem if I spam the Memory like that or created thousands of spools which I don't need/want, so..
    Which is the most elegant way to let that standard List disappear via the "Submit" statement?
    regards,
    Lukas

    Thanks for the quick answer,
    I kind of thought so as well. But I'm a little afraid of the memory used, because the pdf I'm creating is the PDF for the ESS-Payslip. Once a months about 25.000 people will say "Oh Jolly, let's have a look at my payslip shall we"; meaning 25.000 times export into memory, probably on the same day/in the same hour in a worst case scenario.
    Would there be a way to pointedly delete/free the allocated space of the abap memory?
    Regards,
    Lukas

  • Most elegant way to get difference between two tables - not minus!!!

    Hi,
    Simplified example of what I am trying to achieve - I have two tables ORIGINAL and REVISED.
    My desired result is to compare the two, such that; -
    Where data exists in both tables I get the difference between the Budget column, and if there is no difference then I want no rows.
    Where data exists in ORIGINAL but not in revised I want the inverse of the current value of the Budget column.
    Where data exists in REVISED I want the value from REVISED.
    I can see how I can do this, cf below, but is there a more elegant solution??
    Data for table ORIGINAL
    select '801040' entity, '2186' expense_type, 234000 budget
    from dual
    union all
    select '801040' entity, '3001' expense_type, 1000 budget
    from dual
    union all
    select '801040' entity, 'P132' expense_type, 34000 budget
    from dual
    union all
    select '801040' entity, 'P135' expense_type, 43000 budget
    from dualData for table REVISED
    select '801040' entity, '2186' expense_type, 235000 budget
    from dual
    union all
    select '801040' entity, 'P132' expense_type, 34000 budget
    from dual
    union all
    select '801040' entity, 'P139' expense_type, 56000 budget
    from dualDesired output
    ENTITY EXPENSE_TYPE DIFFERENCE
    801040 2186 1000
    801040 3001 -1000
    801040 P135 -43000
    801040 P139 56000
    5 rows selected.
    Current code to achieve this, is there a better way??
    select original.entity
    ,      original.expense_type
    ,       (nvl(revised.budget,0) - original.budget) as difference
    from   original
    ,      revised
    where  original.entity = revised.entity(+)
    and    original.expense_type = revised.expense_type(+)
    and   (nvl(revised.budget,0) - original.budget) != 0
    union all
    select  revised.entity
    ,       revised.expense_type
    ,       revised.budget as difference
    from   revised
    where  not exists
    (select 'x'
    from   original
    where  original.entity = revised.entity
    and    original.expense_type = revised.expense_type)
    and    revised.budget != 0Many thanks for your input,
    Robert.
    Edited by: Robert Angel on 17-Jan-2012 03:31 to change not equals to != - thanks for heads up

    Use full outer join:
    with original as (
                      select '801040' entity, '2186' expense_type, 234000 budget from dual union all
                      select '801040' entity, '3001' expense_type, 1000 budget from dual union all
                      select '801040' entity, 'P132' expense_type, 34000 budget from dual union all
                      select '801040' entity, 'P135' expense_type, 43000 budget from dual
          revised as (
                      select '801040' entity, '2186' expense_type, 235000 budget from dual union all
                      select '801040' entity, 'P132' expense_type, 34000 budget from dual union all
                      select '801040' entity, 'P139' expense_type, 56000 budget from dual
    select  nvl(o.entity,r.entity) entity,
            nvl(o.expense_type,r.expense_type) expense_type,
            nvl(r.budget,0) - nvl(o.budget,0) budget
      from      original o
            full join
                revised r
              on (
                      r.entity = o.entity
                  and
                      r.expense_type = o.expense_type
      where nvl(r.budget,0) - nvl(o.budget,0) != 0
    ENTITY     EXPE         BUDGET
    801040     2186           1000
    801040     3001          -1000
    801040     P135         -43000
    801040     P139          56000
    SQL> SY.

  • Variable number of arguments in C functions

    Hello. I know how to achieve creating a function that accepts a variable number of arguments. For example:
    #include <stdio.h>
    #include <stdarg.h>
    int add (int x, ...);
    int main (int argc, const char * argv[])
    int result = add(3, 5, 3, 7);
    printf("%d", result);
    return 0;
    int add (int x, ...)
    va_list argList;
    va_start(argList, x);
    int sum = 0;
    int i;
    for (i = 0; i < x; ++i)
    sum += va_arg(argList, int);
    va_end(argList);
    return sum;
    The first argument, x, is sent to the function and represents how many additional optional arguments will be sent to the function (3 in the above example). Then, the definition of the add function totals those remaining (3) arguments, returning a value of (in this case) 15, which main then prints to the console. Simple enough, but here's my question:
    What if I want to achieve this same optional arguments concept without having to send the function the number of optional arguments it will be accepting. For example, the printf() function takes an optional number of arguments, and nowhere there do you have to specify an extra argument that represents the number of additional optional arguments being passed (unless maybe the number of formatting specifiers in the first argument determines this number). Can this be done? Does anyone have any input here? Thanks in advance.

    Hi Tron -
    I looked over my first response again, and it needs to be corrected. Fortunately Bob and Hansz straightened everything out nicely, but I still need to fix my post:
    RayNewbie wrote:
    Yes, the macros are designed to walk a list of args when neither the number of args or their type is known.
    The above should have said. "The macros are designed to walk a list of args when neither the number of args or their type is known _at compile time_".
    If I may both paraphrase and focus your original question, I think you wanted to know if there was any way the function could run without knowing the number of args to expect. The answer to this question is "No". In fact at runtime, the function must know both the number of args and the type of each.
    Tron55555 wrote:
    ... the printf() function takes an optional number of arguments, and nowhere there do you have to specify an extra argument that represents the number of additional optional arguments being passed (unless maybe the number of formatting specifiers in the first argument determines this number).
    As both Bob and Hansz have explained, the underlined statement is correct. Similarly, the example from the manual gives the number and types of the args in the first string arg.
    Hansz also included an alternative to an explicit count or format string, which is to terminate the arg list with some pre-specified value (this is sometimes called a "sentinel" value. However when using a sentinel, the called function must know the data types. For example, you could never simply terminate the args with a sentinel and then pass a double followed by an int. The combined length of these args is 8 + 4 => 12 bytes, so unless the function knew which type was first at compile time, it wouldn't be possible to determine whether the list was 4+8 or 8+4 at runtime.
    If you're interested in knowing why a variable arg function is limited in this way, or in fact how any C function finds its args, its parameters, and how to return to the calling function, you might want to do some reading about the "stack frame". You can learn the concept without getting into any assembler code. Here's an article that might be good to start with: [http://en.citizendium.org/wiki/Stack_frame].
    After you have some familiarity with the stack frame, take a look at the expansions of the stdarg macros and see if you can figure out how they work, especially how va_arg walks down the stack, and what info is required for a successful trip. Actually, I don't think you can find these expansions in the stdarg.h file for Darwin; it looks like the #defines point to built-in implementations, so here are some typical, but simplified defs:
    // these macros aren't usable; necessary type casts have been removed for clarity
    typedef va_list char*;
    #define va_start(ap,arg1) ap = &arg1 + sizeof(arg1)
    #define va_arg(ap,type) *(ap += sizeof(type))
    #define va_end(ap) 0
    Note that I"m trusting you not to start asking questions about the stack or the above macros until you've studied how a stack works and how the C stack frame works in particular.
    - Ray

  • More simple way for creating dummy variables

    I am finding for more simple way for creating dummy variables.
    For analyzing by linear regression, logistic regression ... creating dummy variables from categorical data is necessary.
    Most simplest way for creating dummy variables is may be pivot function.
    But I need more simple method.
    Anyone's idea. I welcome.
    Naoya Ikeda

    Hi Naoya. Can you give an example of a sample input and output, with a description of what you'd like to do?
    Thanks,
    Ehren

  • Most reliable way to link to a Quicktime file in HTML

    What’s the best / most reliable way to link to a Quicktime.mov file in HTML (via Dreamweaver). Taking into account different browsers and operating systems PC & Mac.
    I want to use a text and/or image to link to the QT file, what’s the best way to do it, a QK player pop-up; or a new window?
    Thanks!
    imac G4   Mac OS X (10.3.9)  

    In all the years in using Dreamweaver. I have never used the embed code generated by by Dreamweaver. The coding not complete and I feel better writing my own. Untill a few years ago I found this neat little program that write a fairly complete code.
    PAGEot...and it free. It not only writes the emebed code but it can write the javascript code for IE7 (for Windows). Plus it does a lot of other neat things that you do with Quicktime...play lists, poster frames to name a few.
    http://www.qtbridge.com/pageot/pageot.html
    You can either use the html page it makes or just copy and paste the embed code into you own html...
    The coding it makes is compliant with most major browsers. either PC or Mac.

  • Opening unknown number of files

    Does labView have the ability to open a variable number of files?
    If so how would i go about doing this?

    pardon my ignorance... and do WHAT with these files? where does it get the file paths?  I mean after all, lay a file open within a for loop.  wire your number of files to the N terminal.  Then, knowing nothing else... it will prompt the user N number of times to select a file... You will then have opened N file references and have an array of references, if you wire the reference numbers to the edge of your while loop.  Does that accomplish your task?
     I really would like to help, but you have given no information to work with, to allow us to help you. If we knew what your intended functionality is, then we can suggest specific implementations to meet your needs... Otherwise this thread is quickly going to be 30 posts long, frustrating you with no answers and Us, cause we have no idea what you are trying to do.
    Message Edited by Stradis on 08-21-2007 11:39 PM
    Paul <--Always Learning!!!
    sense and simplicity.
    Browse my sample VIs?

  • Can I install the online version rather than using my dvd? it successfully installed (up to a point) that way, it just wont accept my serial number for some reason. my dvd isnt working properly.

    Can I install the online version rather than using my dvd? it successfully installed (up to a point) that way, it just wont accept my serial number for some reason. my dvd isnt working properly.

    If it gets far enough to reject your serial number, it won't help to download it. It must have installed ok.
    What is the message you get (DON'T tell us the serial number!!)?
    Does it mention a "qualifying product" by any chance?

  • Possible to do variable number of REPLACE in SQL?

    Hello. Using Oracle 10G, R2
    Wondering if it is possible to do a variable number of REPLACE() entirely in SQL in a view.
    input_table.text_column = This (b)is(/b) some (i)text(/i) with (u)formatting(/u) codes
    Note: Using ( and ) to represent < and >
    rows in format_codes_table:
    (b)
    (/b)
    (i)
    (/i)
    (u)
    (/u)
    (p)
    (/p)
    etc. (The number of format_codes is not fixed)
    Desired output: This is some text with formatting codes
    This could be done with a user-defined function and then use that function in a SQL:
    create or replace function remove_format_codes(input_p IN varchar2)
    return varchar2
       v_output   varchar2(2000);
    is
    begin
       v_output := input_p;
       for r1 in (select format_code from format_codes_table)
       loop
          v_output := replace(v_output, r1.format_code);
       end loop;
       return v_output;
    end;
    create or replace view unformatted_output_vw
    as
    select remove_format_codes(input_table.text_column) as unformatted_output
    from input_table
    /I tried this SQL:
    select replace(input_table.text_column, format_codes_table.format_code) as unformatted_output
    from input_table
        ,format_codes_table
    /But it only replaces one format code at a time, and it is not recursive so the output is like this:
    This is(/b) some (i)text(/i) with (u)formatting(/u) codes
    This (b)is some (i)text(/i) with (u)formatting(/u) codes
    This (b)is(/b) some text(/i) with (u)formatting(/u) codes
    This (b)is(/b) some (i)text with (u)formatting(/u) codes
    etc.
    I've google'd Oracle recursive sql, looked at CONNECT BY, LEAD, LAG, MODEL, and I've also looked at a
    Tom Kyte example for varying in lists (http://tkyte.blogspot.com/2006/06/varying-in-lists.html),
    but I can't seem to find a way to replicate the loop in my user-defined function in SQL.
    Anyone think this is possible in SQL? If yes, any hints?
    Thanks

    Hi,
    Regular expressions (introduced in Oracle 10) are great for this:
    SELECT     REGEXP_REPLACE ( text_column
                     , '&lt;'          || -- left angle-bracket
                       '/?'          || -- optional slash
                    '[bipu]'     || -- any one of these characters
                    '>'             -- right angle-bracket
                     )      AS no_tag_text
    FROM    input_table
    ;You had some good ideas: recursive subqueries (new in Oracle 11.2), CONNECT BY and MODEL could also do this job, but not nearly as easily.
    In case you're interested, the following thread uses MODEL to do nested REPLACEs:
    SQL Query
    Edited by: Frank Kulash on May 13, 2010 4:08 PM
    Edited by: Frank Kulash on May 17, 2010 1:02 PM
    Fixed link

  • IPod touch - more elegant way to sync to a new library?

    I recently had to change the motherboard in my machine, and took the opportunity to upgrade the machine and put on a fresh install of the OS.  I had expected my iPod touch to work like every other device I've had and just sync with a new install of iTunes (ie pull everything off the device and onto the host machine and be up and running without further action required), but unfortunately it gives me an error saying:
    This iPod "..." is synced with another iTunes library.  Do you want to erase this iPod and sync with this iTunes library?
    When I click cancel it lets me do most of what I'd like, but unfortunately it won't let me do a firmware update (from 4.3.4 to 5.1.1) as it says that:
    There are purchased items on the iPod "..." that have not been transferred to your iTunes library...
    I have done a backup of the device successfully, so I'm guessing that I can say yes to the 'erase the iPod' prompt and then just restore it when complete, but before I do that I want to be 100% sure that this process will back everything on the device up (ie after the process will the device function identically to what it is doing now).  Unfortunately the backup process just completes without providing any details, so I have no way to verify that and would appreciate more detail on this front (or if it will restore the link to the old iTunes library as well, at which point I will have just wasted my time)?  As such, I havn't been confident enough in this process to go about risking the erasure.
    The other thing I am wondering is whether the syncrhonization process and/or backup functionality store system level settings as well or just the data?  For instance, entering my WPA2 key was a royal PITA when I first got the device as the UI isn't really well designed to handle long, cryptic encryption keys (no way to show the characters as you enter it (ie can't double check it before clicking okay), no way to paste it from an email, etc.) and I don't particularly want to go through that process again.
    Ideally, I'd like to find a more elegant way around this (ie I'd really like to avoid having to wipe the device) as this is kind of a ridiculous process to have to go through for such a simple task.  If it helps, I still have all of the old files (the new OS and iTunes were installed on a new HDD, so the old iTunes folder/data is still on the old HDD (can't boot to it on the new hardware, but Ican access the raw files)) so if there is some way to convince iTunes to just load up those files and be done with it I'd be very appreciative.

    You need to:
    Transfer iTunes purchases by:
    http://support.apple.com/kb/HT1848?viewlocale=en_USiTunes Store: Transferring purchases from your iOS device or iPod to a computer
    - Transfer othre music by using a third-party program like one of those discussed here:
    Copy music
    - To retain app data and other information, connect the iPod to yur computer and make a backup by right clciking on the iPod under Devices in iTunes and select Back Up
    - Restore the iPod from that backup
    Note that the Backup that iTunes makes does not include synced media like apps and music.

  • UiXML tables - variable number of columns?

    I'm trying to define a <table> in a UIX page which will be generated from a set of parameters. This set of parameters will result in a varying number of columns so I'm looking at providing a DataObjectList which has DataObjects with keys for each of the columns attributes (header text, name of control, value of control etc.). I want to do something similar to <contents data:childData=...> on the <table> contents but this doesn't seem to work. It seems that <table> needs you to know how many columns will be present - is that so or is there some way I can do this?
    Cheers
    Ian

    Ian,
    That is correct, the uiMXL <table> element cannot currently support
    a variable number of columns (using something akin to the
    childData support in other contexts). But there are two approaches
    to get what you want.
    If you know the range of possible columns, then you can add a <column>
    element for each possible column in the <table>'s contents and then
    databind the rendered flag of the column element to hide/show the
    column as necessary.
    However, the real solution to your scenario, where the number of columns
    is completely unknown when you're designing the page, is our canonical
    example of a time you should write Java code for a portion of your page.
    Specifically, you can use the XML <include> element to refer to a
    DataProvider that will programatically create a TableBean. This
    technique is discussed in the Dynamic Structure for UIX pages
    portion of the UIX Developer's Guide.

  • Procedure with variable number of columns

    Hi, I have a procedure that looks like this:
    PROCEDURE PROC(p_cursor OUT sys_refcursor)
    And in the procedure, I build up QUERY dynamically and the number of columns varies at runtime.
    At the end I do
    OPEN p_cursor for QUERY
    Then to call this, I'm doing
    call PROC(?)
    My question is, how would I go about running the query from this procedure, then adding rows or modifying the existing results, then returning the modified data?
    What I want to do is add a new row based on some condition, so I still need to return a variable number of columns, but I need to modify the results before I return them.
    Is there any way of doing this? I need to do some calculations on the columns (the variable columns), create a new row, insert into result set, and return this new result set.

    A sys_refcursor is ideally suited to pass back to a front end gui like .NET or Java which can then use that cursor to retrieve the data.
    In PL/SQL there is no point in using a sys_refcursor unless you know, at design/compile time what the returned columns are going to be.
    If the resultant columns are dynamic, then you have no choice but to use the DBMS_SQL package, where you can parse and execute any SQL statement you like and then use the DBMS_SQL package to describe what the resultant columns are and how many there are. From that you can reference the columns by position rather than by name.
    e.g.
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_rowcount  NUMBER := 0;
    BEGIN
      -- create a cursor
      c := DBMS_SQL.OPEN_CURSOR;
      -- parse the SQL statement into the cursor
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      -- execute the cursor
      d := DBMS_SQL.EXECUTE(c);
      -- Describe the columns returned by the SQL statement
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      -- Bind local return variables to the various columns based on their types
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);      -- Number
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);     -- Date
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);  -- Any other type return as varchar2
        END CASE;
      END LOOP;
      -- Display what columns are being returned...
      DBMS_OUTPUT.PUT_LINE('-- Columns --');
      FOR j in 1..col_cnt
      LOOP
        DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
                                                                                  when 2 then 'NUMBER'
                                                                                  when 12 then 'DATE'
                                                         else 'Other' end);
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('-------------');
      -- This part outputs the DATA
      LOOP
        -- Fetch a row of data through the cursor
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        -- Exit when no more rows
        EXIT WHEN v_ret = 0;
        v_rowcount := v_rowcount + 1;
        DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
        DBMS_OUTPUT.PUT_LINE('--------------');
        -- Fetch the value of each column from the row
        FOR j in 1..col_cnt
        LOOP
          -- Fetch each column into the correct data type based on the description of the column
          CASE rec_tab(j).col_type
            WHEN 1  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
            WHEN 2  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
          END CASE;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('--------------');
      END LOOP;
      -- Close the cursor now we have finished with it
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    DEPTNO - NUMBER
    SAL - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    DEPTNO : 10
    SAL : 2450
    Row: 2
    EMPNO : 7839
    ENAME : KING
    DEPTNO : 10
    SAL : 5000
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    DEPTNO : 10
    SAL : 1300
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    JOB - VARCHAR2
    MGR - NUMBER
    HIREDATE - DATE
    SAL - NUMBER
    COMM - NUMBER
    DEPTNO - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    JOB : MANAGER
    MGR : 7839
    HIREDATE : 09/06/1981 00:00:00
    SAL : 2450
    COMM :
    DEPTNO : 10
    Row: 2
    EMPNO : 7839
    ENAME : KING
    JOB : PRESIDENT
    MGR :
    HIREDATE : 17/11/1981 00:00:00
    SAL : 5000
    COMM :
    DEPTNO : 10
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    JOB : CLERK
    MGR : 7782
    HIREDATE : 23/01/1982 00:00:00
    SAL : 1300
    COMM :
    DEPTNO : 10
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from dept where deptno = 10');
    -- Columns --
    DEPTNO - NUMBER
    DNAME - VARCHAR2
    LOC - VARCHAR2
    Row: 1
    DEPTNO : 10
    DNAME : ACCOUNTING
    LOC : NEW YORK
    PL/SQL procedure successfully completed.
    SQL>In 11g, you can create a sys_refcursor and then the DBMS_SQL package allows you to convert that refcursor into a DBMS_SQL cursor so that you can get the description of the results and do the same. This isn't available prior to 11g though.
    However_ before any of that, you should really ask yourself if there is a real need to dynamically be creating queries. There is rarely any real need to do that and if you're finding it's common in your application then this is often a sign of poor design or poorly defined business requirements (leaving the technical side to try and be "flexible" and hence leading to unmaintainable code etc.).

  • Possible to use process substitution a variable number of times?

    Hello Archers,
    I have a script like so:
    #! /bin/bash
    ( readlink /proc/$$/fd/0 | grep -q "^pipe:" ) || ( file $(readlink /proc/$$/fd/0) | grep -q "character special" )
    cat | tee >(awk 'NR % 2 == 0') >(awk '(NR+1) % 2 == 0')
    Well, it's pretty trivial at the moment, but the underlying goal is to split the input, so it can be processed in parallel on multiple cores. If I understand correctly, the above code will split the input across exactly two cores. Does there exist some way to put the process substitution (i.e. ">(awk ' ... ')")  in a loop?
    Before trying to increase the number of cores, I first tried to see whether I could loop just two times with,
    cat | tee $(for i in 1 2; do >(awk -vn="$i" '(NR + $n) % 2 == 0'); done)
    but that didn't work.
    It also occurred to me that maybe I'm presenting an X-Y problem. I did also consider using the split command, but as far as I can tell, it will only dump its output to files; it's no good for piping or process substitution. Any other ideas that would avoid needing to tee across a variable number of process substitutions?
    Naturally, I tried a little Googlemancy, but only came up with answers to newbie questions, or tutorials aimed at newbies.
    Thank you for your consideration.
    Last edited by /dev/zero (2012-03-26 07:16:25)

    Or if you want to avoid named pipes, since during development they tend to create lots of files, and the script has to clean them up afterwards, take a look at the 'coproc' feature bash has since version 4
    Though, remember that 'man bash' under BUGS says, there may only be one active coproc at a time.
    According to this it's not really such a big deal though.
    And it won't kill the started coprocesses or anything if you start another process...
    Here's a sample session: (the spaces are important btw. )
    wry:~/ $ bash [19:02:43]
    wry@blubmb:~$ coproc c1 ( cat )
    [1] 4129
    wry@blubmb:~$ coproc c2 ( cat )
    bash: warning: execute_coproc: coproc [4129:c1] still exists
    [2] 4130
    wry@blubmb:~$ echo $c1_PID $c2_PID -- ${c1[@]} ${c2[@]}
    4129 4130 -- 63 60 62 58
    wry@blubmb:~$ echo aaac1 >&${c1[1]}
    wry@blubmb:~$ echo bbbc2 >&${c2[1]}
    wry@blubmb:~$ read -u ${c1[0]} line1
    wry@blubmb:~$ read -u ${c2[0]} line2
    wry@blubmb:~$ echo $line1 and $line2
    aaac1 and bbbc2
    wry@blubmb:~$ kill $c1_PID $c2_PID
    wry@blubmb:~$
    [1]- Terminated coproc c1 ( cat )
    [2]+ Terminated coproc c2 ( cat )
    wry@blubmb:~$ exit
    exit
    Just keep in mind that the filedescriptors you get for a coproc won't be available in subshells you execute with &
    Eg. you cannot do
    coproc X
    ( use X ) &
    Links: http://wiki.bash-hackers.org/syntax/keywords/coproc

  • Variable number of data sets in multiplot

    I would like to be able to overlay sets of spectra to compare intensity variations. I am familiar with the multiplot usage, but my question involves how to allow a variable number of data sets to be overlayed. I have a vi that plots a spectrum after the user presses a "load file" button. I would like to add a boolean that when true would continue to stack spectra on the existing plot, and when false would just plot an individual spectrum each time. How can I accomodate a variable number of data sets in the multiplot?

    Assuming you're using the X-Y graph (the word "multiplot" means little to
    me) then each dataset is a cluster of the X array and Y array for that
    dataset. To put several datasets on the graph you make an array of these
    clusters. This should be very clear in the context help for the X-Y plot
    terminal.
    To add spectra you simply append it to the array of spectra already in the
    plot. The brute force and simplest to understand approach would be to use a
    local to retrieve all the data that's currently in the plot as an array,
    append the new plot to the end and write it all back to the plot, either to
    its terminal or via another local. More elegant would be to buffer your
    array of plots internally within the program and have an array of Booleans
    allowing you to selectiv
    ely show/hide plots, either by omitting datasets
    when writing them to the graph or, to maintain consistency in plot styles,
    writing an empty element to the array in place of hidden datasets, but if
    this is meaningless to you then the first suggestion is perfectly adequate.
    jeffrz wrote in message
    news:101-50650000000800000050150000-982303670000@q​uiq.com...
    > I would like to be able to overlay sets of spectra to compare
    > intensity variations. I am familiar with the multiplot usage, but my
    > question involves how to allow a variable number of data sets to be
    > overlayed. I have a vi that plots a spectrum after the user presses a
    > "load file" button. I would like to add a boolean that when true would
    > continue to stack spectra on the existing plot, and when false would
    > just plot an individual spectrum each time. How can I accomodate a
    > variable number of data sets in the multiplot?

  • Most efficient way to do some string manipulation

    Greetings,
    I need to cleanse some data in a string by replacing unsafe characters with encoded equivalents. (FYI, this is for the purpose of transforming "unsafe" characters into encoded values as data inside an XML document).
    The following code accomplishes the task:
    Note that a string "currentValue" contains the data to be cleansed.
    A string, "encodedValue" contains the result.
      for (counter = 0; counter < currentValue.length(); counter++)
        addChar = (currentValue.substring(counter,counter+1));
        if (addChar.equals("<"))
          addChar = "#60;";
        if (addChar.equals(">"))
          addChar = "#62;";
        if (addChar.equals("="))
          addChar = "#61;";
        if (addChar.equals("\""))
          addChar = "#34;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("/"))
          addChar = "#47;";
        if (addChar.equals("\\"))
          addChar = "#92;";
        encodedValue += addChar;
      } // forI'm sure there is a way to make this more efficient. I'm not exactly "new" to java, but I am learning on my own with no formal training and often take a "brute force" approach with my initial effort.
    What would be the most efficient way to re-do the above?
    TIA,
    --Paul Galvin
    Integrated Systems & Services Group

    im a c++ programmer so im not totally up on these java classes either but...from a c++ stand point you might want to consider using the if else statment.
    by using if else, you only test the character until you find the actual "violating" character and skip the rest of the tests.
    also, you might trying using something to check for alphaNumeric cases first and use the continue keyword when you find one. since more of your characters are probably safe than unsafe you can skip all the ifs/if else statement and only do one test on the good characters. (i just looked for a way to test that and i didnt find one. c++ has a function that does that by checking the ascii number range. dont think that works in java. but maybe you can find one, it would reduce the number of tests probably.)
    happy hunting,
    txjump :)

Maybe you are looking for