passing an array of data as a parameter

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

passing an array of data as a parameter

Post by jalz » Sat Feb 01, 2014 11:21 pm

Hi Guys,
I'm playing with data grids, and I want to take a line of data and pass that data to another command in another stack called CustomerContactEdit. I can seem to pass a single parameter such as in this case FirstName but what I can't seem to pass is the entire tRecordA and process

Code: Select all

on EditRecord pLineNumber
   local tLine, tRecordA, tRecordId

   put the dgDataOfLine[pLineNumber] of me into tRecordA
   
   put tRecordA["firstname"] into tFirstName
   answer tFirstName 
   
   --CustomerContactEdit tFirstName   
   CustomerContactEdit tRecordA
end EditRecord

-- this code is in another stack

command CustomerContactEdit pRecordA
   
   put tRecordA["contactID"] into tContact
   put tRecordA["firstname"] into tFirstname
   put tRecordA["lastname"] into tSurname
   
   answer tFirstname
   
   return the result
end CustomerContactEdit

Anyone advise me how to get the data that belongs to the entire record across to the command?

Thanks

Jalz

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: passing an array of data as a parameter

Post by dunbarx » Sun Feb 02, 2014 12:06 am

Hi.

An array will come over just fine as a passed parameter.

What happens if you step through the code? I made a modified test of your script with a DG and a button, and everything works as advertised.

Craig Newman

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: passing an array of data as a parameter

Post by dunbarx » Sun Feb 02, 2014 12:11 am

Hi again,

I stopped my test a little early. Check out your "CustomerContactEdit " handler, you pass the array to the handler through the local variable "pRecordA". But you then use the array variable "tRecordA". Typo?

Craig Newman

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: passing an array of data as a parameter

Post by jalz » Sun Feb 02, 2014 12:29 am

Hi Craig,

Yes Typo, I've changed everything to pRecordA now, but still not working. Whats the best way to step through code. I presume I need to turn on Script Debug mode, but haven't figured out how do I get to step through the actual code?

Thanks

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: passing an array of data as a parameter

Post by jalz » Sun Feb 02, 2014 12:54 am

Hi Craig,

Got it working and also walked through the script debugger. Thanks for the tip and heads up :)

Jalz

Post Reply