Multiple return values (Bug-ID 4222792)

I had exactly the same request for the same 3 reasons: strong type safety and code correctness verification at compile-time, code readability and ease of mantenance, performance.
Here is what Sun replied to me:
Autoboxing and varargs are provided as part of
JSRs 14 and 201
http://jcp.org/en/jsr/detail?id=14
http://jcp.org/en/jsr/detail?id=201
See also:
http://forum.java.sun.com/forum.jsp?forum=316
http://developer.java.sun.com/developer/earlyAccess/adding_generics/index.html
Multiple return values is covered by Bug-ID 4222792
Typically this is done by returning an array.
http://developer.java.sun.com/developer/bugParade/bugs/4222792.html
That's exactly the problem: we dynamically create instances of array objects that would better fit well within the operand stack without stressing the garbage collector with temporary Array object instances (and with their backing store: 2 separate allocations that need to be recycled when it is clearly a pollution that the operand stack would clean up more efficiently)
If you would like to engage in a discussion with the Java Language developers, the Generics forum would be a better place:
http://forum.java.sun.com/forum.jsp?forum=316
I know that (my report was already refering to the JSR for language extension) Generics is not what I was refering to (even if a generic could handle multiple return values, it would still be an allocated Object
instance to pack them, i.e. just less convenient than using a static class for type safety.
The most common case of multiple return values involve values that have known static datatypes and that should be checked with strong typesafety.
The simple case that involves returning two ints then will require at least two object instances and will not solve the garbage collection overhead.
Using a array of variable objects is exactly similar, except that it requires two instances for the components and one instance for the generic array container. Using extra method parameters with Integer, Byte, ... boxing objects is more efficient, but for now the only practical solution (which causes the least pollution in the VM allocator and garbage collector) is to use a custom class to store the return values in a single instance.
This is not natural, and needlessly complexifies many interfaces.
So to avoid this pollution, some solutions are used such as packing two ints into a long and returning a long, depacking the long after return (not quite clean but still much faster at run-time for methods that need to be used with high frequencies within the application. In some case, the only way to cut down the overhead is to inline methods within the caller code, and this does not help code maintenance by splitting the implementation into small methods (something that C++ can do very easily, both because it supports native types parameters by reference, and because it also supports inline methods).
Finally, suppose we don't want to use tricky code, difficult to maintain, then we'll have to use boxing Object types to allow passing arguments by reference. Shamely boxed native types cannot be allocated on the operand stack as local variables, so we need to instanciate these local variables before call, and we loose the capacity to track the cases where these local variables are not really initialized by an effective call to the method that will assign them. This does not help debugging, and is against the concept of a strongly typed language like Java should be:
Java makes lots of efforts to track uninitialized variables, but has no way to determine if an already instanciated Object instance refered in a local variable has effectively received an effective assignment because only the instanciation is kept. A typical code will then need to be written like this:
Integer a = null;
Integer b = null;
if (some condition) {
//call.method(a, b, 0, 1, "dummy input arg");
// the method is supposed to have assigned a value to a and b,
// but can't if a and b have not been instanciated, so we perform:
call.method(a = new Integer(), b = new Integer(), 0, 1, "dummy input
arg");
// we must suppose that the method has modified (not initialized!)
the value
// of a and b instances.
now.use(a.value(), b.value())
// are we sure here that a and b have received a value????
// the code may be detected at run-time (a null exception)
// or completely undetected (the method() above was called but it
// forgot to assign a value to its referenced objects a and b, in which
// case we are calling in fact: now.use(0, 0); with the default values
// or a and b, assigned when they were instanciated)
Very tricky... Hard to debug. It would be much simpler if we just used:
int a;
int b;
if (some condition) {
(a, b) = call.method(0, 1, "dummy input arg");
now.use(a, b);
The compiler would immediately detect the case where a and b are in fact not always initialized (possible use bere initialization), and the first invoked call.method() would not have to check if its arguments are not null, it would not compile if it forgets to return two values in some code path...
There's no need to provide extra boxing objects in the source as well as at run-time, and there's no stress added to the VM allocator or garbage collector simply because return values are only allocated on the perand stack by the caller, directly instanciated within the callee which MUST (checked at compile-time) create such instances by using the return statement to instanciate them, and the caller now just needs to use directly the variables which were referenced before call (here a and b). Clean and mean. And it allows strong typechecking as well (so this is a real help for programmers.
Note that the signature of the method() above is:
class call {
(int, int) method(int, int, String) { ... }
id est:
class "call", member name "method", member type "(IILjava.lang.string;)II"
This last signature means that the method can only be called by returning the value into a pair of variables of type int, or using the return value as a pair of actual arguments for another method call such as:
call.method(call.method("dummy input arg"), "other dummy input arg")
This is strongly typed and convenient to write and debug and very efficient at run-time...

Can anyone give me some real-world examples where
multiple return values aren't better captured in a
class that logically groups those values? I can of
course give hundreds of examples for why it's better
to capture method arguments as multiple values instead
of as one "logical object", but whenever I've hankered
for multiple return values, I end up rethinking my
strategy and rewriting my code to be better Object
Oriented.I'd personally say you're usually right. There's almost always a O-O way of avoiding the situation.
Sometimes though, you really do just want to return "two ints" from a function. There's no logical object you can think of to put them in. So you end up polluting the namespace:
public class MyUsefulClass {
public TwoInts calculateSomething(int a, int b, int c) {
public static class TwoInts {
    //now, do I use two public int fields here, making it
    //in essence a struct?
   //or do I make my two ints private & final, which
   //requires a constructor & two getters?
  //and while I'm at it, is it worth implementing
  //equals(), how about hashCode()? clone()?
  //readResolve() ?
}The answer to most of the questions for something as simple as "TwoInts" is usually "no: its not worth implementing those methods", but I still have to think about them.
More to the point, the TwoInts class looks so ugly polluting the top level namespace like that, MyUsefulClass.TwoInts is public, that I don't think I've ever actually created that class. I always find some way to avoid it, even if the workaround is just as ugly.
For myself, I'd like to see some simple pass-by-value "Tuple" type. My fear is it'd be abused as a way for lazy programmers to avoid creating objects when they should have a logical type for readability & maintainability.
Anyone who has maintained code where someone has passed in all their arguments as (mutable!) Maps, Collections and/or Arrays and "returned" values by mutating those structures knows what a nightmare it can be. Which I suppose is an argument that cuts both ways: on the one hand you can say: "why add Tuples which would be another easy thing to abuse", on the other: "why not add Tuples, given Arrays and the Collections framework already allow bad programmers to produce unmainable mush. One more feature isn't going to make a difference either way".
Ho hum.

Similar Messages

  • LOV problem with multiple return values.

    I created a ViewObject and in it a transient attribute.
    I create a ViewAccessor for another field and a LOV for it (default InputText with Lov Value).
    In List Return Values I added also my tranient attribute in order to receive another attribute from the accesor VO.
    When I run it from the Application browser I see my transient attribute emtpty even if the "source" attribute is not empty.
    If I change the value from the LOV the source value changes bit the transient is still empty.
    What's wrong ?
    Tks
    Tullio

    Repost.

  • Multiple return values in Customized elementary search help

    Hello,
      I have a requirement when i select the value from F4 . It should populate the more than one return values in ALV grid in different rows .  
       Any FM or help search exit  is available to do this .
    Regards,
    kevin

    Hi Kevin,
    About your first question, for filling several fields of an ALV from a single F4 search help, I think that you should register F4 event to call the search help yourself (F4IF_INT_TABLE_VALUE_REQUEST for instance), and fill the ALV fields inside your F4 handler method. If you used REUSE_ALV_GRID_DISPLAY, then I am not sure how you can handle F4, but you can do it using CL_GUI_ALV_GRID or SALV classes. See BCALV_TEST_GRID_F4_HELP.
    About the second question, for filling automatically another field in the same row in the ALV grid, it should work automatically, as for normal dynpros, i.e. the search help must have these 2 fields defined as exporting, and these 2 fields of the ALV field catalog must refer to the same DDic structure, the search help must be assigned there to the field, and fill in the 2 exporting parameters too.
    Sandra

  • CreateInsert and LOV with multiple return values

    HI. I am on Build JDEVADF_11.1.2.3.0_GENERIC_120914.0223.6276.1
    I have a View Object which is based on Entity Object.
    View Object has customer_name and customer_id attributes.
    customer_name attribute has LOV (input field with LOV) based on some other View Object (which of caurse holds customer name and customer id data)
    I defined that when LOV return the chosen values it will populate customer_name with "Customer Name" value and customer_id with "Customer Id" value
    All atributes are updatable
    I droped my View Object on the page and also "CreateInsert" buton. When I click on "CreateInsert" button, I can see new row added as expected, customer_name field has LOV. I can choose from LOV and can see customers and customer_id data. But when I click OK in the LOV pop-up only customer_name attribute is populated!
    I do see that customer_id is returned from LOV (I implemented ReturnPopupEvent listener), but still the customer id remains empty.
    I though maybe I need to add LOV as auto submit = true and set LOV to be a partial trigger for customer_id. But still  - it didn't help
    However, if I run Application Module tester, I do get what I want. I can create new row and when I change customer name , both customer name and customer id fields are populated
    Please advice

    Hi Michael,
    On Lov VO, make sure you have at least one or combination of attributes as Key attribute. and re test.
    Thanks,
    Jeet

  • Parsing a selected column into multiple returned values

    I have a column in a table that contains a string of variable names seperated by commas. In my Select statement is it possible to break apart the string using the commas as a delimeter and get each item returned individually?
    Here's my table:
    SQL> create table myvars
    2 (x number(1), vars varchar2(200));
    Table created.
    SQL> insert into myvars
    2 values
    3 (1, 'varA,varS,varY');
    1 row created.
    SQL> edit
    Wrote file afiedt.buf
    1 insert into myvars
    2 values
    3* (2, 'varX,varU,varB,var1')
    SQL> /
    1 row created.
    SQL> edit
    Wrote file afiedt.buf
    1 insert into myvars
    2 values
    3* (3, 'varE,varI')
    SQL> /
    1 row created.
    SQL> set linesize 250
    SQL> /
    X VARS
    1 varA,varS,varY
    2 varX,varU,varB,var1
    3 varE,varI
    So, would it be possible to somehow select the a row of text where X = 2 that ends up looking like this:
    X
    2 varX varU varB var1
    ...where the column VARS is broken into 4 smaller strings of text?

    SQL> select ename from emp where empno = 7934 ;
    ENAME
    SMITH,ALLEN
    1 row selected.
    SQL> select * from TABLE(select cast(in_list(ename) as mytableType) from emp where empno = 7934) a ;
    COLUMN_VALUE
    SMITH
    ALLEN
    2 rows selected.
    SQL>Message was edited by:
    Kamal Kishore

  • CREATE_DEEP_ENTITY : Multiple Return Values

    Hello,
    My requirement is to pass some item data to web service & then i use FM to create a Item id for each item passed. So, if i have passed 10 items in input, 10 item ids will be created.
    in SEGW model, i have created a entity type ENT1 that has fields Item id & item name ( This is the info i want WS to return in response). Other entity type ENT2 has item data information or fields that i want to input to web service. Then i created a navigation from ENT1 to ENT2 with cardinality as M:N.
    So, now if i pass 10 Items info in input, i should get back in response 10 item ids with their name. I hope my requirement is clear.
    Then, i have used method CREATE_DEEP_ENTITY to create items & then i have all the items created & their name in an internal table. Then i use below method to send this table in response:
    copy_data_to_ref(
                 EXPORTING
                 is_data = lt_created_items
                 CHANGING
                 cr_data = er_deep_entity
    My issue is that i don't see any item in response if i pass here a table in IS_data but if i pass a work area, then thats returned in response.
    What could be the reason & how can i solve this?
    Regards
    Gaurav K

    Hello Gaurav,
    That is because the navigation property defined in the model for a particular entity need to be a part of your payload.
    Explanation : consider
    Say u have an entity ITEM and entity set ITEMSet where u will be sending your item details.
    Say u have a header entity PARENT and entity set PARENTSet where u send header info.
    Say u have another entity ITEMDETAIL and entity set ITEMDETAILSet ( which will be got from your BE logic as a part of response )
    Say u have association & navigation between entities as below :
    PARENT to ITEM - 1 to N
    PARENT to ITEMDETAIL - 1 to N
    Navigation Properties :
    PARENT to ITEM - ParentItem
    PARENT to ITEMDETAIL - ParentItemDetail
    Now in Payload u would send as below  :
    JSON payload -
    "HeaderProperty1":"",
    "HeaderPropertyN":"",
    "ParentItem":[{
    < Your item info >
    With this u will fire the Deep Entity, Creation of Items happens and u will send back the response as well. i.e., deep structure holding header,items sent initially in payload and item details which u got as part of successful creation )
    But now in response u will not be able to see item details which u got as part of successful creation because the above payload will not have navigation property ParentItemDetail as part of payload so u wont see in response though u send those details as part of your deep structure
    So now solution is :
    Send the payload as below :
    "HeaderProperty1":"",
    "HeaderPropertyN":"",
    "ParentItem":[{
    < Your item info >
    "ParentItemDetail":[{
    With this u can see the item details which u got as part of successful creation along with your header and items sent initially in payload as well
    Regards,
    Ashwin

  • How to get multiple return value

    hi all!
    I have a method to get some values and put them in 3 arrays which include both one and two dimension arrays. I used String [ ] and String [ ]. The problem is how could I get the values in both String [ ] and String [ ] from outside the method`?
    Thanks a lot !

    Thanks!
    Seems I am on the wrong way. What I am doing is like this example of a picture (arrays used are either String[ ] or String [ ][ ] in following):
    A array Box_array[ ] stores all the names of boxes. Box A (called Source Box) points to Box B (Destination Box) by a directed line called AB. The joints are called Aab on Box A and Bab on Box B respectively. Similarly, Box A may point to another Box C. Box B also may point to Box D. So I use arrary Src_arrary[ k ] to store the name of one Souce Boxe,and Dst_arrary [k ][ ] to store the corresponding Destination Boxes. E.g.,
    Src_array[0] = "A";
    Src_array[1] = "B";
    Dst_array[0][0] = "B";
    Dst_array[0][1] = "C";
    Dst_array[1][0] = "D";
    In the same way,
    Line_array[0][0] ="AB"; Point_Src[0][0] = "Aab"; Point_Dst[0][0]= "Bab";
    Line_array[0][1] ="AC"; Point_Src[0][1] = "Aac"; Point_Dst[0][1]= "Cac";
    Line_array[1][0] ="BD"; Point_Src[1][0] = "Bbd"; Point_Dst[1][0]= "Dbd";
    Line_array[k][ ] stores direted lines which start from the Box indicated by Src_array[k]. Point_Src[k][ ] stores all joint points on the source box (Src_array[k]) and Point_Dst[k][ ] is for joint points on the destination box (Dst_array[k]).
    Now you may understand why I use a two dimension array: because I want to find the right lines and points for a given source box, by using the idex k in the above example.
    Until now, I could represent the picture (Not to draw the picture) like this:
    Directed lines Line_array[k][0] and Line_array[k][1] start from Point_Src[k][0] and Point_Src[k][1] respectively. Both points are on box Src_array[k], and these two lines point to Point_Dst[k][0] on box Dst_array[k][0] and Point_Dst[k][1] and Dst_array[k][1] respectively.
    Then I need to get these values or names stored in these arrays from outside of this method. That is my problem. Maybe it is a wrong way, but as a newbie, I didn't find out other solutions.
    Thank you very much for any hints!

  • Search Help: Multiple Return Values in WD4A

    Hello,
    I would like to fill more than one fields on my WD4A screen when executing a search help for one input field.
    So I need to manage somehow to get all the export parameters from the search help and post them to a context node.
    Simple example: The customer sales view consists of sales org and customer number. The search help contains both of them as export parameter. So when the user selects one user I need to get and show the sales organization as well.
    In "normal" SAP Dynpro development its quite easy as shown in thread
    Re: Export search help results to more dynpro fields.
    But how can I execute a search help in WD4A to get all the export parameters?
    Thanks for you help!!
    Kind regards,
    Hendrik

    Hi,
    found the answer by myself.
    The solution is:
    - Create a structure which contains the fields for the search help.
    - then create the search help with all required export parameters.
    - Assign the search help to the corresponding field in the structure.
    - Create the context node with reference to the structure.
    All context node attributes are then filled automatically.

  • Getting Return values from RFC function call with visual basic

    Hi,
    I am creating a sample app to connect to a SAP system which call its RFC functions created with ABAP. It was known that the function will return more than 1 return values.
       SAP Function name ==> "ZFMTP_RFC_GET_RESULT"
            Export parameters (to SAP):
                    - Student Name [char 10]         ==> "STUNAME"
                    - Student ID         [char 20]        ==> "STUID"
           Return values (From SAP):
                    - Results [char 10]        ==> "RESULT"
                    - Remarks [char 200]        ==> "REMARKS"
    i have managed to get sample codes for connecting and call a RFC function with vb but they only get a return value. How do i retrieve multiple return values like the above function "RESULT" and "REMARKS"?
    Here's my vb code to accessing the function
            Dim R3 As Object
            Dim FBFunc As Object
            Dim returnFunc As Boolean
            Dim connected As Boolean
            R3 = CreateObject("SAP.Functions")
            R3.Connection.Client = "000"
            R3.Connection.User = "BCUSER"
            R3.Connection.Password = "minisap"
            R3.Connection.Language = "DE"
            R3.Connection.System = "dtsystem"
            R3.Connection.Applicationserver = "xxx.xxx.xxx.xxx" 
            connected = R3.Connection.Logon(0, True)
            If connected <> True Then
                MsgBox("Unable to connect to SAP")
            End If
            FBFunc = R3.add("ZFMTP_RFC_GET_RESULT")
            FBFunc.exports("STUNAME") = "Jonny"
            FBFunc.exports("STUID") = "12345"
            returnFunc = FBFunc.Call() <<== How do i get the return value? or RESULT and REMARKS of the RFC Function?
    thanks alot.
    Edited by: Eugene Tan on Mar 4, 2008 7:17 AM

    Hi Gregor,
    Thanks for the link....i am having some doubts with the codes, hope you can clarify them for me if you know the codes..
    Below is the code snippet.
    Set impReturn = CHPASS_FN.Imports("RETURN")  <<=== is RETURN the standard keyword to get a                                                                                return object?
      expPassword.Value = currpass
      expNewPass.Value = newpass
      expFillRet.Value = "1"
    ''' Call change password function
      If CHPASS_FN.Call = True Then
        outFile.Write (", Called Function")
        Message = impReturn("MESSAGE") <<==== So if i have 3 return values..i just replace with the return                                                               value variable names?
        outFile.WriteLine " : " & Message
      Else
        outFile.Write (", Call to function failed")
      End If
    thanks alot...all your help is very appreciated.

  • Function with more than one return value

    Hi
    Please let me know how to write a function with more than one return value and in what scenario should we go for this option.
    Thank you

    user12540019 wrote:
    Please let me know how to write a function with more than one return value and in what scenario should we go for this option.Yes. And the following is the correct approach (using OUT variables is not!) - you deal with the multiple values as a data structure. This example uses an custom (user-defined) SQL data type as the structure.
    SQL> create or replace type TXYcoord is object(
      2          x       number,                  
      3          y       number                   
      4  );                                       
      5  /                                        
    Type created.
    SQL>
    SQL>
    SQL> create or replace function fooCoordinate( someParam number ) return TXYCoord is
      2  begin                                                                         
      3          -- doing some kind of calculation using input parameters              
      4          --  etc..
      5
      6          -- returning the multiple return values as a proper data structure
      7          return(
      8                  TXYcoord( 0, 0 )
      9          );
    10  end;
    11  /
    Function created.
    SQL>
    SQL> -- selecting the data structure
    SQL> select
      2          sysdate,
      3          fooCoordinate(123)      as XY
      4  from       dual;
    SYSDATE             XY(X, Y)
    2010-02-01 08:49:23 TXYCOORD(0, 0)
    SQL>
    SQL> -- selecting the properties/fields of the data structure
    SQL> select
      2          sysdate,
      3          treat( fooCoordinate(123) as TXYcoord).x        as X,
      4          treat( fooCoordinate(123) as TXYcoord).y        as Y
      5  from       dual;
    SYSDATE                      X          Y
    2010-02-01 08:49:23          0          0
    SQL>

  • UML notation: Class operation return value multiplicity

    Hallo,
    how would you write function from example below using UML notation on implementation level, please:
    class Coin {
      public String[] getSideNames() {
        return new String{ "Odd", "Even" };
    }Multiplicity in return value is troubling me. I've tried +getSideNames( ) : String [ 2 ] but my tool just created new class named "String[2]" :-( To be precise I know that return value of function is array of MyClass with one or more element (1..*) so created class name was "MyClass[1..*]" -- nasty name to pass to javac isn't it? :-)
    Is is possible to write multiplicity of return value this way? I couldn't find anything in omg's "UML: supertructure document" :-( I am not telling that it's not written there :-)))
    Thank You.

    jschell>
    Unfortunately [n] behaves in same fashion as [*] =>
    creating class named MyClass[1..n]" :-(
    duffymo> what's the point?
    this was only sample, real application is far more
    complex than that. Even "nature" of result was just
    made up. How am I or anyone else who responds supposed to know that?
    >
    duffymo> you can have cardinality in a class diagram
    that shows exactly two values are available.
    yup, i ended like that but there's still problem coz
    return value class is "Object[]" :-(Sounds like a bad design, but I haven't seen the code, so I can't tell.
    duffymo> personally, i don't think that exposing the
    side names as ...
    "side names" were just example :-) IMHO there are
    certain situations where one could say "screw the
    abstraction" :-D E.g. for final classes from one
    package that cooperate on single time critical task.
    :)"screw the abstraction" - good luck as an object-oriented designer with that attitude.
    Either you're doing real-time work where time really is critical, or you're just another yutz who is congratulating himself on recognizing a time critical task without doing profiling or getting any real data. (A common mistake.) The maintainence and development time might be more critical here.
    Gotta admit that I'm not much interested in commenting on your poor approximation of the real problem.
    %

  • How to pass a function with the same argument multiple times and return values in variables?

    The problem I have is I created a function which really is some kind of database.  Basically a bunch of:
    if (a.value == "this number"){
    b.value = "this expression";
    Inside the form are 2 dropdown lists that return numerical values which I want to process through that function and put the return value inside separate variables.
    var a = this.getField("OPE003.EVEN.1.MIP");
    Mip(a);
    var result1 = Mip();
    I tried to overwriting *a* to process the second field
    a = this.getField("OPE003.EVEN.2.MIP");
    Mip(a);
    var result2 = Mip();
    result1 and result2 are put in an array, joined as a string.
    Doing so, I always get the last processing twice as the final result.
    Can I use a function as a batch processing tool that way?

    You are right, I changed the code to what you said but how do I pass another value through my fonction so I can get Result1 and Result2?
    is it
    var a = this.getField("OPE003.EVEN.1.MIP");
    var b = this.getField("OPE003.EVEN.2.MIP");
    var result1 = Mip(a);
    var result2 = Mip(b);
    var c = new Array[result1, result2]

  • Assigning LOV return Value to multiple text items

    Hi all
    I have a custom form on which i have 10 text items
    text item 1,text item 2 ....text item10
    I have a table xx_querywith fields
    text_item,query
    i have inserted into the xx_query table
    insert into xx_query(text_item,query)
    values(text_item1,'select sysdate from dual');
    insert into xx_query(text_item,query)
    values(text_item2,'select sysdate-1 from dual');
    I have created a record group dynamically and i am getting the query from the query column of the xx_query table into the record group(say test_rg)
    I have created a LOV test_lov and thr set_lov_property i have populated the test_rg query into the test_LOV
    is it possible for me to set the return item of the LOV dynamically so that i can get the LOV on the item which i want to ?
    thanks
    _

    Hi All
    thanks for your responses
    I have Created a control item and assigned the return value of the LOV to the control item
    and i have assigned the LOV to the text item that i want
    Currently when i navigate to the text item the LOV is visible
    but when i select a value from the LOV the value is not getting populated into the text item
    I have assigned the value of the control item to the text item
    but i am not sure in which trigger to write the code so as when i select the value from the LOV the value should be shown on the form populating in the text item
    Thanks

  • Wait ms Timer Multiple returning inaccurate timer value

    We are using the Wait Until Next ms Multiple Timer value to set the interval that data is recorded to a file. Because of Windows 2000 time indeterminancy, the Wait Until Next ms Multiple Timer value is written to file, along with the data point, and is used to calculate the derivative between two successive points. With a delay of 1 sec (1000 ms), the actual interval ranges from 1025 to 1035 ms. At several (random!) points during the acquisition, the difference between successive ms values is considerably smaller than 1000 ms (e.g. 15-25 ms). The following difference compensates for the previous error e.g. the difference will be 2025-2055ms. The data that we are recording is a smoothly continuou
    s function and it appears that the sample is actually recorded at approximately 1000 plus ms. Thus it appears that the Wait Until Next ms Multiple waits the appropriate amount of time to record the data point, but outputs an erroneous ms timer value. We added a ms Timer function to the VI, which also experienced a similar glitch. This glitch does not correspond to the wraparound point; it occurs at approximately 60 to 130 sec intervals. We took the timing code only (no data acquisition, etc) and created a VI that wrote just the time values to a file. This is attached, along with the generated data in a spreadsheet. This consistently executed every 1000 ms but occasionally confused the intervals by 1-57 ms. The pattern was reversed from the previous problem by having a long interval and then a short interval. Any insight would be greatly appreciated!
    Attachments:
    CollectingSampleData.vi ‏47 KB
    Create_XCoord.vi ‏25 KB
    sampledata.xls ‏91 KB

    Agree completely but why can't LV provide access to the windows multimedia
    timer like LabWindows does? Provide me a timer, I can start/stop by changing
    its properties and run that in a separate thread. Obviously if I have
    another thread starving this timer thread, it won't help much but using
    multi-media timer, I have seen very good results on a windows2000 machine.
    Now win95/98 and derivatives are all other story.
    vishi
    "Al S" wrote in message
    news:[email protected]..
    > There are a couple of things going on that affect your results.
    > 1. Windows is not a real-time operating system. As it multi-tasks,
    > you have little control over when it gives time to your application.
    > Loop times may vary depend
    ing on what else Windows decides during that
    > iteration. Especially when doing file I/O: if your disk is busy, a
    > loop interation may take longer. Windows may also be doing some disk
    > buffering, so occasionally a loop interation may take much longer than
    > usual as the buffered data from multiple loop interations gets written
    > to disk.
    > 2. Wait Until Next ms Multiple doesn't garuntee equal loop times.
    > With the millisecond multiple input set to 1000, if one iteration
    > starts with the PC's clock at xx:xx:xx.001, Wait Until Next ms
    > Multiple will wait 0.999 seconds. If an iteration starts with the
    > PC's clock at xx:xx:xx.999, Wait Until Next ms Multiple will wait
    > 0.001 seconds.
    > 3. In your main loop, you check to see if the millisecond timer value
    > * 60 equals the desired Length of Data Collection. If your loop
    > doesn't execute every millisecond, you may miss the equals case and
    > then your loop won't stop. You should check >= rather than just =.

  • Trying to get multiple cell values within a geometry

    I am provided with 3 tables:
    1 - The GeoRaster
    2 - The geoRasterData table
    3 - A VAT table who's PK is the cell value from the above tables
    Currently the user can select a point in our application and by using the getCellValue we get the cell value which is the PK on the 3rd table and this gives us the details to return to the user.
    We now want to give the worst scenario within a given geometry or distance. So if I get back all the cell values within a given geometry/distance I can then call my other functions against the 3rd table to get the worst scores.
    I had a conversation open for this before where JeffreyXie had some brilliant input, but it got archived while I was waiting on Oracle to resolve a bug (about 7 months)
    See:
    Trying to get multiple cell values within a geometry
    If I am looking to get a list of cell values that interact with my geometry/distance and then loop through them, is there a better way?
    BTW, if anybody wants to play with this functionality, it only seems to work in 11.2.0.4.
    Below is the code I was using last, I think it is trying to get the cell values but the numbers coming back are not correct, I think I am converting the binary to integer wrong.
    Any ideas?
    CREATE OR REPLACE FUNCTION GEOSUK.getCellValuesInGeom_FNC RETURN VARCHAR2 AS
    gr sdo_georaster;
    lb blob;
    win1 sdo_geometry;
    win2 sdo_number_array;
    status VARCHAR2(1000) := NULL;
    CDP varchar2(80);
    FLT number := 0;
    cdl number;
    vals varchar2(32000) := null;
    VAL number;
    amt0 integer;
    amt integer;
    off integer;
    len integer;
    buf raw(32767);
    MAXV number := null;
    r1 raw(1);
    r2 raw(2);
    r4 raw(200);
    r8 raw(8);
    MATCH varchar2(10) := '';
    ROW_COUNT integer := 0;
    COL_COUNT integer := 0;
    ROW_CUR integer := 0;
    COL_CUR integer := 0;
    CUR_XOFFSET integer := 0;
    CUR_YOFFSET integer := 0;
    ORIGINY integer := 0;
    ORIGINX integer := 0;
    XOFF number(38,0) := 0;
    YOFF number(38,0) := 0;
    BEGIN
    status := '1';
    SELECT a.georaster INTO gr FROM JBA_MEGARASTER_1012 a WHERE id=1;
    -- first figure out the celldepth from the metadata
    cdp := gr.metadata.extract('/georasterMetadata/rasterInfo/cellDepth/text()',
    'xmlns=http://xmlns.oracle.com/spatial/georaster').getStringVal();
    if cdp = '32BIT_REAL' then
    flt := 1;
    end if;
    cdl := sdo_geor.getCellDepth(gr);
    if cdl < 8 then
    -- if celldepth<8bit, get the cell values as 8bit integers
    cdl := 8;
    end if;
    dbms_lob.createTemporary(lb, TRUE);
    status := '2';
    -- querying/clipping polygon
    win1 := SDO_GEOM.SDO_BUFFER(SDO_GEOMETRY(2001,27700,MDSYS.SDO_POINT_TYPE(473517,173650.3, NULL),NULL,NULL), 10, .005);
    status := '1.2';
    sdo_geor.getRasterSubset(gr, 0, win1, '1',
    lb, win2, NULL, NULL, 'TRUE');
    -- Then work on the resulting subset stored in lb.
    status := '2.3';
    DBMS_OUTPUT.PUT_LINE ( 'cdl: '||cdl );
    len := dbms_lob.getlength(lb);
    cdl := cdl / 8;
    -- make sure to read all the bytes of a cell value at one run
    amt := floor(32767 / cdl) * cdl;
    amt0 := amt;
    status := '3';
    ROW_COUNT := (WIN2(3) - WIN2(1))+1;
    COL_COUNT := (WIN2(4) - WIN2(2))+1;
    --NEED TO FETCH FROM RASTER
    ORIGINY := 979405;
    ORIGINX := 91685;
    --CALCUALATE BLOB AREA
    YOFF := ORIGINY - (WIN2(1) * 5); --177005;
    XOFF := ORIGINX + (WIN2(2) * 5); --530505;
    status := '4';
    --LOOP CELLS
    off := 1;
    WHILE off <= LEN LOOP
    dbms_lob.read(lb, amt, off, buf);
    for I in 1..AMT/CDL LOOP
    if cdl = 1 then
    r1 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
    VAL := UTL_RAW.CAST_TO_BINARY_INTEGER(R1);
    elsif cdl = 2 then
    r2 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
    val := utl_raw.cast_to_binary_integer(r2);
    ELSIF CDL = 4 then
    IF (((i-1)*cdl+1) + cdl) > len THEN
    r4 := utl_raw.substr(buf, (i-1)*cdl+1, (len - ((i-1)*cdl+1)));
    ELSE
    r4 := utl_raw.substr(buf, (i-1)*cdl+1, cdl+1);
    END IF;
    if flt = 0 then
    val := utl_raw.cast_to_binary_integer(r4);
    else
    val := utl_raw.cast_to_binary_float(r4);
    end if;
    elsif cdl = 8 then
    r8 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
    val := utl_raw.cast_to_binary_double(r8);
    end if;
    if MAXV is null or MAXV < VAL then
    MAXV := VAL;
    end if;
    IF i = 1 THEN
    VALS := VALS || VAL;
    ELSE
    VALS := VALS ||'|'|| VAL;
    END IF;
    end loop;
    off := off+amt;
    amt := amt0;
    end loop;
    dbms_lob.freeTemporary(lb);
    status := '5';
    RETURN VALS;
    EXCEPTION
        WHEN OTHERS THEN
            RAISE_APPLICATION_ERROR(-20001, 'GENERAL ERROR IN MY PROC, Status: '||status||', SQL ERROR: '||SQLERRM);
    END;

    Hey guys,
    Zzhang,
    That's a good spot and as it happens I spotted that and that is why I am sure I am querying that lob wrong. I always get the a logic going past the total length of the lob.
    I think I am ok using 11.2.0.4, if I can get this working it is really important to us, so saying to roll up to 11.2.0.4 for this would be no problem.
    The error in 11.2.0.3 was an internal error: [kghstack_underflow_internal_3].
    Something that I think I need to find out more about, but am struggling to get more information on is, I am assuming that the lob that is returned is all cell values or at lest an array of 4 byte (32 bit) chunks, although, I don't know this.
    Is that a correct assumption or is there more to it?
    Have either of you seen any documentation on how to query this lob?
    Thanks

Maybe you are looking for

  • Low battery warning percent fixed??

    I have Vaio VPCYB15AG with Win 7 Ultimate SP1 32Bit retail. In it's advanced power options even though I can set percentage value for Low battery warning, I find that the warning is given (Blinking green power LED) when battery falls to 12%.Is this l

  • STUCK thread equals elevated CPU

    Agile PLM 9.3.0.1 Weblogic 10.0 Solaris 10 Recently installed Agile 9301 in production. Three times in the week since go-live CPU has elevated up to 100% (twice on one managed host, once on the other), forcing me to kill Agile on that managed host an

  • Two same iphoto's in network

    Hi all, I have two MBP's. Bought close together in time. One came with iLife08, the other iLife07. Now for all iLife apps I dont mind too much, however the new iPhoto converts your library, which makes it annoying to copy libraries back and forth. Th

  • Compile error in hidden module: AZWizardModul.

    Receiving the following error message when opening Office Word 2010: ========================================================= Microsoft Visual Basic for Applications Compile error in hidden module:  AZWizardModul. This error commonly occurs when cod

  • Printing to a printer shared on a PC from a Mac

    I have a PC running Windows XP Pro connected to a home network. I am trying to print to a Canon S530D printer shared on that PC. I can see the printer in the printer setup utility on my Mac but I don't know what to choose as the printer model, generi