Icon id conflicts?

2024-08-10 Thread David Epstein via use-livecode
I am moving a project I created in LC 5.5 to LC 10.0rc1.  Some buttons have 
their icon set to the id of an image found in a stack “in use.”  In some cases, 
this still works, but several buttons no longer look right in LC10, I assume 
because the icon number exists somewhere else in LC10.  How can I go about 
finding and imposing an id number for my image that will not encounter this 
conflict?

Alternatively, the dictionary says I can use an image name as a button’s icon, 
but the LC property inspector doesn’t let me enter non-numbers as an icon, and 
setting the icon to an image name from the message box has no effect (the image 
named is in a stack “in use”).

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Making controls less subtle

2024-08-06 Thread David Epstein via use-livecode
On my Mac, some LiveCode (10.0rc1) controls seem to me much too subtle, light 
gray where I would like there to be a distinct black line.  The  “slider” 
control looks to me as if it is disabled (although if I actually disable it, it 
gets even dimmer).  And the circle of the radio button, the rounded rectangle 
of a check box button, and the edges of an option button have this same light 
gray color.

Is there some way to change this?  

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


PDF widget print quality

2024-02-20 Thread David Epstein via use-livecode
I want to use the PDF widget to print a PDF with additional markings added in 
LiveCode.  Showing a simple PDF tax form in Widget 1 at 100% scale, I tried 
this script:

on p1

get the pageRect of widget 1

open printing with dialog

print card from (item 1 to 2 of it) to (item 3 to 4 of it) into it

close printing

end p1


This prints a full page at the proper size, but not with acceptable print 
quality; everything is slightly blurred and pixellated.  How can I get a good 
quality printout?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: LockLoc and grab

2024-01-23 Thread David Epstein via use-livecode
Let me try to clarify the problem I stated.

I am not trying to remove the button, I am trying to use the “grab” command to 
let a user move the button around the window by dragging it.

If I use a script to “set the loc” of a button to somewhere outside that 
group’s rectangle
- the group will resize if its lockLoc property is false (thus keeping 
the relocated button visible); 
- but the button will disappear if the group’s lockLoc property is true.

But when I use the “grab” command to relocate the button outside the group’s 
current rectangle the group does not resize even if its lockLoc property is 
false.



> A group with lockLoc set to false does not resize itself when an object in it 
> is moved by a ?grab? command.  Is this a bug?  Is there a simple workaround?
> 
> Recipe using 10.0.0 dp6 on an intel Mac:  
> 
> Create a button with this script:  
> on mouseDown; grab me; end mouseDown.  
> Group the button.  Confirm that the group?s lockLoc property is false.  Then 
> with the browse tool, drag the button past the edge of the group.  The button 
> disappears.
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


LockLoc and grab

2024-01-22 Thread David Epstein via use-livecode
A group with lockLoc set to false does not resize itself when an object in it 
is moved by a “grab” command.  Is this a bug?  Is there a simple workaround?

Recipe using 10.0.0 dp6 on an intel Mac:  

Create a button with this script:  
on mouseDown; grab me; end mouseDown.  
Group the button.  Confirm that the group’s lockLoc property is false.  Then 
with the browse tool, drag the button past the edge of the group.  The button 
disappears.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Comparative speed in switching among groups

2023-11-28 Thread David Epstein via use-livecode
Many thanks to Richard, for his interesting results and for the reminder that 
speed testing is pretty easy.  I ran a similar test on a slightly different 
task--flipping among 50 different groups, or 50 different cards--and got 
similar results.  Adding a “lock messages” sped up the card option by a factor 
of 4, but the group option was much, much faster even then.
I’m trying to make it possible to scan quickly through a long document.
The remarks of Richard and Alex raise these questions for me:
1.  Is LC recalculating the line wraps of all fields every time we go to a 
card?  Is it not doing that when a hidden field on a card is shown (or is the 
field somehow “ready to go” even when the field is hidden)?
2. On the question of resizing:  One possibility is to adjust groups when 
(i.e., just before) they are shown.  But would it be speedier to do this in 
advance, when nothing else is happening?  The User Guide says “timer based 
messaging [is] ideal where you want your user interface to remain responsive.”  
I’m not sure exactly how to do this, but it seems like on a resize event one 
could make a list of the hidden groups that need to be adjusted, and call them 
one at a time with something like 
send “upDateGroupLayout oneGroupID” to me in 10 milliseconds.  Is that right?

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Comparative speed in switching among groups

2023-11-25 Thread David Epstein via use-livecode
Does anyone have practical experience or an understanding of the engine that 
would cast light on the relative speed of some alternative ways of doing 
things?  I want to switch among a number of different groups, each of which may 
contain its own fields, graphics, buttons, and images.  Possible approaches:

- Have many different cards, each with a group peculiar to it, and GO TO each 
card as desired, or

- Have one card, with many different groups, and SHOW/HIDE the groups as 
desired, or

- Have many different cards, each with a group peculiar to it, and COPY a group 
from an unseen card to a single card that is always seen (and DELETE the 
unwanted group on that single card).

There are other considerations that affect a choice among these methods, but my 
concern here is the speed with which I can switch from displaying one group to 
displaying another.   I am wondering whether at some level these methods all 
amount to the same thing from the engine’s point of view (since everything is 
in RAM in any case).

Many thanks.

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together

2023-09-04 Thread David Epstein via use-livecode
I do not know how my problems accessing the rawClipboardData were overcome, 
but I succeeded in reading the array values there.  So I was able to address my 
original question of how to reconstruct in LiveCode a combination of text and 
image copied from another program.  Conclusion thus far:  no success.  If 
anyone is interested in this and might have some further suggestions, read on.

When I use the control key to invoke from the contextual menu “copy image” on a 
web page, the fullClipboardData[“image”] gets a string of humanly 
unintelligible characters that, when used as the text of a LiveCode image 
object, shows the copied image.   I did this for the picture of Robert Cailliau 
on webpage https://livecode.com/core-benefits-of-livecode/.  Call this String A.

To see how this information might be stored when I have copied both text and 
image, I selected from the word before to the word after that same picture, 
chose “Copy,” and then inspected the rawClipboardData["com.apple.flat-rtfd”], 
which seemed the most promising candidate of the various clipboardData array 
values.  Call this String B.

Something that looks kind of like String A appears in String B, but it is not 
the same.

At char 4097 of String B I see the first few characters of the beginning of 
String A, and think this might define the PNG data to follow.  But what follows 
is not the same as String A.

Here’s the start of string A:

âPNG
IHDR,,y}éusRGBÆŒÈDeXIfMM*ái††,†,ÿ`ÇÁ@IDATxÏΩ

And here’s char 4097ff of String B;

âPNG
IHDR,,y}éu IDATxúÏΩ{¨mYv÷˜sƵˆ„ÏÛ∏˜ú{Îvuuwuπ‹.€Ìˆ«!,d«2$qä¯a«9éCj,d°!dÅ"EâàB 

So my hope that String A could somehow be extracted from String B and used to 
“paste” the included image was disappointed. 

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together

2023-09-02 Thread David Epstein via use-livecode
Paul, getting the keys of the rawClipboardData worked for me too.  What didn’t 
work was trying to read the values.  See this part of my script, I hope shown 
this time without the asterisks gMail added before:

   lock clipboard
  …
   put the keys of the rawClipboardData into myK3  ## THIS WORKS
   …
   repeat for each line k in myK3
  try
 put the rawClipboardData[k] into temp[n]  ## DOESN’T WORK
  catch myError
 put myError into e4[n] ## ERROR IS TRIGGERED
  end try
  add 1 to n
   end repeat
   unlock clipboard



> From: Paul Dupuis 
> To: use-livecode@lists.runrev.com
> Subject: Re: Pasting text and images together?
> Message-ID: <3814cd2a-0f20-2bbb-8783-42fc57e68...@researchware.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
> 
> Since my method didn't work, I'd try Marks, namely to put the keys of 
> the clipboard array into a variable to look at
> 
> on mouseUp
> ? lock clipboard
> ? put the keys of the clipboarddata into tKeys1
> ? put the keys of the fullclipboarddata into tKeys2
> ? put the keys of the rawclipboarddata into tkeys3
> ? breakpoint
> ? unlock clipboard
> end mouseUp
> 
> I tested this in LC 10dp6 and it works. Once you see what keys are 
> present with your mixed text and images copied to the clipboard, you can 
> choose which clipboard array and keys to work with to get the data.
> 
> -- Paul
> 
> 
>> On 9/2/2023 10:36 AM, David Epstein via use-livecode wrote:
>> Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
>> test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
>> execution after the breakpoint, I get errors at each "try" in the script.
>> So it does not seem that I can write the fullClipboardData
>> or rawClipboardData to an array variable; and it does not seem that I can
>> access any element of the rawClipboardData array.  Further advice is
>> welcome.
>> 
>> Best wishes,
>> David Epstein
>> 
>> *on* a2
>> 
>> *lock* clipboard
>> 
>> *put* the keys of the clipboardData into myK1
>> 
>> *put* the keys of the fullClipboardData into myK2
>> 
>> *put* the keys of the rawClipboardData into myK3
>> 
>> *breakpoint*
>> 
>> *try*
>> 
>> *put* the fullClipboardData into ta2
>> 
>> *catch* myError
>> 
>> *put* myError into e2
>> 
>> *end* *try*
>> 
>> *try*
>> 
>> *put* the rawClipboardData into ta3
>> 
>> *catch* myError
>> 
>> *put* myError into e3
>> 
>> *end* *try*
>> 
>> *put* 1 into n
>> 
>> *repeat* for each line k in myK3
>> 
>> *try*
>> 
>> *put* the rawClipboardData[k] into temp[n]
>> 
>> *catch* myError
>> 
>> *put* myError into e4[n]
>> 
>> *end* *try*
>> 
>> *add* 1 to n
>> 
>> *end* *repeat*
>> 
>> *unlock* clipboard
>> 
>> *end* a2
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-02 Thread David Epstein via use-livecode
Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
execution after the breakpoint, I get errors at each "try" in the script.
So it does not seem that I can write the fullClipboardData
or rawClipboardData to an array variable; and it does not seem that I can
access any element of the rawClipboardData array.  Further advice is
welcome.

Best wishes,
David Epstein

*on* a2

*lock* clipboard

*put* the keys of the clipboardData into myK1

*put* the keys of the fullClipboardData into myK2

*put* the keys of the rawClipboardData into myK3

*breakpoint*

*try*

*put* the fullClipboardData into ta2

*catch* myError

*put* myError into e2

*end* *try*

*try*

*put* the rawClipboardData into ta3

*catch* myError

*put* myError into e3

*end* *try*

*put* 1 into n

*repeat* for each line k in myK3

*try*

*put* the rawClipboardData[k] into temp[n]

*catch* myError

*put* myError into e4[n]

*end* *try*

*add* 1 to n

*end* *repeat*

*unlock* clipboard

*end* a2
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-01 Thread David Epstein via use-livecode
To clarify my original question:

I'm not expecting the built-in paste command to handle this task; I'm
wondering if I can script my own paste command to handle it.

Richmond, I can write a script to "paste" an image by itself (by creating
an image and setting its text to clipboardData["image"]).

But is there some way I can access both the text and the image that are on
the clipboard after I have copied a combination of those from, e.g., a web
browser?  (Pasting to Apple Notes confirms that the clipboard contains both
text and image.)
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Pasting text and images together?

2023-08-30 Thread David Epstein via use-livecode
From a web browser, or from programs like Word or (Apple) Notes, it is possible 
to copy to the clipboard a single selection that includes both text and images.
Is there any way to paste all of this information to LiveCode—for example, 
placing the text in fields and the imageData in image objects, or showing 
everything in one field by setting the imageSource of some characters in that 
field?
After having copied such a collection of text and image information, the keys 
to the fullClipboardData seem only to include text and styled text options, 
with no indication of the images that are included on the clipboard.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Detecting when resizeStack is completed

2023-08-18 Thread David Epstein via use-livecode
How can I redraw objects after the user has resized the stack, but not 
continuously during the resize?  Releasing the mouse at the end of a resize 
does not appear to send a mouseUp message.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Remote debugger error message

2023-07-02 Thread David Epstein via use-livecode
panagiotis m asked:
@david
How do you trigger this error? Could you provide a recipe?

With the stacks that trigger the error it is hard to troubleshoot them without 
triggering the error.  So I’m starting with an entirely new stack, and will 
report if I encounter the problem.

I suspect the problem has something to do with a message that calls a handler 
in a stack-in-use.

Best wishes,
David

> 
> 
> On Thu, Jun 29, 2023 at 8:40?PM David Epstein via use-livecode
> mailto:use-livecode@lists.runrev.com>> wrote:
>> 
>> I?ve just started using LiveCode 9.6.9 and 10.0.0 DP 5 on two Intel
> Macs, and can do very little without getting this error message:
>> 
>> ?There was an error executing a script in stack
> com.livecode.library.remotedebugger.  No more information is available
> because the stack is password protected.?
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Remote debugger error message

2023-06-29 Thread David Epstein via use-livecode
I’ve just started using LiveCode 9.6.9 and 10.0.0 DP 5 on two Intel Macs, and 
can do very little without getting this error message:

“There was an error executing a script in stack 
com.livecode.library.remotedebugger.  No more information is available because 
the stack is password protected.”

I can click OK, but the error message soon returns.

Any suggestions?

Best wishes,
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


PDF widget and XPDFviewer

2023-06-17 Thread David Epstein via use-livecode
What is the relation between the widget “PDF” and the external “XPDFViewer” 
(both in Pro Features)?  The latter offers more direct access to a few 
properties (e.g., totalCharacterCount), while the widget syntax is a little 
simpler.  It does not appear that a PDF widget is a PDF Viewer, at least the 
widget’s name is not recognized as the name of a viewer when I try to call a 
function like XPDFViewer_Get(viewerName,property).

So do I need either to create a widget or create a viewer?  And are there 
non-obvious reasons to do one or the other?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Maximum field size

2023-01-20 Thread David Epstein via use-livecode
My testing attempts, like Bernd’s, show that the important “limits” are not 
just what LC can display in a field but what it can display without making 
things too slow.  I am also wondering if the new polyGrid has different 
characteristics, either its absolute limits or its performance when heavily 
populated.

Richard Gaskin asks “Why?”

I have developed a set of routines to analyze tabular data.  For KB or MB-sized 
files, it is convenient to display them in a field.  It would be simplest if I 
could also load GB-sized files and use my routines unchanged, but I accept that 
this is impractical.  But in order to design workarounds I’d like to get as 
much clarity as possible on what limits I am working around.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Maximum field size

2023-01-19 Thread David Epstein via use-livecode
Thanks to Bernd for this:

> Maximum length of a line in a field:
> 65,536 characters storage
> No more than 32,786 pixels wide for display

This seems to mean we can have a 65k long line only if each character’s width 
is around half a pixel.
And that if the character width is 10 pixels the maximum line is 6,553 
characters.
Or does “for display” mean something else?

And, if we respect the line length limit, is the number of lines in a field 
limited only by however much of minimum(RAM, LC’s 4GB “total addressable 
space”) is not being used by something else?
So for example would trying to load a 2.1 GB variable in a field surpass the 
4GB limit, because the variable and the field would each need 2.1 GB?

Best wishes,
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Maximum field size

2023-01-18 Thread David Epstein via use-livecode
How many rows or columns or characters can reasonably be displayed in a 
LiveCode field?  A 1.39 GB text file seems pretty clearly to surpass the limit, 
but how much do I need to subdivide it?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Livecode performance problem

2022-08-20 Thread David Epstein via use-livecode
I didn’t text the speed, but why not

put fld A into x[1]
put fld B into x[2]
put fld C into x[3]
put fld D into x[4]
combine x by column
return x

> 
> I have a set of fields, call them A, B, C, and D. Each has the same 
> number of lines. Each field has different text (per line)
> 
> I need to combine the data - frequently - into a form that look like:
> 
>  C>


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Chart widget question

2022-08-03 Thread David Epstein via use-livecode
Using LC 10 dp2, I am trying to script the creation of a chart widget.  

My command “create widget myName as chart in group myMain” creates only a small 
gray box.  

The LC command “New Widget/Chart” creates a line chart, ready to be modified.  
What is the LC command doing that I am not?

Or:  how do I find the script that LC runs when the “New Widget/Chart” command 
is chosen?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Is there a way to create a generic setprop handler?

2022-08-03 Thread David Epstein via use-livecode
Control “A” has many custom properties that are set by a variety of other 
controls.  If Control “A” has a "setProp property1” handler, it can react when 
property1 gets set.  But is there a way to give Control “A” a general handler 
that will be triggered whenever any of its custom properties is set?

David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Using LiveCode with Mac Photos App

2022-04-18 Thread David Epstein via use-livecode

I want to allow selection of some images from my Mac Photos library and show 
them as “referenced” images in a LiveCode stack.  Is there an efficient way to 
do this?
What would be great is to open Photos, drag images from there to my LiveCode 
stack, and record in LiveCode the file location of the original image.  But 
this seems not to work from within Photos, only with images that have been 
exported (e.g., I can drag exported images from my desktop to a LiveCode stack 
and get the dragData[“files”]).
Is there any way from within Photos to gain access to the file locations for 
convenient use by LiveCode?
David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Shaping an image to fit in a polygon

2021-10-18 Thread David Epstein via use-livecode
Jacqueline Gay’s suggestion is excellent, and by exactly aligning the rect of 
the polygon with the rect of the image being “trimmed”, I can avoid having the 
image centered or repeated.  See script below.  

I am still wondering what goes wrong with my alphaChannel approach to showing 
irregularly shaped images.  Is there some imprecision in the “within” function? 
 This would be important to know for other uses of it.

David Epstein

on imageToGrc gID
  # fills graphic id gID with image it is positioned on; works for polygon, 
oval, regular, or rectangle
  set the linesize of grc id gID to 0
  set the filled of grc id gID to false
  wait 1 ticks # seems needed so that linesize of 0 is respected
  hide grc id gID
  import snapshot from rectangle globalRect(the rect of control id gID)
  put the short id of image (the number of images) into imID
  set the rect of image id imID to the rect of grc id gID
  set the filled of grc id gID to true
  set the backgroundPattern of grc id gID to imID
  show grc id gID
  set the loc of grc id gID to the bottomRight of grc id gID ## to make it 
visible
  hide image id imID  ## note:  don’t delete, or polygon loses the image
  choose browse tool
end imageToGrc

function globalRect theRect
  return globalLoc(item 1 to 2 of theRect),globalLoc(item 3 to 4 of theRect)
end globalRect
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Shaping an image to fit in a polygon

2021-10-16 Thread David Epstein via use-livecode
I am trying to create an image that will appear to have the shape of some 
arbitrary polygon.  The idea is to set the image's alphaData so that pixels 
within the polygon are opaque, and those outside the polygon are transparent.  
The scripts below create a rectangular image of whatever is under the polygon's 
enclosing rectangle, and then adjust the alphaData of that new image.  But 
while the new image gets trimmed a bit, the result does not match the shape of 
the designated polygon.  Any thoughts?

David Epstein

on action gID ## gID is the short id of the polygon
  import snapshot from rectangle globalRect(the rect of control id gID) 
  put the short id of image (the number of images) into imID
  set the width of image id imID to the width of grc id gID
  set the height of image id imID to the height of grc id gID
  set the loc of image id imID to the loc of grc id gID
  set the polyCrop of image id imID to gID
end action

function globalRect theRect
  return globalLoc(item 1 to 2 of theRect),globalLoc(item 3 to 4 of theRect)
end globalRect

setProp polyCrop polyID
  -- crop target image's alphadata to show only points within grc id polyID
  put the filled of grc id polyID into fillState
  set the filled of grc id polyID to true
  put the rect of the target into r
  put numToChar(255) into P ## opaque
  put numToChar(0) into T ## transparent
  repeat with y = 1+item 2 of r to item 4 of r ## SEE NOTE*
repeat with x = 1+item 1 of r to item 3 of r
  put x,y into myPoint
  if within(grc id polyID,myPoint) then put P after hold else put T after 
hold
end repeat
  end repeat
  set the filled of grc id polyID to fillState
  set the alphaData of the target to hold
end polyCrop

* NOTE:  the "1+" is these statements is my effort to step through the exact 
number of pixels in the width and height of the image.  The number of values in 
the series (item 1 of the rect of the image) to (item 3 of the rect of the 
image), inclusive, is 1+ the width of the image.  (But I am not really sure 
whether to add 1 to the first value or subtract 1 from the last value).
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Implementing UNDO

2021-05-21 Thread David Epstein via use-livecode
LC’s built in undo does not appear to undo anything done by something I have 
scripted.
My approach is to use a global array variable “u” to store information needed 
to undo the most recent action.  On each action, an “undoInit” puts empty into 
u, after (if necessary) cleaning up anything u’s values indicate is left over 
from the prior action (e.g., actually deleting an object that had been only 
“pseudo-deleted” (hidden) so as to make the user’s choice of deletion 
undoable).  Then the appropriate new values are loaded into u.  The main 
elements I use are

# u["cardID"] = short id of the card where the undoable action was taken
# u["stackName"] = short name of the stack where the undoable action was taken
# u["changed"], list of objects being changed, each line has:  propName,objectID
# u[propName,objectID] holds prior value of that property of that object (one 
key/value for each line of u["changed"]
# u["removed"], list of objectID,cardID,stackName for objects being 
pseudo-removed
# u["added"], list of objectID,cardID,stackName for objects being added
# u["cardsRemoved"], list of cards being pseudo-removed, each line has:  
cardID,cardNumber
# u["cardsAdded"], list of cards being added, each line has:  cardID,cardNumber

The “Undo” command makes sure we’re on card id u[“cardID”] of stack 
u[“stackName”}, then checks for non-empty values of 
u[“changed”],u[“removed”],u[“added”],u{“cardsRemoved”], and u[“cardsAdded”], 
and uses values stored in u to restore the prior state of things, while 
reloading u with values reporting the state of things now being reversed.

For text, I load u[“changed”] with “htmlText”,, and load 
u[“htmlText”,] with the htmlText of that field before the latest 
editing.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Smooth scrolling

2021-02-01 Thread David Epstein via use-livecode
My impression is that a LiveCode field scrolls less smoothly than a comparable 
field in some other programs, such as MS Word and Scrivener.  If I paste about 
25,000 words into a word wrapped scrolling field, and then drag the scrolling 
thumb up and down there is much more jumpiness than I see when I do the same 
thing to the same text in those other programs.  (LC 9.6 on Mac OS 10.12.6).  
Do others see the same thing?  Does anyone know the underlying cause of this, 
or a remedy?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Updating a menubar button on Mac

2020-09-21 Thread David Epstein via use-livecode
I can use a “mouseEnter” handler to update a menu button’s contents just before 
the user displays that menu.  But if that menu button is part of the stack’s 
menubar group on a Mac, the Mac menu does not seem to receive the mouseEnter 
message and the menu is not updated.  Is there a workaround?  Thank you!

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Saving stacks before closing

2020-05-24 Thread David Epstein via use-livecode
I want to give the user a choice of whether to save changes before closing a 
stack.  To script this, I will handle the closeStackRequest message, and find a 
way to keep track of whether the stack in question has been changed since it 
was last saved.

What I am trying to figure out is under what circumstances LiveCode takes care 
of this without my scripting it.  In the LiveCode IDE, trying to close an 
unsaved stack seems automatically to ask me whether I want to save changes (but 
I have not found a handler in the backscripts that implements this).  This is 
true of stacks I have created with the IDE “new stack” tool and then try to 
close.  Is it also true of stacks I have created by script?  

And what happens in a standalone?  Does this feature still work there?

In short, do I need to script an option to save changed stacks before closing, 
or can I rely on LiveCode to take care of this?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: DataGrid question...

2020-03-30 Thread David Epstein via use-livecode
This is more or less Jacqueline Gay’s suggestion, but with a couple of 
wrinkles.  You do need to adjust for the horizontal scroll of the field (I’m 
not sure about borders or margin).  And if I am not mistaken sometimes “the 
tabStops” will not have an entry for each tab, if the column width stays 
constant.
My approach is to keep a global called gColGuide, which gets reloaded when 
column widths change.  It has one line per column, with leftEdge,0,rightEdge,0 
in each line.
The function used to load gColGuide is shown below.

put word 1 of the clickLoc into x
put word 2 of the clickLine into L — line number
put the hScroll of fld “table” into hs

put colGuide() into gColGuide

function mCol x,hs — returns column number for horizontal pixel x, consulting 
gColGuide.  hs is the field’s hScroll.
  global gColGuide
  add hs to x
  put 1 into c
  repeat for each line k in gColGuide
if x > item 1 of k and x < item 3 of k then return c
add 1 to c
  end repeat
  return empty
end mCol-- Any need to adjust for borders and margins?

function colGuide — used to load gColGuide with one line per column; each line 
has left,0,right,0
  set itemDelimiter to tab
  put the number of items in fld "headers" of into cz
  set itemDelimiter to comma
  get the tabStops of fld “table”
  put "0," before it
  put the left of fld “table” into fL
  repeat with n = 1 to min(cz,(-1 + the number of items in it)) -- so that 
colGuide will only cover the used columns.
put fL+8 + item n of it,0,fL+8 + item n+1 of it,0 & return after hold
  end repeat
  if cz > n then
put item 3 of line -1 of hold - item 1 of line -1 of hold into w
repeat with m = n+1 to cz
  get item 3 of line -1 of hold
  put it,0,w + it,0 & return after hold
end repeat
  end if
  put fL into item 1 of hold
  return hold
end colGuide

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Reading and writing globals by script

2019-08-10 Thread David Epstein via use-livecode
I want to write a function that will read and write to any named global.  What 
I have below seems to work, but I’m not sure quite why.  Usually, “put gName 
into oldVal” for a global named gName would put the value, not the name, of 
that global into oldVal.  But here it does not.

function globalSwap gName,gVal
   -- Return the existing value of global gName and load gVal into that same 
global
   do "global" && gName
   do "put" && gName && "into oldVal" # "put gName into oldVal" doesn't work 
here.
   do "put gVal into" && gName
   return oldVal
end globalSwap

Is there some way to write this with fewer or no uses of “do”?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: script for redo/undo text?

2019-07-10 Thread David Epstein via use-livecode
I cannot help with the project of "unlimited" undo/redo, but a simple one-layer 
undo for fields is not hard to implement.  

Sean Cole's suggestion that we should record the field state whenever a key is 
pressed I think does more than is wanted; if you type 10 characters, you don't 
want to choose Undo 10 times to get rid of them.  

My approach is to record the field state on keypresses ONLY if there is a text 
selection (about to be lost when the key is pressed) rather than an insertion 
point.  If text has been added but no text has been lost, you don’t need an 
Undo command to remove what was added.  If you also record the field's state 
before anything is typed in it, and before the Undo command itself is executed, 
and before any scripted handlers change the field, I think this will resemble 
ordinary Word Processor behavior.

on keyDown
  if the selectedText is not empty then uStoreFieldState the short id of the 
selectedField
  pass keyDown
end keyDown
-- and a similar handler for the other keys Sean mentions, although I don't 
think for arrow keys.  

on uStoreFieldState fID -- fID is the short id of the field
  global u
  put the selectedChunk into myChunk
  put fID into u["fieldModified"]
  put the htmlText of fld id fID into u[fID]
  put word 2 of myChunk into u["chunkA"]
  put word 4 of myChunk into u["chunkB"]
end uStoreFieldState

Then on undo, you read the values of u to revise the field, and reload u with 
the state of the field just before undoing.  I store the chunk information so 
that undo can restore the selection as well as the text to its prior state.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: A question about openCard

2019-06-08 Thread David Epstein via use-livecode
Jacqueline is correct:  if I’m not debugging, the execution contexts is not in 
the list of recentCards.
But my palette still does not appear in the list of recentCards.  Further 
testing reveals:  although activating a palette triggers a resumeStack message, 
and leaving a palette triggers a resumeStack message in the stack activated, 
palettes do not get listed in “the recentCards”.
So I think I will resort to a global.  In my main stacks, a resumeStack handler 
should 
— compare the name of this stack with a global “gActiveStack”
— if they are not the same, carry out init actions, and put the name of this 
stack into gActiveStack.
David Epstein

Jacqueline Gay wrote:
I wouldn't expect the execution contexts to be in the list but it sounds 
like that's a result of the debugging process itself. Is it different if 
you just log it to the message box without the debugger?

get the recentCards
put it
... etc

Does the palette not appear anywhere in the list at all?

> On Jun 8, 2019, at 9:13 AM, David Epstein  wrote:
> 
> Several people gave helpful replies to my question, including pointing out 
> that this is a case of “resumeStack”, not “openCard”:
> 
> Is there some simple way that an openCard handler can branch based on what 
> card it is coming from?
> 
> When a user goes to a different card in a stack, or to a different stack, I 
> use an “openCard” handler to set things up.  But I do not want those actions 
> taken if the user is merely “returning” to a card after using a palette tool, 
> or after a palette tool has been opened.
> 
> Jacqueline Gay suggested using the “recentCards” to determine what card the 
> user is coming from.  So I wrote this handler:
> 
> function resumedTheSameCard
>   -- call this in a "resumeStack" handler.
>   -- returns true if palette "tTools" has just been active and the 
> resumeStack message was received by the same card that had been active when 
> that palette was activated.
>   -- returns false if we are coming from a different card, either directly or 
> with a palette activation in between.
>   get the recentCards
>   if the long id of stack "tTools" is not in line 2 of it then return false 
> -- nb should work even if palette "tTools" stack has several cards
>   return line 1 of it = line 3 of it
> end resumedTheSameCard
> 
> But this does not work.  When I debug, I see that line 2 of the recentCards 
> does not refer to a card on my palette stack (“tTools”); it refers instead to 
> a card in the stack “Execution Contexts”.
> 
> Why is that LiveCode system stack appearing in the recentCards, and why is my 
> palette not appearing there?
> 
> Many thanks.
> 
> David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: A question about openCard

2019-06-08 Thread David Epstein via use-livecode
Several people gave helpful replies to my question, including pointing out that 
this is a case of “resumeStack”, not “openCard”:

Is there some simple way that an openCard handler can branch based on what card 
it is coming from?

When a user goes to a different card in a stack, or to a different stack, I use 
an “openCard” handler to set things up.  But I do not want those actions taken 
if the user is merely “returning” to a card after using a palette tool, or 
after a palette tool has been opened.

Jacqueline Gay suggested using the “recentCards” to determine what card the 
user is coming from.  So I wrote this handler:

function resumedTheSameCard
  -- call this in a "resumeStack" handler.
  -- returns true if palette "tTools" has just been active and the resumeStack 
message was received by the same card that had been active when that palette 
was activated.
  -- returns false if we are coming from a different card, either directly or 
with a palette activation in between.
  get the recentCards
  if the long id of stack "tTools" is not in line 2 of it then return false -- 
nb should work even if palette "tTools" stack has several cards
  return line 1 of it = line 3 of it
end resumedTheSameCard

But this does not work.  When I debug, I see that line 2 of the recentCards 
does not refer to a card on my palette stack (“tTools”); it refers instead to a 
card in the stack “Execution Contexts”.

Why is that LiveCode system stack appearing in the recentCards, and why is my 
palette not appearing there?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

A question about openCard

2019-06-02 Thread David Epstein via use-livecode
Is there some simple way that an openCard handler can branch based on what card 
it is coming from?

When a user goes to a different card in a stack, or to a different stack, I use 
an “openCard” handler to set things up.  But I do not want those actions taken 
if the user is merely “returning” to a card after using a palette tool, or 
after a palette tool has been opened.

I’m not sure I understand the full range of events that “close” a card so that 
returning to it triggers “openCard.”  Does this happen if I set an insertion 
point or select text in an unlocked field in a palette, or the user types 
there?  Does it happen if I open a palette, or move a palette, or if the user 
clicks on the palette?

Many thanks.

David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Multiple regression in LiveCode?

2019-01-18 Thread DAVID Epstein via use-livecode
Has anyone written a LiveCode function that will take a table of 2 or more 
independent variables and 1 dependent variable, and return coefficients, 
intercept, and standard errors for a multiple regression?


David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Repeat for each line of a variable or field?

2019-01-12 Thread David Epstein via use-livecode
I've done a little bit of speed testing showing extremely slight differences, 
but wonder if anyone who understands the "engine" can advise on this:

Is there a difference between these two approaches?

(1) put fld 1 into txt; repeat for each line k in txt; etc.

and
(2) repeat for each line k in fld 1; etc.

For no very good reason, I tend to do (1), but have begun to wonder:  for a 
very lengthy field 1, does my writing to a variable use up more RAM, and so 
perhaps injure performance?  Or is the engine in effect writing to a variable 
either way?  Is a variable read more quickly than a field?  

Many thanks.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Large files crash on Windows 10

2018-10-31 Thread DAVID Epstein via use-livecode
Does anyone else have problems dealing with large files on Windows 10?  My main 
LiveCode tool is a stack of about 1.5 MB, and I use it to create, save, and 
open LiveCode stacks that store text and graphics.  These "content" stacks can 
be anywhere from a few kilobytes to 50 MB or more.  On an iMac, these all run 
smoothly.  On Windows 10, my larger content stacks (>10 MB) will sometimes 
close unexpectedly, or crash LiveCode entirely.  The typical trigger is either 
executing a save command, or clicking on a list of cards to navigate to a card 
that contains a large table of text.
Does anyone have relevant experiences or suggested remedies or ways of better 
diagnosing the problem?

Perhaps relevant is that on the Mac I mostly use LC 5.5, on Windows 10 I am 
using LC Community 9.0 (dp4).

Many thanks.
David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Area of regular polygon triangles

2018-06-07 Thread David Epstein via use-livecode
While trying Mike Bonner's suggestion of "manual" measuring, I learned the 
answer:  a regular polygon whose official length is L and width is W is 
inscribed in the oval whose length is L and width is W.  So for an equilateral 
triangle the area will be 3/4 * 3^.5 * R^2 (where R = L = W).

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Area of regular polygon triangles

2018-06-06 Thread David Epstein via use-livecode
If a regular polygon has 4 or 8 sides it seems to be inscribed so that all 
points touch the square defined by the object’s height and width, which means 
that it should be fairly easy to deduce the polygon’s area.  
But with 3 sides, the triangle appears slightly smaller than the maximum size 
that could fit into that square.  Is there some math that would give me the 
area of that triangle from the height and width of the square (i.e., the 
official height and width of the polygon object)?
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Text with accented characters

2018-06-03 Thread David Epstein via use-livecode
I am importing some text where certain characters do not look right.  When I 
test their charToNum values I get, for example, 226 and 232.  226 is shown as a 
comma, but should be a lower case a with a circumflex, and 232 is shown as an 
upper case e with an umlaut but should be a lower case e with accent grave.  Is 
there some font I can choose, or some other action I should take, to get these 
(and others) to display properly?
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


HilitedLine of list field lost when unlocked field selected

2018-05-30 Thread David Epstein via use-livecode
This seems like a problem that I’ve solved before, but I can’t recall how.  
With a line hilited in a locked list-behavior-true field, I can use the mouse 
to select text in any of a number of unlocked fields without disturbing my 
list’s hilite.  But if I use the tabKey to move the insertion point or 
selection from one unlocked field to the next, the list hilite is lost.  How 
can I preserve it?

Many thanks.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: FormattedHeight of a field and its contents

2018-02-02 Thread David Epstein via use-livecode
Thanks for the responses on this.  I used Bernd’s tool and did some more tests, 
and found some things that may be helpful to others.

While the left and right margins of a field are meant literally (a 5 pixel left 
margin leaves 5 white pixels to the left of the text), the top margin is more 
complicated, no doubt owing to the variety of textHeights that need to be 
accommodated.  For example, a margin of "0" will often clip the top of the 
text--as if "0" meant a "negative margin".

6 seems to be a magic default value for a field's top margin, which avoids 
clipping the content.  With horizontal gridlines visible, a 6 pixel buffer 
makes the top row the same height as the other rows.  And with a 6 pixel buffer 
the formattedHeight of the field will exactly match the formattedHeight of the 
field's content (although a non-zero borderwidth or a horizontal scrollbar 
changes this).

Thus--what I wondered about in my original post--with a margin less than 6 the 
formattedHeight of the field is less than the formattedHeight of the content; 
the content is in effect clipped.  At smaller textHeights this will be visible, 
while at larger textHeights only white space above the characters is clipped.

I was trying to answer two questions, and I think I'm pretty close.

1. How do I make sure that the field's contents are all visible if I set the 
field's height to the formattedHeight?  Answer: Set the top and bottom margins 
to 6. For the left and right margins, even 1 pixel should be enough to keep 
everything visible.

2. What margins will provide a symmetrical look for a text box?
A top margin of 6 doesn’t look like a 6 pixel margin; how it looks depends on 
the textHeight.  I estimate that its apparent height is one fourth of the 
effective textHeight, and I use this to size the other margins in the 
“tightMargins” handler below.
While the top margin of 6 looks good with horizontal gridlines, without them 
(and especially if you show a text baseline) it looks too small compared to the 
space between subsequent lines.  To match that larger space, in effect doubling 
the apparent top margin, add one third of the effective textHeight.  See 
“niceMargins” handler below.

Example of usage:
set the margins of fld 1 to the niceMargins of fld 1
set the height of fld 1 to the formattedHeight of fld 1

getProp niceMargins
   put the effective textHeight of the target into t
   put round(t*7/12) into m1
   put round(t/3) into m2
   return m1,6+m2,m1,m1
end niceMargins

getProp tightMargins
   put round(.25*the effective textHeight of the target) into m
   return m,6,m,max(6,m)
end tightMargins

Improvements to these are welcomed.

David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

FormattedHeight of a field and its contents

2018-01-31 Thread David Epstein via use-livecode
Is there somewhere an explanation of how a field’s textSize, borderWidth, 
margins, and formattedHeight interact?  

According to the dictionary entry for “formattedHeight”, a field’s 
formattedHeight is calculated “including top and bottom margins”, while the 
formattedHeight of a chunk is calculated “disregarding margins.”

That does not seem consistent with these results for a field whose textSize is 
16 and whose margin is 4:

the formattedHeight of line 1 of fld 1 19
the formattedHeight of line 1 to 2 of fld 1  38
the formattedHeight of fld 1   15  if there’s one 
line of text
the formattedHeight of fld 1   34  if there are two 
lines of text.

Even though there are top and bottom margins of 4, the field’s formattedHeight 
is smaller, rather than larger, than the formattedHeight of its contents.

A perhaps related question:  Why does a field margin of zero clip the visible 
text at the top and left?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Identifying empty lines of text

2018-01-12 Thread David Epstein via use-livecode
I use “the number of words in myString = 0” to test whether a line of text 
appears empty, since I want a line with only space characters to be understood 
as empty.
But a line of text I pasted from elsewhere contained an invisible character 
whose charToNum value is 202, and this was counted as a word by my script.
Is there a better way to test for a line of text that has no visible characters?
Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Auto scrolling a locked field when mouse comes to edge

2017-02-01 Thread David Epstein via use-livecode
To clarify:
For a locked field with autohilite and traversalOn both true, the “built in” 
auto scrolling works the same as with an unlocked field.  I’m looking for a way 
to script this kind of auto scrolling with autohilite and traversalOn both 
false.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Auto scrolling a locked field when mouse comes to edge

2017-02-01 Thread David Epstein via use-livecode
When the mouse drags across text in an unlocked (horizontally and vertically) 
scrolling field, the field automatically scrolls at a legible rate to display 
the (previously hidden) text that the mouse was dragging toward.
Has anyone scripted a way to reproduce this effect for a locked field?
Many thanks.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Bizarre problem setting a custom property

2016-09-18 Thread David Epstein
From the message box, I type

set the autoFitted of group “a” of stack “specs” to false

Works as expected.

But if I type

set the frameOptions of group “a” of stack “specs” to false

Fails with this message:
Message execution error:

Error description: Chunk: error in object expression

Hint: 

Various other property names also fail, but I can’t detect a pattern.
Any insights?

Many thanks,

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

getProp puzzle

2016-09-11 Thread David Epstein
The script of stack “A” has a getProp handler to report the number of lines in 
an object’s script:

getProp nSL
  return the number of lines in the script of the target
end nSL

With stack A frontmost, I type in the message box “the nSL of this stack” or 
“the nSL of stack’A’”, and I get the expected result.  But with stack A still 
frontmost, if I type in the message box “the nSL of stack ‘B’” I get an empty 
result (not even a “0”).  

What am I missing?

Thanks very much.

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: MouseMove message interrupted when I change cards

2015-11-11 Thread David Epstein
Thanks to Scott Rossi, whose example is indeed what I am trying to do, and to 
Matt Maier, who warns me that there are aspects of mouseMove I don't quite 
understand.
In trying to see why Scott's example works and mine does not, I discovered that 
my "mouseleave" handler seemed to be the problem.  If I have "on mouseleave, go 
card 1, end mouse leave" in my script, then the mouseMove message stops firing 
after it triggers one change of card, perhaps because that change of card makes 
LC think I have "left" the control my mouse was moving in.  (But why does it 
not still detect a "mousemove" on that same control on the card I have moved 
to?  It seems like mouseMove doesn't start reporting unless there has been a 
"mouseEnter" event, and with my change of card my mouse did not enter the 
control because it was already in it).
Adding my mouseLeave handler to Scott's script won't show this unless I also 
change the points of his polygon so that it is a single rectangle rather than 3 
non-adjacent rectangles.  With his polygon, the mouse really is "leaving" and 
then re-entering the polygon when it moves from one rectangle to the next; so 
that on each change of card there is a new mouseEnter event that restarts the 
mouseMove message stream.
I tried Matt’s idea of catching all mouseMoves, but still had problems.  So I 
have placed the entire “quick browse” diagram in a separate palette, where 
mouseMove is not bothered by card changes in the main stack.
David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

MouseMove message interrupted when I change cards

2015-11-10 Thread David Epstein
Among the controls in a group with background behavior I have a “quick browse” 
control — a polygon graphic whose many rectangular parts represent cards in the 
stack.  I handle “mouseEnter” and “mouseMove”, and use the mouseH to calculate 
which card to go to.
I find that the “mouseMove” message is interrupted when I change cards.  Even 
though the mouse is moving across what looks like the same graphic, LC seems to 
treat each card’s representation of that graphic as a separate control.  Thus 
when a mouseMove causes navigation to a different card, no more mouseMove 
messages are received, unless I move the mouse out of and back into the control.
Is this how things should work?  Do I need to move my control to a palette so 
that the change of card that it triggers does not interrupt its own operation?  
Are there other options?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Field loses its identity as a target

2015-07-29 Thread David Epstein
Sorry, I see my long question appeared twice; my eMail reported it undelivered, 
so I tried again.

Thanks to Richard for his sound advice, and Jacqueline for the promising 
theory—promising because I have noticed that disabling locked fields with 
visible, non-3D borders does not make their borders gray, so that their enabled 
status is not clear if they contain no text.

But disabling does not seem to be the source of my problem, as I have inserted 
into my script, just before the point of failure, tests both for the existence 
and the enabled of the field whose identity has been lost.

I think it will be easier to circumvent this problem than to figure it out, but 
I will report back if I narrow it down.  

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Script-controlled export of animation from Livecode?

2015-07-29 Thread David Epstein
Thanks for the suggestions on this.  If I understand them correctly, they seem 
to require using some tools outside of LiveCode.  Can any of those tools be 
controlled by a LiveCode script?  What I want to do is write a script so that a 
user clicking my button will create some kind of video file from the action 
that my script is displaying in a LiveCode stack.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Field loses its identity as a target

2015-07-29 Thread David Epstein
I have encountered a bizarre problem that occurs in a somewhat complicated 
context.  I wonder if anyone has experienced anything similar.

In short:  when I click a locked field on one occasion “the long id of the 
target” returns the expected result; but when I click on it subsequently “the 
long id of the target” returns the long id of the card instead.

Details:
To allow the user to edit certain properties of a card, I copy a “dropPanel” 
group to that card, allowing the user the adjust various controls on that group 
whose settings I use to adjust the appropriate properties of the card.  I want 
the “dropPanel” to disappear if the user clicks outside of it, so I insert a 
frontScript that, on mousedown, checks whether the targeted object is part of 
the dropPanel group.

This has worked well for a long time, but I now encounter this problem.  
Several of the controls in one of my dropPanels are locked fields (call one of 
these “A”).  The first time one is clicked on, it operates as expected.  But on 
subsequent clicks my dropPanel gets deleted.  When I debug my frontScript, I 
see that on the first occasion the long id of the target is recognized as 
“field id x of group id y of… etc.”—and my script confirms that this control is 
indeed part of the dropPanel group and so clicking it should not delete that 
group.  On subsequent clicks, however, that same target is interpreted as “card 
id x… etc.”, which of course is not a member of the group, and this causes my 
group to be deleted.

Why does my field “A” lose its identity between these two clicks?  When working 
properly, the click on the locked field causes a different group to be created 
adjacent to it, allowing the user to select one or more things from a list 
field (“B”), and then click a Cancel or OK button.  (This subgroup does not 
have the auto-close feature).  The OK button of that subgroup sets a custom 
property of and sets the text of field “A”—neither of which seems like it 
should cause that main field no longer to be recognized as a target.  And the 
Cancel button does nothing at all to the main field.  OK and Cancel both delete 
the subgroup that includes them and Field “B”.

Testing various combinations of events, I learned that the problem arises 
whenever the user selects something in the list field “B”—regardless of whether 
he clicks OK or Cancel—but there is no problem if he never makes a selection in 
that list field “B”—again, regardless of whether he clicks OK or Cancel.  (And 
if toggleHilites is true for field “B” the problem arises even if the user 
removes a selection he initially made).

So it seems as if nothing my scripts do to Field “A” is associated with its 
losing its identity; it is rather the fact that one or more lines have been 
selected in a different field (the list field “B”).  Two more symptoms
- clicking on a second locked field that operates in the same way also causes 
the problem; i.e., two clicks on one field or one each on two fields makes no 
difference.
- Field A does not seem to lose its identity until the subgroup containing 
Field B is deleted.  If a wayward user repeatedly clicks on Field A and makes a 
selection in Field B without clicking OK or Cancel, the script as written will 
keep creating new subgroups with new Field B’s.  Only after the user has 
repeatedly clicked OK or Cancel to remove the duplicative series of subgroups 
will a click on Field A cause the problem.

Thanks very much for any insights about this.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: menu buttons and showname

2015-07-03 Thread David Epstein
“Set the label of button myBtn to space” makes an option button appear blank 
but does not interfere with a user’s subsequent choice of an option.
While disabling the button or hiding the button are other ways of making clear 
that no option is in effect, an able but blank option button means that an 
option can be put into effect in one step, not requiring some other action that 
enables or shows the button.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Insertion point problems

2015-06-25 Thread David Epstein
One more try on the second part of my original post.

In LC 7.01, Mac Yosemite, I find that the insertion point blinks once when 
placed by clicking or typing, then disappears.  It will also blink once in its 
most recent position if I click the title bar, but again it disappears.
 
Also, if I type a tab key at the beginning of the line that has tabStops, the 
blink will be at the beginning of the line, not indented (even though if I then 
type a character it will be indented).

This was not true in LC 5.5, and seems like a major obstacle to working with 
text.  Do others see these symptoms?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Insertion point problems

2015-06-22 Thread David Epstein
1.  With a word selected in field 1 of the topStack, a menu button in a palette 
issues a command “Paste”.  The handler for this command includes

set the defaultStack to the topStack
get the selectedChunk
— test whether the chunk is a suitable place to paste, and if so then
paste

This works fine if there is actually a word selected in field 1.  But if there 
is only an insertion point it does not work; the selectedChunk is reported as 
empty.  (On mouseDown on the palette menu, a selected word stays selected; but 
a blinking insertion point disappears).

2.  Results above both in LC 5.5 and LC 7.01.  But I notice another problem in 
7.01 (unlike in 5.5):  the insertion point does not blink.  I see it blink just 
after typing a character, and it blinks once when the stack is activated, but 
when nothing is happening there is no indication of where the insertion point 
is.

Do others see this, or have solutions?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Resolution of PDF in player object

2015-05-26 Thread David Epstein
In the past, when I displayed a PDF in a player object on my PowerPC Mac Mini, 
I could scale it to, say, 1.5x the formattedWidth and formattedHeight, and see 
it beautifully displayed at full resolution.  On my newer MacBook Air and iMac 
this is not true; the PDF looks terrible when scaled to anything other than 
100%.  And if I print it, even at 100%, I get screen quality, i.e., very bad, 
resolution.  Has something changed?  Can LiveCode not display or print PDFs at 
full resolution on an Intel Mac?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Can a script preempt substack name conflicts?

2015-05-14 Thread David Epstein
With stack A already open, I open stack B and get a alert like this:

"A stack "" in file  is already in memory.  
The Revolution UI does not distinguish stacks which have identical names, so 
editing these stack files while both are in memory could result in data loss.”

Is it possible by script to intercept the message that generates this alert, 
and rename either the substack that is already in memory or the substack of the 
stack I am trying to open, so as to avoid both the alert and the risk of data 
loss?  My impression is that if I try to learn the substack names of a file I 
will already be loading that file into memory, and it will be too late to head 
off the alert.

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: What is driving the MB of a stack?

2015-04-29 Thread David Epstein
Thanks to Scott Rossi for calling my attention to “unplaced groups,” which seem 
important enough to be better known.  I found and purged a few of these, but 
trimmed only a few KB off my 4.3 MB stack, which still seems much larger than 
its (known) content can explain.  Are there any other ways of diagnosing what’s 
going on?

David Epstein

> An issue that has been discussed in the past might be unplaced groups --
> groups that have been created at some time but aren't being used in the
> stack.  Here's one thread:
> <http://runtime-revolution.278305.n4.nabble.com/Storing-and-saving-a-settin 
> <http://runtime-revolution.278305.n4.nabble.com/Storing-and-saving-a-settin>
> g-in-a-stand-alone-td4687858i40.html>
> 
> Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design
> 
> 
> 
> 
> On 4/29/15, 6:21 AM, "dfepst...@comcast.net <mailto:dfepst...@comcast.net>" 
> mailto:dfepst...@comcast.net>> wrote:
> 
>> A stack I have gradually improved over several years now occupies 4 MB on
>> disk, whereas for a long time it was more like 500 KB.
>> Is there some way to diagnose what elements are causing this?  I'd like
>> to generate a list of all of the stack's substacks, cards, fields,
>> images, scripts, etc., and see the amount of stack space each is
>> occupying. 
>> 
>> David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Interfacing with web services - advice needed

2015-03-17 Thread David Epstein

>> For those who want to know, my current case involves a succession of points 
>> on the Earth’s surface where I know each one's longitude and latitude: I 
>> want to convert the intervals between these points to distances in metres 
>> (say).

Graham Samuel stipulated that he did not want to code a LiveCode algorithm to 
solve this problem, but in case it might be useful here is a function that I 
believe does so.

function earthKM myLat,myLon,Lat0,Lon0,@aid
  -- return km distance on earth, load aid [angle in degrees] from origin point 
Lon0,Lat0 to myPoint myLon,myLat
  put PI/180 into rpd -- radians per degree
  put myLat*rpd into myLat
  put myLon*rpd into myLon
  put Lat0*rpd into Lat0
  put Lon0*rpd into lon0
  put (SIN((myLat-Lat0)/2))^2+COS(Lat0)*COS(myLat)*(SIN((myLon-Lon0)/2))^2 into 
j
  put 6371*2*ASIN(MIN(1,j^0.5)) into dkm -- distance in km
  put 
ATAN2(SIN(myLon-Lon0)*COS(myLat),COS(Lat0)*SIN(myLat)-SIN(Lat0)*COS(myLat)*COS(myLon-Lon0))
 into k -- bearing in radians
  put k/rpd into aid -- in degrees
  return dkm
end earthKM

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Spider Web chart?

2015-03-11 Thread David Epstein
Michael Doub asked

> What are the implications of getting a fractional part of a point? Does 
> livecode just ignore the fraction or should the results be truncated or 
> rounded?

When setting “the points,” LC insists on integers, although it is more 
forgiving in other cases (e.g., you can “set the loc” using non-integers.  I 
wrote the function without rounding because I may want to call it from a script 
that performs multiple transformations and then rounds the final results.

> On 3/10/15 10:27 PM, David Epstein wrote:
>> function yAD x,y,d,a,@xAD
>>   -- calculate point x1,y1 that is distance d and angle a from point x,y
>>   -- return y1, load x1 into param 5
>>   -- a is in degrees, positive is east of north
>>   put (90-a)*2*pi/360 into a
>>   put x + d*cos(a) into xAD
>>   return y + d*sin(a)
>> end yAD
> 

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Spider Web chart?

2015-03-10 Thread David Epstein
Richard Gaskin asked for code useful for making a spider web chart.  I think 
the function below would help.  Both the grid and the plots will be polygons 
whose points can be conveniently specified by their distance from an origin and 
their angle on a circle.

function yAD x,y,d,a,@xAD
  -- calculate point x1,y1 that is distance d and angle a from point x,y
  -- return y1, load x1 into param 5
  -- a is in degrees, positive is east of north
  put (90-a)*2*pi/360 into a
  put x + d*cos(a) into xAD
  return y + d*sin(a)
end yAD


David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Invisible character treated as word?

2015-01-30 Thread David Epstein
Thanks for the helpful responses on this question. A complication is that while 
I want to get rid of invisible characters that cause seeming-numbers not to be 
numbers, I don't want to exclude all non-numbers from my table. But since it 
seems that fonts and systems will differ as to which characters are actually 
invisible, I will need to purge even harmless visible characters. So my current 
plan is to use this function:

function scrubbedText txt

-- For tab-delimited data, replace possibly invisible characters with a space; 
and then

-- remove leading and trailing spaces from each cell

  repeat for each char k in txt

if charToNum(k) > 31 or charToNum(k) < 127 then put k after hold

else put space after hold

  end repeat

  set itemDelimiter to tab

  repeat for each line k in hold

repeat for each item i in k

  put word 1 to -1 of i & tab after k2

end repeat

put return into char -1 of k2

put k2 after hold2

put empty into k2

  end repeat

  return hold2

end scrubbedText

If anyone sees a way to do this without stepping through each character, or 
without excluding non-standard visible characters, suggestions are welcome.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Invisible character treated as word?

2015-01-27 Thread David Epstein
For a tab-delimited table of numbers, I want to be sure that none of the 
numbers is surrounded by invisible spaces that will interfere with using the 
numbers in calculation.  I do that by overwriting each cell with "word 1 to -1 
of" that cell.
This generally works fine, but was tripped up by a case in which a number was 
followed by what looked like two spaces.  Closer inspection revealed that the 
second space had charToNum value 202.  Even though it is invisible, LiveCode 
(5.5) seems to treat it as a word, and so my script did not strip it out.
Are there other characters that are always or sometimes invisible that cause 
the same problem?  And what is a remedy?
Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Tabstops problem in 7.0.1?

2015-01-19 Thread David Epstein
On Mac Yosemite, a simple field with tabstops set to 36:

In LiveCode 7.0.1 Community, with the insertion point in the field, I press 
tab, expecting to indent the paragraph I am about to type.  The cursor does not 
move, as if the tab keystroke was not received.  But when I type another 
character it gets indented properly, showing me that the tab had been inserted.

In LiveCode 5.5 the cursor moves as expected and desired when I press tab, to 
the indented point where what I type next will be inserted.

Do others see this symptom?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Determine the LC version of an existing stack

2014-12-14 Thread David Epstein
Is there a way to determine by script which version of LC’s file format an 
existing stack uses?  I see that I can set the file format version when saving 
a stack by setting the stackFileVersion, but I’d like to write a script that 
saves a stack and leaves unchanged its prior version.

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Speed testing: Fastest search method

2014-09-01 Thread David Epstein
Thanks to j...@souslelogo.com for the suggestion that hasMemory(bytes)  
might be useful.  I haven't tried this yet.


Thanks to   for replies to my other  
questions.


On the memory cost of writing fld "data" to tVar


Q2. Of course it does, but the same condition is in place in all three
tests. And the data has to come from somewhere.


My question was whether we could save memory (and if there is some  
other downside) if we write



repeat for each line L in fld "data"


rather than


put fld "data" into tVar
repeat for each line L in tVar


On the rules about "repeat for":

Q2. This 'repeat for each' rule refers to not modifying whatever  
'each'

refers to. In this case, 'each' is a line and the number of lines in
unchanged so I am not changing the internal line pointers set up by  
the

engine at the start.


If your approach works consistently, it implies that LiveCode's  
dictionary is too restrictive when it says (regarding "repeat for  
each labelVariable in container"):


"Important! In any of the for each loops, you should not change the  
labelVariable or container in a statement inside the loop. Doing so  
will not cause a script error, but will almost certainly produce  
unexpected results."


David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Edit cell in basic table field

2014-02-22 Thread David Epstein
Thanks very much for the suggestions of other tools and the script  
that would help me write my own.  But before giving up completely on  
the basic table, I'm trying to understand how it works (and, in the  
process, more about how LiveCode works).


Inspecting "the frontscripts", I discovered that the handlers  
governing basic table fields are in the script of button "revTable"  
of group "revLibraries" of stack "revLibrary."


1.  Hoping to see table-editing in action, I set a checkpoint at the  
beginning of the "on mouseUp" handler in that script.  But clicking  
the field did not cause execution to halt or the debugger to open.   
Are LiveCode's own frontscripts not debuggable by the user?


2.  It looks like if I am willing to edit LiveCode's own frontscript,  
I can get the information I want.  When I insert this statement

send "cellWasEdited pObject,txCell,tyCell,tNewText" to pObject
into the frontscript's "revWriteCellField" handler, I can handle a  
"cellWasEdited" message in my table field's script.


Doing this would mean my stack would not work on someone else's  
machine.  I also wonder whether fiddling with LiveCode's scripts is  
hazardous, or if there are better ways of doing this.  (I tried  
inserting my own closeField handler in front, and having it pass  
closeField on to LC's frontscript.  This did not work.  And some of  
the useful information is stored as script local variables by LC's  
frontscript, which doesn't give me access to it in my own script.)


Any thoughts?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Edit cell in basic table field

2014-02-21 Thread David Epstein
If I check "basic table object" in the field property inspector, and  
check "Edit cell," clicking on the table field causes a small  
unlocked field to be created at the cell's location, which on tab or  
arrowkey has its contents written to the cell.


Is there some way to have a script trap the relevant information  
about what is going on, e.g., that a cell has just been "opened for  
editing", that a cell has just been edited, which cell it is, etc.?


I assume that this "Edit Cell" activity is governed by a script that  
is reading a custom property, but I see no indication that the field  
actually has such a property or where the script is.


Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: pageHeights ignores new line properties in fields?

2014-01-18 Thread David Epstein
Thanks to Jan Schenkel for the confirmation and suggestion.   
Unfortunately, when I tried to script my own pageHeights function  
using formattedHeight, I discovered that formattedHeight also gives  
inaccurate results when paragraph properties have been set.  I have  
reported both of these problems as bug #11688.


The scripts below attempt to adjust for these inaccuracies, insofar  
as I have been able to understand them.  I am sure I have not  
accounted for all cases, so amendments are welcome.


The first function reports the scroll values that will put each  
complete paragraph (except the first) at the top of the field.
The second function is more directly comparable to the "pageHeights"  
function, but it reports cumulative scroll values rather than the  
height of each individual page.


function paragraphBottoms fid
  -- report the values of scroll of field id fid that will put the  
top of a full paragraph at the top of the field
  -- returns a return delimited list.  Each line reports  
hScrollValue,adjuster
  -- hScrollValue is a cumulative total, unlike the pageHeights  
function, which reports height of each page

  -- adjuster is the LC-reported value less the true value
  repeat with n = 1 to the number of lines in fld id fid
add the spaceAbove of line n of fld id fid to a
if n > 1 then
  add 2 * the padding of line n-1 of fld id fid to a
  add 2 * the borderwidth of line n-1 of fld id fid to a
  add the spaceBelow of line n-1 of fld id fid to a
end if
get the formattedHeight of line 1 to n of fld id fid
put it-a & comma & a & return after myList
  end repeat
  return myList
end paragraphBottoms

function lineBottoms fid
  -- a return delimited list of hScroll values that will show field  
id fid's
  -- content as consecutive "pages", each of which begins with a  
line (could

  -- be the wrapped continuation of a paragraph).
  -- Reports a cumulative total, unlike the pageHeights function,  
which reports height of each page


  put the height of fld id fid - 2 * (the borderWidth of fld id fid  
+ (the margins of fld id fid) - 8) into tgtH

  put tgtH into h -- cumulative height target, increments as we go
  put paragraphBottoms(fid) into pbList
  repeat with p = 1 to the number of lines in pbList
if item 1 of line p of pbList < h then next repeat
-- Now work backwards from the bottom of para p, looking for the  
first

-- visible line bottom < h
put length(line 1 to p of fld id fid) into c
put 2+length(line 1 to p-1 of fld id fid) into b
put empty into s
put item 2 of line p of pbList into a -- adjustment needed from  
what LC reports as formattedHeight of para 1 to this para

add the borderWidth of line p of fld id fid to a
add the padding of line p of fld id fid to a
-- for chars in all but the last line of a bordered or padded  
para, this further adjustment seems necessary

repeat with x = c down to b
  get the formattedHeight of char 1 to x of fld id fid
  if it - a < h then
put it-a into s
put s & return after newList
exit repeat
  end if
end repeat
if s is empty then
  if p > 1 then
get (item 1 of line p-1 of pbList)
if it is not line -1 of newList then
  put it into s
else put h into s
  else put h into s
  -- i.e., if line is taller than h, accept a value that breaks  
across the line

  put s & return after newList
  put s+tgtH into h
end if
  end repeat
  return newList
end lineBottoms

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


pageHeights ignores new line properties in fields?

2014-01-15 Thread David Epstein
I find that the pageHeights function does not take account of the  
newer lines-in-fields properties like padding, spaceAbove,  
spaceBelow, etc.  If I set the scroll of the field to line 1 of the  
pageHeights of that field, it will ordinarily put the first line of  
"page 2" at the top of the field.  But if I have, say, set the  
padding of line 3 of that field to 15, setting the scroll in this way  
may result in only the bottom half of a line of text appearing at the  
top of the field.  (It might accidentally work properly for some  
cases, but trying a few different values illustrates the problem.)


Can anyone confirm this, and has anyone already scripted a workaround?

Thanks very much.

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Finding matched parentheses

2013-07-28 Thread David Epstein
Thanks for all the interesting replies to this query.  I used  
"offset" rather than (what most replies suggested) "repeat" with (or  
for) each character thinking it would be faster, but that seems to be  
true only if the string is extremely long and the sought for  
character very far from the front.  And I tried to match the first  
"(" rather than building a list of all matches.  There is no  
practical need for yet another approach, but in case others will find  
it of interest here is a speedy one that does not step through each  
character and barely uses offset.


David Epstein

function offsetPair a,b,str -- NOTE: a and b are single characters,  
str cannot be more than one line
-- in string str, locate the first a, and the nth b, where n = the  
number of a's that precede that b
-- e.g., if a = "("  and b = ")" the character positions of the first  
matched pair will be returned

-- return 0 if a is not found and empty if no match is found
  put offset(a,str) into ca
  if ca = 0 then return 0
  put numToChar(7) into char 1 to ca of str -- some char that's not  
a or b

  replace a with return in str
  put 1 into na -- number (ordinal) of a's, also the line count in str
  put 0 into nb
  repeat for each line k in str
if k is not empty then -- does this line have (na-nb) instances  
of b?

  get nthHit(na-nb,b,k,z,numToChar(7))
  if it is not empty then return ca && it+ca+length(line 1 to  
na-1 of str)

  add z to nb
end if
add 1 to na
  end repeat
  return empty
end offsetPair

function nthHit n,a,str,@z
  -- returns character number of the nth instance of a (a single  
character) in str

  -- z reports the total number of hits
  put numToChar(7)  & str & numToChar(7)  into str   -- so str does  
not begin or end with a

  set itemDelimiter to a
  put -1 + the number of items in str into z
  if n > z then return empty
  return length(item 1 to n of str)
end nthHit

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Finding matched parentheses

2013-07-25 Thread David Epstein
Has anyone scripted a function that will locate the closing  
parenthesis (or bracket, etc.) of a pair?  Below is my effort.   
Reports of its limitations or simpler alternatives (regex?) are invited.


David Epstein

function offsetPair a,b,str,@z
  -- returns offset(a,str) and loads in z offset(b,str) where b is  
the "matching" member of the pair;

  -- returns 0 if there is no a, empty if there is no match

  if a is not in str then return 0
  if b is not in str then return empty
  put 0 into b4 -- skipped characters
  put 0 into na -- number (ordinal) of the a hit
  put 0 into nb
  repeat
put offset(a,str,b4) into ca -- character position of a
put offset(b,str,b4) into cb -- character position of a
if ca = 0 and na < nb then return empty
if cb = 0 and nb < na then return empty
-- only take note of the first hit:
put empty into hitCase -- default
if ca > 0 and (ca < cb or cb = 0) then put "a" into hitCase
if cb > 0 and (cb < ca or ca = 0) then put "b" into hitCase
if hitCase = "a" then
  add 1 to na
  put ca+b4 into aca[na] -- absolute char position of a hit  
number na

  put aca[na] into b4
else if hitCase = "b" then
  add 1 to nb
  put cb+b4 into acb -- absolute char position of most recent b hit
  put acb into b4
else return empty
if na = nb then -- we have a match
  put acb into z
  return aca[1]
end if
  end repeat
  return empty
end offsetPair

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Printing puzzle

2013-06-19 Thread David Epstein

Jacqueline Gay lucidly explained printing settings, including this:
 Every printer has a hard, physical limitation on how far from  
the edges
 it will print. If you get a half-inch unprintable margin at  
100% scale,

 it will still be the same at any other scale.

Yes, the unprintable margins are fixed, but what are they?   
PrintRectangle reports their size in screen pixels, but that will  
only be their size on the printed page if the page setup scale is 100%.


It appears that LC lets us either
  (a) use the full printable area of the paper (print card into rect  
the printRectangle), OR
  (b) place things at precise locations on the paper (leave a safe  
margin of empty space on all sides of a card whose dimensions are  
equal or proportional to the printPaperSize, then print into rect  
“0,0,” & the printPaperSize)

 – but not both.
Unless my script can know what scale is governing the result of the  
printRectangle, it cannot position an object that will be exactly one  
inch from the top of the printed page using method (a).


If the left and right unprintable margins were always symmetrical,  
the "pageSetupScale" I'm looking for could be derived as
100 * item 1 of the printPaperSize / ( item 1 of the printRectangle +  
item 3 of the printRectangle).

But this symmetry was found on only one of the two printers I tested.

David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Printing puzzle

2013-06-18 Thread David Epstein
The question:  how can I find out, by script, how big the unprintable  
margins are when the Page Setup dialog has been set to some scale  
other than 100%?


At 100%, there's no problem.  For example, the unprintable right  
margin = item 2 of the printPaperSize - item 4 of the printRectangle.


But at any other scale I can't use this calculation, because while  
the "printRectangle" responds to a Page Setup choice of scale, the  
"printPaperSize" does not.


Thus if I set the scale to 50%, the printRectangle of 36,36,1188,1504  
tells me the pixels I can fit into a letter size page after shrinking  
them by half and avoiding the unprintable margins.  This means the  
left unprintable margin on the printed output will be 18/72 of an  
inch (shrinking the 36 by 50%).  But I do not see any way of learning  
this information in a script, because the 50% scaling factor is not  
being reported, and the printPaperSize doesn't change the way the  
printRectangle does when the scale changes.  (The "printScale" seems  
to return 1 regardless of what I do to the Page Setup dialog).


What I'm trying to do is show on the screen is both a rectangle that  
will, when printed, be 1 inch from each edge of the paper; and also  
as much space outside of that rectangle as can be printed to.  Thus I  
need to know how much of that 1 inch cannot be printed to.


Many thanks for any suggestions.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Polygon's share of its rectangle inconsistent?

2013-06-09 Thread David Epstein
Although within(,) returns a significant number of  
false positives when a polygon is tested, I find that it gives much  
better results when testing an image.  I imported a snapshot of my  
graphic, then ran my "coverage" function on the image rather than the  
graphic itself.  ("coverage" reports the number of pixels that are  
within the object divided by the number of pixels that are within the  
object's rectangle).  For the image, "coverage" remains quite close  
to constant when you resize the image, or when you resize the graphic  
and then import and test a new snapshot.


David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Polygon's share of its rectangle inconsistent?

2013-06-08 Thread David Epstein
Thanks to Dar Scott, Craig Newman, and Jim Hurley for thinking about  
this.  I don't know why the coverage function would yield 1.0 (except  
for a very small graphic; see glitch described below).  The Dar Scott  
amendment to my function--subtracting 1 from the right and bottom of  
the rect that I survey--is, I learned, equivalent to testing whether  
"pt is within the rect of grcLID"; in other words the pixels on the  
bottom and right edge of a graphic's rect are not counted as "within"  
the graphic's rect.
I tested Dar's suggestions about lineSize and borderWidth.  Perhaps  
because I have showBorder set to false borderwidth had no effect.   
LineSize did affect the results of my "coverage" function, with  
results that are peculiar but do not solve my original puzzle (that  
reported "coverage" should not, but does, vary as I scale a shape).
I resorted to careful study of a very simple polygon, an isosceles  
right triangle with its hypotenuse toward the bottom left.  This is a  
case where I would want my "coverage" function to return 0.5, since  
half of the rectangle is covered by the visible graphic.  Rather  
amazingly, the "within(graphicLID,point)" function returned true not  
only for the points I expected, but for 5 additional diagonal "lines"  
of pixels forming a kind of border extending left and down from my  
visible hypotenuse.  This was true both for a 10 x 10 rectangle and  
for a 50 x 50 rectangle.
This makes it easy to see why "coverage" seems to decline as a  
graphic gets bigger, since these false positive pixels are a much  
larger share of a small rectangle.  But why is "within" returning all  
these false positives?  I tested the "margins" property to no avail.

One further source of difficulty:
If I define a grapic’s “points”, LC seems to impose a lower limit of  
8 x 8 on its width and height. Thus while a triangle with points 0,0  
 10,0  10,10  0,0 has 100 pixels within its rect,  
defining a triangle with points 0,0  5,0  etc. results in an  
object with 64 -- not the expected 25 -- pixels within its rect.  And  
almost all of those extra pixels also register as "within" the filled  
graphic itself, so that "coverage" gets close to 1.0.


Jim Hurley’s function is very useful, but I was hoping to use “within 
()” so that I could handle graphics that are not singly connected and  
closed.  Is there some way to script a test for those cases?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Polygon's share of its rectangle inconsistent?

2013-06-06 Thread David Epstein
In order to properly adjust the relative area of two dissimilar  
polygons, I thought I would use a function to determine the fraction  
of each polygon's rectangle that is covered by the polygon.


function coverage obLID
   set the filled of obLID to true
   put the rect of obLID into r
   repeat with x = (item 1 of r) to (item 3 of r)
  repeat with y = (item 2 of r) to (item 4 of r)
 put x,y into pt
 if within(obLID,pt) then add 1 to isIn
 add 1 to all
  end repeat
   end repeat
   return isIn/all
end coverage

This seems to work as expected, but I am perplexed by the fact that  
when I resize an object keeping its proportions constant (drag a  
corner with the shift key down; or script this) I get a surprising  
variation in the result.  E.g., a fairly simple shape I tried went  
from 0.48 coverage up to 0.59 coverage when I shrank its dimensions  
by about two-thirds.  With tens or hundreds of thousands of pixels  
being sampled in the calculation, I would not expect this variation.


Many thanks for any insights or suggestions.

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Page 2 of a PDF

2013-04-06 Thread David Epstein

 J. Landman Gay:
That's pretty good, it works great. Where'd you get the "75" from?

Based on your calculation, this one-liner also works:

on goPage n
set the currenttime of player 1 to (n-1)*75
end goPage


Thank you, that's an improvement.  The 75 came from observing that  
the "duration" of a player with a PDF loaded seemed to be 75*(z-1)  
where z = the number of pages.



Thomas McGrath III:
Do you have more code or explanations about how this works? I am  
actually looking for a step for images in a scrolling group on iOS  
and Android but your email made me think that maybe a pdf might  
work. I need the images to 'land' fully in view even if the user  
has not scrolled all the way on a touch.




I don't know about iOS or Android, but I would think you could move  
an image to the group's top edge by setting the scroll of the group  
to the top of the image minus item 2 of the formattedRect of the group.


David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two Windows

2013-03-03 Thread David Epstein
I think Tim Miller is right to think that opening two copies of  
LiveCode will not help him edit the same stack in two windows, as  
each will not know about the changes in the other until saved to disk  
and reopened, and two very different versions are likely to result-- 
unless all changes are immediately saved and the other window's stack  
is reopened.


I would suggest rather creating a second stack (perhaps a substack)  
used as a secondary window, to which the content of individual cards  
could be copied as needed.  Write their changes back to the main  
stack before you "navigate" to another card in the secondary window  
by copying new content there.  You'll need to either prevent or  
handle the special case where one card is open in both windows at  
once (you can handle it by, e.g., using a closeField handler or a  
keyDown handler in stack 1 to change the content of field 1 of stack  
2 whenever field 1 of stack 1 is edited).


David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Keys of a custom property array

2013-03-03 Thread David Epstein

get the customKeys[myCustomPropertySetName] of myObject



Jacqueline Gay asked:

If I store an array as a custom property, is there a way to get its  
keys

without putting the whole thing into a variable first?


David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Copying fields sometimes doesn't copy their content. But when?

2013-02-25 Thread David Epstein
Many thanks to Jacqueline for providing the master key to this  
question.  By trial and error, I think I have confirmed this rule:


"Copy  to " will  
include the text of the field(s) in the new copy ONLY if

(a) the sharedText property of the field is TRUE, or
(b) the field is on the card that is or includes the destination, or
(c) the field is on, and destination is or is on, the first card of a  
stack.


Note that if you copy a field via the clipboard, the paste command  
will include the text of the field regardless of the sharedText  
property.
The dictionary does not mention this effect of the "sharedText"  
property, saying (what is not strictly true) that "If the field is a  
card field (not part of a group), its sharedText property has no  
effect."  I can add a user-contributed note there, and to the
copy command entry, unless someone determines that my findings are  
incorrect.


David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Copying fields sometimes doesn't copy their content. But when?

2013-02-24 Thread David Epstein
Is there some rule that determines whether, when a field or group is  
copied in LiveCode (using the "copy  to " command)  
the contents of the field or grouped fields are copied?


This result seems strange:  copying a field or group from a different  
stack to the current card includes the field contents if the current  
card is card number 1, but not otherwise.


Recipe:

Create two stacks, "x" and "y"
Create a second card in stack y
Create two fields on card 1 of stack x, put some content in them, and  
group them.


Now with card 1 of stack y frontmost, type in the message box:

copy group 1 of stack "x" to this card

Then with card 2 of stack y frontmost, type in the message box:

copy group 1 of stack "x" to this card

Result:
When copying to card 1, the content of the fields is copied.
When copying to card 2, the fields are empty.

Thanks for any insights into this.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Answer File crashes LC on PPC Mac 10.4

2013-02-07 Thread David Epstein
I've just started using LC 5.5.3 on my desktop Mac Mini, with a power  
pc chip running System 10.4 as well as on my MacBook Air running 10.6.


This very simple script crashes LC on the Mac Mini:

on mouseUp
  answer file "Display what file?"
  put it
end mouseUp

When I stripped away the intended functions and left only this, and  
created a new stack with only one button to put this script in, the  
crashes are not consistent but they are very frequent.  On the first  
try a file path will sometimes be displayed as expected, but the  
second or third click of the button causes a crash as soon as I  
choose the file.


On my MacBook Air, I do not have this problem.

Any one else have this experience, or suggestions?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Characters that can be used in an array key

2012-04-29 Thread David Epstein
Are there any limits on what characters can be used in an array key?   
For example, do tab characters cause problems?

Many thanks.

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


AltIDs

2012-01-08 Thread David Epstein
To avoid conflicts with normal ids, it seems we want to choose large  
numbers for altIDs.  Testing this out:


Create a new stack.
Create one button.
In the message box, "set the altID of btn 1 to 8"
In the message box, "put the altID of btn 1"
Result:
24120
Tried this again, using 9.  Result was 51711
What's going on?

Many thanks.
David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode