5000 lines of code

Jim Ault jimaultwins at yahoo.com
Thu Jun 9 08:12:40 EDT 2011


> I moved the "recyclable" code into the stack script and called it  
> from each object.
>
> BUT, the interesting thing as that, while the objects called the  
> code successfully, it meant
> that the individualised segments of code in the object that came  
> after the recyclable code
> stopped working properly.


Did you try referencing variables instead of passing them as parameters?

Usually if you call a function (or a handler) and have it return  
something, it will be a single string which can be used to update a  
single variable in the calling handler.

In the case of multiple variables that need to be updated, consider  
using reference parameters, therefore the calling handler will already  
have the updated contents of each variable.

Example is shown in the dictionary by finding "@"

The character @ is placed before a parameter name to pass a reference  
to the parameter instead of its value. Pass a parameter reference when  
you want a handler to change a variable in the calling handler, or  
when you want a handler to return more than one value.

Hope this helps

On Jun 9, 2011, at 2:18 AM, Richmond Mathewson wrote:

> Mark
>> Took me a couple of times through that to get what you meant. Ah...
>> you mean that same switch code is duplicated in other objects as  
>> well.
>> What I'd do in that case is move it out of the objects and make a
>> handler farther along the message path (the stack script, for
>> instance) as
>>
>> command ParseIt
>>   switch blahBlahBlah
>>   end switch
>> end ParseIt
>>
>> then in the mouseUp handlers just say
>>
>> on mouseUp
>>  ...
>>  ParseIt
>>  ...
>> end mouseUp
>>
>> it's make maintenance much easier and your stack will lose a bit of
>> flabbiness in the process.
>>
>
> It certainly seemed like good advice until I tried what you suggested:
>
> I moved the "recyclable" code into the stack script and called it  
> from each object.
>
> BUT, the interesting thing as that, while the objects called the  
> code successfully, it meant
> that the individualised segments of code in the object that came  
> after the recyclable code
> stopped working properly.
>
> This is a right bu**er as your advice would have meant I could  
> reduce my file size considerably.
>

Jim Ault
Las Vegas






More information about the use-livecode mailing list