Lee Gillie CCP Active Member Licensed User Longtime User Aug 11, 2015 #1 My eventual usage calls for an array of class instances, so this function returns an array... Code: Copy Sub DeliveredOrders As SerializableOpenOrder() In the mechanics of it the orders are first created with a List because it is dynamic, so I can add items to the List as they are discovered. Once the List is built I coerce the List to an array (because that's what is needed downstream)... Code: Copy Dim orders(reclsth.Size) As SerializableOpenOrder For i = 0 To reclsth.Size-1 orders(i) = reclsth.Get(i) Next Return orders I then eventually pass it to a routine that will utilize the array.... Code: Copy Public Sub DeleteOrders( orders() As SerializableOpenOrder ) Dim soo As SerializableOpenOrder Dim ooh As OpenOrderHeader Dim ool As OpenOrderLine For i = 0 To orders.Length - 1 Where it says "orders.Length" I get a runtime error: java.lang.RuntimeException: Field; length not found in java.util.ArrayList. So I tried changing the reference to orders.Size at the FOR loop, but now it won't compile: Code: Copy Error compiling program. Error description: Only 'Length' is supported by arrays. I seem to have put myself into a pickle, and it's not really clear to me why this approach does not work.
My eventual usage calls for an array of class instances, so this function returns an array... Code: Copy Sub DeliveredOrders As SerializableOpenOrder() In the mechanics of it the orders are first created with a List because it is dynamic, so I can add items to the List as they are discovered. Once the List is built I coerce the List to an array (because that's what is needed downstream)... Code: Copy Dim orders(reclsth.Size) As SerializableOpenOrder For i = 0 To reclsth.Size-1 orders(i) = reclsth.Get(i) Next Return orders I then eventually pass it to a routine that will utilize the array.... Code: Copy Public Sub DeleteOrders( orders() As SerializableOpenOrder ) Dim soo As SerializableOpenOrder Dim ooh As OpenOrderHeader Dim ool As OpenOrderLine For i = 0 To orders.Length - 1 Where it says "orders.Length" I get a runtime error: java.lang.RuntimeException: Field; length not found in java.util.ArrayList. So I tried changing the reference to orders.Size at the FOR loop, but now it won't compile: Code: Copy Error compiling program. Error description: Only 'Length' is supported by arrays. I seem to have put myself into a pickle, and it's not really clear to me why this approach does not work.
R Roycefer Well-Known Member Licensed User Longtime User Aug 11, 2015 #2 Do you have any List variables named "orders" in global scope? Upvote 0
Lee Gillie CCP Active Member Licensed User Longtime User Aug 11, 2015 #3 Thanks for your reply Roycefer! No I do not. I tried to make a tiny test project to illustrate the issue as I think I am observing it, but it does not reproduce the behavior of the large production project. There must be an intermediary involved I can not yet see. So for the moment I should call this closed so no one spins wheels on it, and I will trace it more deeply in the debugger. I'm obviously doing something wrong. I will report back here with my findings. Upvote 0
Thanks for your reply Roycefer! No I do not. I tried to make a tiny test project to illustrate the issue as I think I am observing it, but it does not reproduce the behavior of the large production project. There must be an intermediary involved I can not yet see. So for the moment I should call this closed so no one spins wheels on it, and I will trace it more deeply in the debugger. I'm obviously doing something wrong. I will report back here with my findings.
Lee Gillie CCP Active Member Licensed User Longtime User Aug 11, 2015 #4 In fact all with B4A works as expected, and I found my cockpit error down in the bowels of an intermediary routine. Upvote 0
In fact all with B4A works as expected, and I found my cockpit error down in the bowels of an intermediary routine.