Problem with send command???

Jim Ault JimAultWins at yahoo.com
Thu Jun 26 23:47:44 EDT 2008


On 6/26/08 8:04 PM, "Shao Sean" <shaosean at wehostmacs.com> wrote:

> I have run into issues where my data being "sent" has had commas and
> it ends up thinking that it is a new parameter..

The 'send' command has some difficulties since it first tries to interpret
the string expression of the task you wish to execute.  If the string
contains variable names, then Rev does the best it can to 'do what you mean'

The same variability arises when using the 'do' command.

Caution: this is not really a new user topic, but read on.

Using encoding will help this, but you need to consider what other
characters besides the comma could also be considered 'control or delimiter'
characters.

Passing by reference rather than variable name also works in many cases.
This way you are not passing the data, but a pointer to the memory location
of the data.  { see below for a post from 2005 and a question asked by Mark
Wieder and answered by Trevor}

Of course using custom properties would mean you are not passing any data,
but storing it, then accessing it from another handler.  I showed an example
of this in a previous email.

Another level of complexity occurs if you are trying to use the send command
to store data in a database (such as MySQL).  Not all characters can be
stored directly since the data tables have to have some sort of delimiter,
slashes in particular.

Jim Ault
Las Vegas
-----------------------------------------------------------
what follows below is an old email that still applies, and then a section of
working code.
------------------------
On Sep 20, 2005, at 8:23 AM, Mark Wieder wrote:

> All-
>
> I've run up against a couple of problems here:
>
> 1. I'm trying to pass parameters using the "send" command. The problem
> is that "send" insists on interpreting these for me rather than
> sending them verbatim. In other words, if I try
>
> send "hi" && the long id of field "xyz" to field "abc" of card "argh"

Try stuffing the values you want to send into variables and then do
this:

get the long id of field "xyz"
send "hi it" to field "abc" of card "argh"

> 2. I can pass a parameter by reference once. That is,
>
> local someArray
>
> on stuff @pArray, pIndex, pValue
>   put pValue into pArray[pIndex]
> end stuff
>
> stuff someArray, tUserID, tPassword
>
> works fine. But I need to pass a reference to someArray to another
> handler down the line. Is there a syntax that will allow me to do
> this? I need a second level of indirection and I can't figure out how
> to do it. I don't think passing the entire array back and forth is
> going to be an option. I miss pointers...
>
> on stuff @pArray, pIndex, pValue
>   stuff2 pArray, pIndex, pValue
> end stuff
>
> on stuff2 @pArray, pIndex, pValue
>   put pValue into pArray[pIndex]
> end stuff2
>
> stuff2 someArray, tUserID, tPassword
«  [hide part of quote]

What you have above will work.  The array is passed by reference all
the way down the line. In both cases you are passing the array by
reference.  I do this in libraries all of the time.


-- 
Trevor DeVore
Blue Mango Multimedia
-----

-----------copy and paste into  the stack script  ----------------
 local someArray

on testStuffing
  put 23 into someArray["mark"]
  put 45 into someArray["john"]
  put 56434 into tUserID
  put "marble" into tPassword
  stuff someArray, tUserID, tPassword
   breakpoint
  
  put 4433 into tUserID
  put "locateye" into tPassword
  stuff1 someArray, tUserID, tPassword
  breakpoint
end testStuffing

on stuff @pArray, pIndex, pValue
  put pValue into pArray[pIndex]
end stuff

 on stuff1 @pArray, pIndex, pValue
   stuff2 pArray, pIndex, pValue
 end stuff1

on stuff2 @pArray, pIndex, pValue
   put pValue into pArray[pIndex]
 end stuff2
--------------- end copy ----------------------------





More information about the use-livecode mailing list