[comp.sys.mac.hypercard] How can I keep the tab key?

lin@diemen.cc.utas.oz (Zhen Jie Lin) (03/21/90)

Hello, HyperCard Experts:

When I try to paste some data including tab into HyperCard field, once I quit
from the field, the tab characters disappear immediately.  Is there any way that
I can keep these tab characters so that I can use some other character (eg comma) to replace it?  If I can do this, I would be able to copy some spreadsheet data
into HyperCard without great suffer.

All your response would be greately appreciated.

Zhenjie Lin
               lin@diemen.cc.utas.oz
    or         lin@cmltas.cml.oz

lin@diemen.cc.utas.oz (Zhen Jie Lin) (03/26/90)

In article <1318@diemen.cc.utas.oz>, lin@diemen.cc.utas.oz (Zhen Jie Lin) writes:
> When I try to paste some data including tab into HyperCard field, once I quit
> from the field, the tab characters disappear immediately.  Is there any way that
> I can keep these tab characters so that I can use some other character (eg comma) to replace it?  If I can do this, I would be able to copy some spreadsheet data
> into HyperCard without great suffer.

 
I posted the above message couple weeks ago, and have only got one suggestion
(from J. G. Smith), but still failed.  Tonight, one idea suddenly came out, and
the following is solution.  I think this may be useful for many people, so post
it to the net.


--                    TabToComma HyperCard Script

-- by Zhenjie Lin, PO Box 445, Sandy Bay, Hobart, TAS 7005, AUSTRALIA
-- 26 March, 1990
--
-- IF YOU LIKE THE SCRIPT, JUST DROP ME A LINE, I WANT TO KNOW HOW MANY
-- PEOPLE MAY USE IT.  THANK YOU.
--
-- My email address:        lin@cmltas.cml.oz    
--        or             lin@diemen.cc.utas.oz  


--When copy-paste some text from external file into HyperCard, the tab 
--characters will be deleted.  This could be annoying in some cases,
--especially when the user want to use spreadsheet data.  The following 
--script will replace tab key with comma when pasting data into a text
--field.  Please put it in the script of card or bg or stack or home 
--depending on where you want this feature.

on doMenu x 
  global finishDoMenu
  put false into finishDoMenu
  --
  if x is "paste text" then tabToComma
  -- {insert any other commands)
  --
  if finishDoMenu then exit doMenu
  pass doMenu
end doMenu

on tabToComma
  global finishDoMenu
  send "doMenu paste text" to hyperCard

  --skip the replacing if paste text into message box
  put the rect of the message into box
  put item 1 of the clickLoc into x
  put item 2 of the clickLoc into y
  if x>= item 1 of box and x<= item 3 of box andB
  y>= item 2 of box and y<= item 4 of box then
    put true into finishDoMenu
    exit tabToComma
  end if

  put the Number of the selectedField into fldNo
  get the name of the selectedField
  if word 1 of it is "card" then                -- process cd fld
    repeat until offset(tab,cd fld fldNo) = 0
      put "," into char offset(tab,cd fld fldNo) of cd fld fldNo
    end repeat
  else                                          -- process bg fld
    repeat until offset(tab,fld fldNo) = 0
      put "," into char offset(tab,fld fldNo) of fld fldNo
    end repeat
  end if
  put true into finishDoMenu
end tabToComma

 

lin@diemen.cc.utas.oz (Zhen Jie Lin) (03/27/90)

In article <1328@diemen.cc.utas.oz>, lin@diemen.cc.utas.oz (Zhen Jie Lin) writes:
> In article <1318@diemen.cc.utas.oz>, lin@diemen.cc.utas.oz (Zhen Jie Lin) writes:
> > When I try to paste some data including tab into HyperCard field, once I quit
> > from the field, the tab characters disappear immediately.  Is there any way that
> > I can keep these tab characters so that I can use some other character (eg comma) to replace it?  If I can do this, I would be able to copy some spreadsheet data
> > into HyperCard without great suffer.
> 
>  
> I posted the above message couple weeks ago, and have only got one suggestion
> { the rest is the script}

I am sorry that the script I posted last night doesn't work properly when the
message box is hiding. In that case, even the insertion I beam is within the
rect of the message box, the text is still to be pasted into text field instead
of message box. The following script fix this problem.  I apologize for any
inconvenience.

--                    TabToComma HyperCard Script (v1.1)

-- by Zhenjie Lin, PO Box 445, Sandy Bay, Hobart, TAS 7005, AUSTRALIA
--                       27 March, 1990
--
-- IF YOU LIKE THE SCRIPT, JUST DROP ME A LINE, I WANT TO KNOW HOW MANY
-- PEOPLE MAY USE IT.  THANK YOU.
--
-- My email address:        lin@cmltas.cml.oz
--        or             lin@diemen.cc.utas.oz


--When copy-paste some text from external file into HyperCard, the tab
--characters will be deleted.  This could be annoying in some cases,
--especially when the user want to use spreadsheet data.  The following
--script will replace tab key with comma when pasting data into a text
--field.

on doMenu x
  global finishDoMenu
  put false into finishDoMenu
  --
  if x is "paste text" then tabToComma
  -- {insert any other commands)
  --
  if finishDoMenu then exit doMenu
  pass doMenu
end doMenu

on tabToComma
  global finishDoMenu
  send "doMenu paste text" to hyperCard
  
  if the visible of the message then  --check whether pasting into msg box
    put the rect of the message into box
    put item 1 of box into x1
    put item 3 of box into x2
    put item 2 of box into y1
    put item 4 of box into y2
    
    put item 1 of the clickLoc into x
    put item 2 of the clickLoc into y
    if x>=x1 and x<=x2 and y>= y1 and y<=y2 then
      put true into finishDoMenu
      exit tabToComma
    end if
  end if
  
  put the Number of the selectedField into fldNo
  get the name of the selectedField
  if word 1 of it is "card" then
    repeat until offset(tab,cd fld fldNo) = 0
      put "," into char offset(tab,cd fld fldNo) of cd fld fldNo
    end repeat
  else
    repeat until offset(tab,fld fldNo) = 0
      put "," into char offset(tab,fld fldNo) of fld fldNo
    end repeat
  end if
  put true into finishDoMenu
end tabToComma