Thank Brian. The issue is now resolved.

Alon Raskin

From: iphonewebdev@googlegroups.com [mailto:iphoneweb...@googlegroups.com] On 
Behalf Of Brian McMillin
Sent: Tuesday, October 12, 2010 5:24 PM
To: iphonewebdev@googlegroups.com
Subject: Re: Returning values from transaction success handler

Alon -

It would be nice to get away without global variables, but.....

It appears that the scope of your callback is always going to be different from 
your calling function.

In your case, I believe that the callback is setting the global msgArray, not 
the one local to the caller.

Try getting rid of the var declaration in your calling function - just set it 
as a new Array();

See if that makes your results show up.

As for handling global variables, just dispose of it when you are done.

-----

I hope that I properly understood your problem and that my answer is suitably 
clear.

Brian

________________________________
From: Alon Raskin <aras...@go3i.com>
To: "iphonewebdev@googlegroups.com" <iphonewebdev@googlegroups.com>
Sent: Tue, October 12, 2010 11:24:22 AM
Subject: Returning values from transaction success handler


Hi Everyone,

I am trying to return an array of values from a function which is called when a 
successful SQL call is made.
The problem I am having is that msgArray.length always equal to 0 even though 
when I am inside the function it has a value.
Can I not return a value from the transaction success handler function? I am 
going to this trouble because I really hate global variables.


function GetQEntryMsgsfromDB(aQEntryRecord){
    var mw_db = init_core_DB();
    var msgArray = new Array();


    mw_db.transaction(function(transaction){
      transaction.executeSql('SELECT * FROM QueueMsg Where APP_ID=? AND 
REFOBJTYPE=? AND REFOBJKEY=? AND TARGETXML=?;',
      [aQEntryRecord.appid, aQEntryRecord.refobjtype, aQEntryRecord.refobjkey, 
aQEntryRecord.targetXML],
      function(transaction, results){ msgArray = ProcessMsgDBResults(results); 
} , errorHandler);
     });
     alert('returning array' + msgArray.length);

 }

Your thoughts are appreciated.

Alon Raskin
e: aras...@go3i.com<mailto:aras...@3i-consulting.com>
--
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to iphoneweb...@googlegroups.com.
To unsubscribe from this group, send email to 
iphonewebdev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en.


--
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to iphoneweb...@googlegroups.com.
To unsubscribe from this group, send email to 
iphonewebdev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to iphoneweb...@googlegroups.com.
To unsubscribe from this group, send email to 
iphonewebdev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en.

Reply via email to