Re:Multicolumn Printing (Text Flow)

2004-11-17 Thread depstein
I like Cubist's binary search idea, but I recall that when I originally stepped 
through the text by word rather than by char I was stymied by the fact that 
a quoted series of words is understood as a single word, even though a proper 
page break could fall within that series.  I assume a binary search by char 
would work.  Thanks.

David Epstein

 sez [EMAIL PROTECTED]: 
 Here's another approach to the text overflow calculation: 
 Nice idea, but do you really need to test every character in sequence? I 
 was under the impression that Rev doesn't believe in hyphenation, so you 
 could 
 speed up this handler by testing words rather than characters; a further 
 speedup could be gained by starting with the entire field (what if the text 
 doesn't 
 actually overflow?) and doing a binary search. With that in mind, here's my 
 modified version of your handler ('ware the line wraps!)... 
function ExtraText2 FldName
-- removes from fld FldName, and returns, the htmlText that overflows size of 
fld FldName
  put (the number of words in fld FldName) into WordKount
  put max (WordKount div 2, 1) into DerDelta
  put the height of fld FldName into DerHeight

  put the formattedHeight of word 1 to WordKount of fld FldName into 
CurrentHeight
  if CurrentHeight = DerHeight then return  -- no overflow, right?

  -- now comes the binary search
  put WordKount into HiEnd
  put CurrentHeight into MaxH
  put DerDelta into LoEnd
  put the formattedHeight of word 1 to LoEnd of fld Fldname into MinH

  repeat
put max (DerDelta div 2, 1) into DerDelta
if MinH  DerHeight then -- even the minimum is too long
  put LoEnd into HiEnd
  put MinH into MaxH
  subtract DerDelta from LoEnd
  put the formattedHeight of word 1 to LoEnd of fld Fldname into MinH
else if MinH = DerHeight then -- *just* right!
  return the htmlText of word (LoEnd + 1) to -1 of fld FldName
else -- the minimum is too small
  if MaxH - MinH = 1 then -- we've discovered the overflow point
return the htmlText of word (LoEnd + 1) to -1 of fld FldName
  end if
  add DerDelta to LoEnd
end if
put the formattedHeight of word 1 to LoEnd of fld Fldname into MinH
  end repeat
end extraText2
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Multicolumn Printing (Text Flow)

2004-11-16 Thread depstein
Here's another approach to the text overflow calculation:

function extraText f -- removes from fld f, and returns, the htmlText that 
overflows size of fld f
  repeat with c = 1 to length(fld f)
if the formattedHeight of char 1 to c of fld f  the height of fld f then
  put the htmlText of char c to -1 of fld f into myHtml
  delete char c to -1 of fld f
  return myHtml
end if
  end repeat
  return empty
end extraText

David Epstein

 4. Multicolumn Printing (Text Flow)? (Frank D. Engel, Jr.) 

 My best guess is to create separate fields for the left and right 
 columns and somehow figure out where to split the text so that I can 
 fit the text neatly into the two columns. Does anyone know of an easy 
 way to figure out where to split this? 
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: selectedText from a palette?

2004-09-09 Thread depstein
Rich Layne wrote:

 I trying to make an application that has most of it’s functionality on 
 a palette-- a bunch of different buttons that will do different stuff 
 to the main data stack. Most things work, but handlers that involve the 
 “selectedText” don’t seem to make it to the main stack, (which is the 
 topStack.) 

My experience using Metacard 2.5 is that when you click on a palette the selection in 
the topStack is lost, so the selectedText is empty.  I use these handlers in my 
palette's script as a way of recording and restoring the selection:

on mouseEnter
  global chunkStore
  get the selectedChunk
  if it is empty then put empty into chunkStore else put it  of  word -2 to -1 
of the long id of the selectedField into chunkStore
end mouseEnter

on mouseDown
  global chunkStore
  if chunkStore is not empty then do select  chunkStore
end mouseDown

So on mouseUp, the selection is where you want it and references to it should work 
properly.  

There is a slight flashing associated with the selection being lost and restored, so 
I'd be interested to hear other methods.

David Epstein
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Windows Printing

2004-08-29 Thread depstein
Jacqueline Landman Gay wrote of Windows printing problems:

 The printing stack has its 
 formatForPrinting set to true.
 
 My script fills both fields, prints the card, prints a break, then 
 repeats until the data is gone.

The documentation for formatForPrinting warns us never to edit a field with its 
formatForPrinting set to true.  A script that fills both fields is editing a field 
with formatForPrinting set to true.

I experienced the symptoms you described, plus the program frequently simply quitting, 
while trying to print in Windows using Metacard 2.5.  I believe I have now remedied 
the problem by having my script repeatedly call this command:

on ffp whether
  set the formatForPrinting of stack myPrintLayoutStack to whether
end ffp

FormatForPrinting needs to be FALSE before the script changes a field's content 
(including filling it in the first place), and it needs to be TRUE before you try to 
determine what changes are needed based on how the text fits in the space available 
(and before you print).  For example, here's handler I use to determine what text 
doesn't fit in a field and needs to be moved to the next column or page:

function extraText f -- returns the htmlText that overflows size of fld f
  ffp true -- SO THAT FORMATTEDHEIGHT WILL BE PROPERLY CALCULATED
  repeat with c = 1 to length(fld f)
if the formattedHeight of char 1 to c of fld f  the height of fld f then
  put the htmlText of char c to -1 of fld f into myHtml
  ffp false -- BECAUSE I'M ABOUT THE CHANGE THE CONTENT OF FLD F
  delete char c to -1 of fld f
  return myHtml
end if
  end repeat
  ffp false -- READY FOR FURTHER EDITS OF FLD F
  return empty
end extraText

Just before you print, set ffp true again.  Somewhere (but not in Rev docs, I think) I 
read advice suggesting a further precaution:  close and open the stack and then set 
formatForPrinting to true.  So I added this just before printing:

set the destroyStack of stack myPrintLayoutStack to true
save stack myPrintLayoutStack
close stack myPrintLayoutStack
open stack myPrintLayoutStack
ffp true

This last bit seems a littler superstitious, but since I made these fixes a couple of 
weeks ago my Windows printing has worked properly.

I hope this will help with your difficulties.

David Epstein
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: OptionKey madness

2004-03-21 Thread depstein
Richard Gaskin wrote:
 My goal was to provide 20 simple keystrokes for user-settable actions, 
 giving them Cmd/Ctrl-1 through 0, and Opt/Alt-1 through 0.  Function 
 keys are out since both Win and Mac OSes reserve so many for specific 
 features.  Now it seems Option keys may be out as well

Have you considered using the Mac CONTROL key to do what your Windows ALT key does?  
This works:

on controlKeyDown what -- for Mac CONTROL key
  keyShortcut what
end controlKeyDown what

on optionKeyDown what -- for Windows ALT key
  keyShortcut what
end optionKeyDown

(Where a keyShortCut handler does the work intended for Win-Alt-what or Mac 
Ctrl-What).  
A commandKeyDown handler catches the use of the Windows control key and the Mac 
command key.

David Epstein
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Selection strategies

2004-02-27 Thread depstein
Richard Gaskin noted that 

 when text is selected in the field [of the topstack] the 
 palette buttons work great, but if the cursor is inserted with no 
 selection then clicking in the palette window causes the field to lose 
 focus.

My palette is a menu of pulldown buttons, and these handlers are in the palette's 
stack script:

on mouseEnter
  global chunkStore
  get the selectedChunk
  if it is empty then put empty into chunkStore else put it  of  word -2 to -1 
of the long id \
  of the selectedField into chunkStore
end mouseEnter

on mouseDown
  global chunkStore
  if chunkStore is not empty then do select  chunkStore
end mouseDown

This works properly, although there is a slight flash as the text gets reselected on 
mousedown, so an approach that avoided that would be welcome.  One approach:  if I 
test the selectedText's length and load chunkStore only if that length is 1, the 
engine keeps the selection without my help for cases where there's more than an 
insertion point, and the flash is avoided.  But in that case my experience is that the 
insertion point is not properly placed after the command is executed (e.g., a paste 
command does not place the insertion point after the newly pasted material), whereas 
the scripts above set the insertion point properly.  But there is that flash.

I'm using MC 2.5.

David Epstein
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


re: Long combo box buttons

2004-02-07 Thread depstein
To display more than a few lines in a combo box list:

set the menuLines of btn myCombo to the number of lines in btn myCombo

Works the same way as with option button lists.  Tested with Metacard 2.5 Mac OSX.

David Epstein
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Poor technique?

2004-01-09 Thread depstein
Robert Brenstein quoted Scott Raney:

open
inv is poor technique in MC anyway (it's only there as a SuperCard
compatibility feature), as is setting up fields in one stack from
another directly.  Instead, do the init in a preOpenStack handler, and
get the data in the dialog from a well known place (use the dialogData
property if you don't already have such a place).
   Regards,
 Scott

Why is setting up fields in one stack from another directly a worse 
technique than writing data to a global property and having the preOpenStack 
handler transfer the data to that stack?  I can see that the latter might be 
convenient in some cases, but is there any important reason not to do the 
former?  Similarly:  is it in any way better to set custom properties of the 
second stack before opening it than to set the text of its fields before 
opening it?  

The ability to read and write to fields of unopened stacks is very powerful; 
Raney's remarks suggests there are some limits on how this should be used.  
Can anyone clarify this?

David Epstein

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Moving more than one line in a listfield

2003-12-17 Thread depstein
This is a subset of a more elaborate function, so I hope it still works.  It 
can be used to move the selected lines of a list-type field to the top or 
bottom of the list, or up or down.

David Epstein


function reListed theList,actPieces,action,myDelim,@newSelec
-- theList is the starting list; if return-delimited, pass return as myDelim
-- actPieces gets passed the hilitedLines of the field containing theList
-- action is 1, 2, 3, or 4, depending on where you want to move the selected 
lines.
-- the function returns the modified list, and loads variable newSelec
-- with a comma-delimited list of numbers useful for setting the appropriate 
-- hilitedLines of the field after the list has been altered.

  put theList into origList
  replace , with   in actPieces
  set the itemDelimiter to myDelim
  put the number of items in theList into z
  put the number of words in actPieces into p
  repeat with w = p down to 1
put word w of actPieces into i
put myDelim  item i of theList before newList
delete item i of theList
  end repeat
-- items (lines) specified in actPieces are now listed in newList, and
-- have been removed from theList.  The rest of the script
-- combines those newList and theList in the right order.

  delete char 1 of newList
  switch action
  case 1 -- move newList to the top
put rangeList(1,p) into newSelec
return newList  myDelim  theList
  case 4 -- newList to the bottom
put rangeList(z-p+1,z) into newSelec
return theList  myDelim  newList
  case 2 -- newList up
put word 1 of actPieces into slot
if slot  3 then
  put rangeList(1,p) into newSelec
  return newList  myDelim  theList
else
  put slot - 1 into slot
  put rangeList(slot,slot+p-1) into newSelec
  return item 1 to slot-1 of theList  myDelim  newList  myDelim  item 
slot to -1 of theList
end if
  case 3 -- newList down
put word -1 of actPieces into slot
if slot = z then -- last selected is at end of list
  put rangeList(z-p+1,z) into newSelec
  return theList  myDelim  newList
else
  put slot + 2 - p into slot
  put rangeList(slot,slot+p-1) into newSelec
  return item 1 to slot-1 of theList  myDelim  newList  myDelim  item 
slot to -1 of theList
end if
  end switch
end reListed

function rangeList a,z -- returns comma delimited series of numbers from a to 
z
  put z-a into myCount
  if myCount = 0 then return a
  put a into hold
  repeat with b = 1 to myCount
put ,  a+b after hold
  end repeat
  return hold
end rangeList
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Moving more than one line in a listfield (fwd)

2003-12-17 Thread depstein
A clarification:  The function I just suggested for this purpose assumes that 
you want to group the several selected lines, e.g., that when you move 
lines 4 and 7 up in the list you want them to become lines 3 and 4, not 
lines 3 and 6.  I hope this is what was intended.

David Epstein

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Getting a chunk of stylized text?

2003-02-21 Thread depstein
There are probably faster ways to do this, but try this:

function extraText f 
  -- returns the htmlText that overflows size of fld f
  -- and deletes it from field f
  repeat with c = 1 to length(fld f)
if the formattedHeight of char 1 to c of fld f  the height of fld f then
  put the htmlText of char c to -1 of fld f into myHtml
  delete char c to -1 of fld f
  return myHtml
end if
  end repeat
  return empty
end extraText

David Epstein
  Getting a chunk of stylized text?
 From: Dan Friedman [EMAIL PROTECTED]
...
 Let's say field A contains more text than can fit in it.  The text in field

 A contains multiple fonts, styles and sizes.  How can I get the stylized
 text that is not being displayed? (and remove it from field A and put it
 into field B)
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Re: ranging lists

2003-01-29 Thread depstein
Since you're dealing with integers, you could run each line of list 1 through 
a function like

function numberSeries x,y
-- returns space-delimited list of all integers from x to y

to build an expanded version of list 1 that explicitly lists all possible 
matching numbers in each range.  Then send each item n in list 2 to a 
function:

function whichRange n,expandedList
set wholeMatches to true
get wordOffset(n,expandedList)
if it = 0 then return 0
return the number of lines in word 1 to it of expandedList

I suspect this will be faster than running each of your 2000 numbers 
through a series of comparisons.

David Epstein


 I have 2 lists. I need to check whether the values of list 2 fall within the
 range of the values of list 1. eg.
 
 list 1
 1 10
 20 25
 45 55
 
 list 2
 1,3,12,23,34,45,52,78
 

 List 1 may have up to 60 different ranges, one range per line.
 List 2 may have over 2000 items. (these are line numbers of a text 
database)
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution