Path: utzoo!attcan!uunet!snorkelwacker!apple!jdevoto From: jdevoto@Apple.COM (Jeanne A. E. DeVoto) Newsgroups: comp.sys.mac.hypercard Subject: Re: Pasting text with tabs into a field: How is it done? Keywords: xcmds,file-to-field,tabs in fields Message-ID: <45362@apple.Apple.COM> Date: 4 Oct 90 11:47:52 GMT References: <8561@milton.u.washington.edu> Organization: Apple Computer Inc., Cupertino, CA Lines: 34 In article <8561@milton.u.washington.edu> bjornl@milton.u.washington.edu (Bjorn Levidow) writes: >I'm trying to use the FileToField XCMD in the Dartmouth 3.1 collection >to put a text field with tab in it into a field. The problem is that >all of the tabs get stripped out and I'm left with one long line of data. >I'd like to be able to replace the tabs with spaces or commas if possible. I'm not familiar with the FileToField XCMD; however, here is a way to do what you want in HyperTalk: on getFile myFile -- get contents of file with substitution open file myFile repeat until it is empty -- in other words, until there ain't no more read from file myFile for 16834 -- maximum length repeat while it contains tab put "," into char offset(tab,it) of it -- substitute , for 1st tab end repeat put it after field "Destination" end repeat close file myFile end getFile Note that the above handler will trigger an error if the file contains more than 30,000 characters or so (the maximum number of characters for a field). You may want to handle this in any number of ways -- disallowing the transaction and emptying the field, or creating a new field to hold the overflow, or whatever. -- ========= jeanne a. e. devoto ======================================== jdevoto@apple.com | You may not distribute this article under a jdevoto@well.sf.ca.us | compilation copyright without my permission. ______________________________________________________________________ Apple Computer and I are not authorized | CI$: 72411,165 to speak for each other. |