language syntax question

Michael Doub mikedoub at gmail.com
Wed Nov 19 15:14:41 EST 2014


Thanks Sean,  How would I go about saving the reference for use later?  
I am trying to pass in a buffer address to a library driver routine for 
a serial port.  You must keep a read posted until data arrives.  The 
allert the caller thru a callback.

in a cardscript:

local buffer
On mouseup
    put empty into buffer  -- this creates the buffer
    initialize_read buffer, "callback", me   -- pass the address of the 
buffer and the callback routine to the driver
    start_reading
end mouseup

on callback
    put buffer -- buffer now has data from the read
end callback

---------------
In a library script:

local savebuf, savedcallback, savedobj
On initialize_read @buf, obj
     put (the address of buf) into savebuf  -- How do I do this?
     put obj into savedobj
     open file serialport
end initialize_read

on start_reading
     read file serialport till empty
     if it is not empty then
          put it into buffer via savebuf  --  How to get the data back 
into buffer?
          send savedcallback to obj in 5 millisec
     else
          send start_reading to me in 5 millisec
     end if
end start_reading








I am good with issue 1.   As for issue 2,
On 11/19/14 2:35 PM, Sean Cole (Pi) wrote:
> Hi Mike
>
> Issue 1-
> Get is for parameters which 'word' is not. So you would use 'put' rather
> than 'get'. Get works well for formattedRect. To use 'get' for getting the
> word 1 of 'obj' you would do this:
>
> Get word 1 of line pl of the text of obj
>
> because 'the text' is a parameter of your 'obj'
>
>
>
> Issue 2-
> With send, you don't need to add the @ suffix. When you use it on the input
> of your handler (i.e., on doit @thevar) it is effectively referencing it to
> the same mem-space of the passed variable 'thevar'. So you would just use
> 'send "another" & thevar in 1 sec' but still use the @ suffix in your next
> handler (i.e., on another @thevar).
>
> Hope this helps you out.
>
> All the best
>
> Sean Cole
> *Pi Digital Productions Ltd*
> www.pidigital.co.uk
> +44(1634)402193
> +44(7702)116447
> π
> 'Don't try to think outside the box. Just remember the truth: There is no
> box!'
> 'For then you realise it is not the box you are trying to look outside of,
> but it is yourself!'
>
> This email and any files transmitted with it may be confidential and are
> intended solely for the use of the individual to whom it is addressed. You
> are hereby notified that if you are not the intended recipient of this
> email, you must neither take any action based upon its contents, nor copy
> or show it to anyone. Any distribution, reproduction, modification or
> publication of this communication is strictly prohibited. If you have
> received this in error, please notify the sender and delete the message
> from your computer.
>
>
>
> Any opinions presented in this email are solely those of the author and do
> not necessarily represent those of Pi Digital. Pi Digital cannot accept any
> responsibility for the accuracy or completeness of this message and
> although this email and any attachments are believed to be free from
> viruses, it is the sole responsibility of the recipients.
>
>
> Pi Digital Productions Ltd is a UK registered limited company, no. 5255609.
> VAT GB998220972
>
> On 19 November 2014 18:57, Mike Doub <mikedoub at gmail.com> wrote:
>
>> i have been struggling with a couple of language issues and I hope some one
>> can set me straight.
>>
>> Issue 1).  What is the syntax to get the contents of a field when you have
>> the long IDE to the field.
>>
>> Put something ( long ID of field "foo", 2) into x
>> ...
>>
>> Function something obj pl
>>      Get the formattedrect of line pl of obj -- this works fine
>>      Get word 1 of the text of line pl of obj -- this what I want to do but
>> the syntax is wrong
>> End something
>>
>>
>> Issue 2). Can a reference to a variable be passed thru the message path
>> with a send command?
>>
>> Local foo
>> Put "stuff" into var
>> doit var
>> ...
>>
>> On doit @thevar
>> Put "ed" after thevar
>> -- here I want to send the reference to another handler
>> Send "another" & @thevar   In 1 second-- this is where I want the reference
>> to be sent and I
>>   --  know the syntax is wrong
>> End doit
>>
>> On another @thevar
>> If thevar = "stuffed" then answer "it worked"
>> End another
>>
>>
>> Regards,
>>
>>       Mike
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list