home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / mactool / delimfix.cpt / The Delimiter Fixer 1.0.3 / stack_-1.xml < prev    next >
Encoding:
Extensible Markup Language  |  1991-10-30  |  17.3 KB  |  23 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in.3</name>
  5.     <id>-1</id>
  6.     <cardCount>3</cardCount>
  7.     <cardID>2959</cardID>
  8.     <listID>4019</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>256</width>
  14.         <height>288</height>
  15.     </cardSize>
  16.     <script>Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧THE DELIMITER FIXER┬⌐1991 Geoff Duncan, Red Split Ends Inc.This stack is free, although the author maintains copyright.  You maynot sell this stack or charge for its distribution without the express permissionof the author AND the author(s) of materials contained herein.XFCNs used in this stack:HierPopUpMenus, ┬⌐ Jon Pugh  jpugh@apple.comXCMDs used in this stack:HCBalloon, ┬⌐ Len Saaf  saaf@joker.optics.rochester.eduUsed within limits specified by the authors.Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧on openstackif the version < 2.1 thenanswer the short name of this stack && "requires HyperCard 2.1 or higher." && ┬¼"Many features of this stack will not work properly with an earlier version of HyperCard."┬¼& return & "See the Stack OverView for more information."end ifput "<<none>>" into bg fld "Import"put "<<none>>" into bg fld "Export"-- put empty into bg fld "Specified Header"dfremovemaskhide bg btn id 32 --okhide bg btn id 46 --savehide bg fld "Specified Header"DFSetUpMenu Onpass openstack --for othersend openstackon closestackglobal DFImportFile, DFExportFile,FieldDelimiter,RecordDelimiterput empty into DFImportFileput empty into DFExportFileput empty into FieldDelimiterput empty into RecordDelimiterif the freesize of this stack > .1 * the size of this stack thenput the freesize of this stack div 1024 & "K free in stack" && the short name┬¼of this stack & ". Compacting..."domenu "Compact Stack"hide msgend ifDFSetUpMenu Offpass closestack --ferothersend closestackon suspendStackDFSetUpMenu Offpass suspendstack --for others, if anyend suspendstackon resumeStackDFSetUpMenu Onsend "opencard" to this cardpass resumeStack --for others, if anyend resumeStackΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧MAIN CARD HANDLERSΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧--asks for and obtains paths for import and export fileson DFgetAFile whichglobal DFImportFile, DFExportFileif which is "Import" thenanswer file "Please name an" && which && "file:" of type TEXTelseask file "Please name an" && which && "file:"end ifif (it is not empty) or (the result is not "Cancel") thenput FileFromPath(it) into bg fld whichif which is "import" then put it into DFImportFileelse put it into DFExportFileelse put "<<none>>" into bg fld whichend DFgetAFileΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧on GODelimiterFixer--GetUserSettings -- gets user settingsif the result is empty then exit GODelimiterFixer--GetProperHeaderput the result into DFHeaderif DFHeader is empty then exit GODelimiterFixerParseTheHeader DFHeaderput the result into DFHeaderif DFHeader is empty then exit GODelimiterFixer--if the hilite of bg btn "Variable to fixed" then VarToFixed DFHeaderelse FixedToVar DFHeader--play finis f c g cwend GODelimiterFixerΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧on GetUserSettingsglobal DFImportFile, DFExportFile,FieldDelimiter, RecordDelimiterif (bg fld "Import" is empty) or (bg fld "import" is "<<none>>") thenbeepanswer "No import file specified." with "OK"return empty -- puts empty into "the result" for later processingend ifif (bg fld "Export" is empty) or (bg fld "Export" is "<<none>>") thenbeepanswer "No export file specified." with "OK"return empty -- puts empty into "the result" for later processingend ifif DFImportFile is DFExportFile thenbeepanswer "Import and Export files may not be identical." with "Oh hell."put "<<none>>" into bg fld Importput "<<none>>" into bg fld Exportreturn emptyend if--now obtains user settings and puts them into the appropriate global variables-- used in the routines.  Also puts the appropriate character values in where needed.put the short name of bg btn id 5 into FieldDelimiterput the short name of bg btn id 15 into RecordDelimiterif fieldDelimiter is RecordDelimiter thenbeepanswer "Field and Record delimiters may not be identical." with "Oh hell."return emptyend if--those are the "popup" buttonsif  (FieldDelimiter is "Colon")┬¼or (FieldDelimiter is "Tab")┬¼or (FieldDelimiter is "Comma")┬¼or (FieldDelimiter is "Space") thenput value(FieldDelimiter) into FieldDelimiterelseif (FieldDelimiter is "SemiColon") then put ";" into FieldDelimiterend ifif  (RecordDelimiter is "Return")┬¼or (RecordDelimiter is "Tab")┬¼or (RecordDelimiter is "Space") thenput value(RecordDelimiter) into RecordDelimiterend if--return trueend GetUserSettingson GetProperHeader--returns the appropriate header for operation...  returns EMPTY if noneglobal RecordDelimiter, DFImportFileput empty into WhichHeaderopen file DFImportFileread from file DFImportFile until RecordDelimiter --gets header information if presentput it into FirstLineclose file DFImportFileput bg fld "Specified Header" into SpecHeader--here's the testing sectionif isValidHeader(FirstLine) and isValidHeader(SpecHeader) then--BOTH ARE VALIDanswer "The file" && quote & FileFromPath(DFImportFile) & quote &&┬¼"apparently contains valid header information." && ┬¼"Do you wish to use this information or the header you supplied?" ┬¼with "FileΓÇÖs" or  "Mine" or "Cancel"if it is "Cancel" then return emptyput it into whichHeaderend ifif isValidHeader(SpecHeader) and ┬¼((whichHeader is empty) or (whichHeader is "Mine")) then return SpecHeader--SPECHEADER VALIDif isValidHeader(firstLine) and ┬¼((WhichHeader is empty) or (WhichHeader is "FileΓÇÖs")) then return FirstLine--FIRSTLINE VALIDif not(isValidHeader(firstLine)) and not(isValidHeader(SpecHeader)) then--BOTH ARE INVALIDanswer "Neither the file" && quote & FileFromPath(DFImportFile) & quote &&┬¼"nor this stack contain a valid Header.  Please see this stackΓÇÖs documentation" &&┬¼"for information about creating a Header." with "OK"return emptyend ifend GetProperHeaderon ParseTheHeader Header--this leaves us with a return-separated listglobal fieldDelimiterif not(isValidHeader(header)) then return emptyif header contains fieldDelimiter then put FieldDelimiter into Delimelse put comma into Delimif not(header contains Delim) thenanswer "The specfied Header is not valid.  Please see this stackΓÇÖs documentation" &&┬¼"for information on creating a valid Header." with "OK"return emptyend ifput StripReturnsAndSpaces(header) into headerdelete char 1 to 2 of header --removes <<put the number of chars in header into lastChardelete char lastchar -1 to lastchar of header --removes >>--this removes all FIELDDELIMITERS so we can parse out column notationsrepeat with i = 1 to the number of chars in headerif char i of header is Delim then put return into char i of headerend repeatreturn Headerend ParseTheHeaderΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧on VarToFixed Columnsglobal DFImportFile, DFExportFile, FieldDelimiter, RecordDelimiter, DFDATAif columns is "PreWarm" then exit VarToFixeddisallowinterruptionDFSetUpMaskopen file DFImportFileopen file DFExportFileif not(the hilite of bg btn "Low Memory Mode") then LoadAllData DFImportFile --Γêåput 0 into processedRecordsset the itemdelimiter to FieldDelimiterrepeat -- until eofif UserInterrupt() then exit repeat-- read from file DFImportFile until RecordDelimiter -- one "line"get theNextRecord()if it is empty then exit repeatput it into Field-- delete the last char of Field -- the record delimiterput empty into FixedFieldsrepeat with i = 1 to the number of lines in Columnsset cursor to busyConvertToFixedField item i of Field, line i of columnsput the result after FixedFieldsend repeatwrite FixedFields & return to file DFExportFileput ProcessedRecords + 1 into ProcessedRecordsDFMaskMessage "Records Processed:" && ProcessedRecords & return & ┬¼"Hold down ∩ú┐-option-mouse to interrupt."end repeatCleanUpStuffend VarToFixedon ConvertToFixedField field, columnsput the number of chars in field into FieldCharsif FieldChars > columns thendelete char columns + 1 to (fieldchars) of fieldreturn fieldelserepeat columns - fieldchars timesput space after fieldend repeatreturn fieldend ifend ConvertToFixedFieldon FixedToVar Columns--converts fixed-field format to variable-lengthglobal DFImportFile, DFExportFile, FieldDelimiter, RecordDelimiter, DFDATAif columns is "PreWarm" then exit FixedToVardisallowinterruptionDFSetUpMaskopen file DFImportFileopen file DFExportFileif not(the hilite of bg btn "Low Memory Mode") then LoadAllData DFImportFile --Γêåput 0 into processedRecordsrepeatif UserInterrupt() then exit repeat-- read from file DFImportFile until return --gets one lineget theNextRecord()if it is empty then exit repeatput it into Recordput 1 into FirstCharrepeat with i = 1 to the number of lines in columnsset the cursor to busyput stripReturnsAndSpaces(char FirstChar to (firstChar +line i of Columns -1)┬¼of Record) after VarRecordput varRecord & FieldDelimiter into VarRecordput firstChar + line i of Columns into firstCharend repeatput recordDelimiter into the last char of VarRecordwrite VarRecord to file DFExportFileput empty into VarRecordput ProcessedRecords + 1 into ProcessedRecordsDFMaskMessage "Records Processed:" && ProcessedRecords & return & ┬¼"Hold down ∩ú┐-option-mouse to interrupt."end repeatCleanUpStuffend FixedToVaron LoadAllData infile--loads all data into a single global variable for faster processinganswer "Hypercard has approximately" && the heapspace div 1024 & "K"┬¼&& "of free in which to process your data.  If this figure isnΓÇÖt larger"┬¼&& "than your input file, please choose ΓÇ£AbortΓÇ¥ and either allocate"┬¼&& "more memory to HyperCard or run The Delimiter Fixer in Low Memory Mode."┬¼with "Continue" or "Abort"if it is "abort" thenglobal DFImportFileclose file DFImportFilereturn emptyend ifglobal DFDATAread from file infile until end --eofif the result contains "not enough memory" thenanswer "Sorry, there is not enough memory to load your data file."┬¼&& "Either attempt this operation in Low Memory Mode or"┬¼&& "split your data file into smaller segments." with "OK"return emptyend ifput it into DFDATAclose file infileend LoadAllDataon CleanUpStuff--cleans up after conversion proceduresglobal DFDATA, DFImportFile, DFExportFileif the hilite of bg btn "Low Memory Mode" then close file DFImportFileclose file DFExportFileput empty into DFDATADFRemoveMaskallowinterruptionend CleanUpStuffΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧MASK ROUTINESΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧on DFSetUpMask--sets up the mask field for user messages etc. during conversion runlock screenshow bg fld maskput empty into bg fld maskrepeat 6 times -- the number of visible linesput return after bg fld maskend repeatunlock screen with dissolve very fastend DFSetUpMaskon DFRemoveMask--removes mask and clears out its fieldlock screenput empty into bg fld maskhide bg fld maskhide bg btn "OK"hide bg btn "Save..."unlock screen with dissolve very fastend DFRemoveMaskon DFMaskMessage TheMess--puts THEMESS as a message to user during conversion at bottom of mask fieldput theMess into line (5 - the number of lines in themess) to 5 of bg fld mask-- 5 is the last visible lineend DFMaskMessageΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧MENU ROUTINESΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧on DFSetUpMenu whichshow menubarif which is "on" thenif there is not a menu "DF" thencreate menu "DF"put "Main Card,DF Help,DF Headers" into menu "DF"set the menuMessage of menuitem "Main Card" of menu "DF" to DFMainCardset the menuMessage of menuitem "DF Help" of menu "DF" to DFHelpset the menuMessage of menuitem "DF Headers" of menu "DF" to DFHeadersend ifelse if which is "off" thenreset menubarend ifend DFSetUpMenuon DFMainCardlock screengo to card "Main Card"unlock screen with dissolveend DFMainCardon DFHelplock screengo to card "DF Help"unlock screen with wipe right fastend DFHelpon DFHeaderslock screengo to card "DF Headers"unlock screen with wipe right fastend DFheadersΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧FUNCTIONSΓê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧Γê₧function SomeOtherDelimiterask "Please enter the delimiter of your choice:"if (it is empty) or (it is "Cancel") then return emptyreturn itend SomeOtherDelimiterFunction printField-- accumulates the text of the documentation together into one (big!) string for printing-- purposes.put "Intro" & return & "About" & return & "Operation" & return &┬¼"Info #1" & return & "Info #2" into TheFieldsrepeat with i = 1 to the number of lines in TheFieldsput bg fld line i of TheFields & return & return & return after manualend repeatreturn manualend printFieldfunction FileFromPath path--requires hyperCard 2.1 or higher due to the use of THE ITEMDELIMITER.--returns the last item of a pathname, most probably a fileset the itemdelimiter to colonreturn the last item of pathend FileFromPathfunction IsValidHeader TheText--tests to see if the text supplied meets minimal criteria as a valid header...put stripReturnsAndSpaces(theText) into TheTextput the number of chars in TheText into LastCharif (char 1 to 2 of TheText is "<<") thenif char lastChar-1 to lastChar of TheText is ">>" then return trueend ifreturn falseend IsValidHeaderfunction theNextRecordglobal RecordDelimiter--loads the next "record" to be processed, whether from disk or memory.  It--deletes each "record" from the global variable as it it processed.if the hilite of bg btn "Low Memory Mode" thenglobal DFImportFileread from file DFImportFile until RecordDelimiter -- one "line"delete the last char of it --removes the record delimiterreturn itelseglobal DFDATA, RecordDelimiterput the itemdelimiter into savedDelimiterset the itemdelimiter to RecordDelimiterget the first item of DFDATAdelete the first item of DFDATAset the itemdelimiter to savedDelimiterreturn itend ifend theNextRecordfunction UserInterrupt--optional interruptif the commandkey is down thenif (the optionkey is down) and (the mouse is down) thenbeep 3return trueend ifend ifreturn falseend UserInterruptfunction stripReturnsAndSpaces theText--this is stolen from some Claris stack (I don't remember which) and is somewhat--modified to strip spaces from the front of a string and both spaces and returns from the--end. I think the original just removed things from the endrepeatif (the last char of theText is space) or (the last char of theText is return)┬¼then delete the last char of theTextelseif (the first char of theText is space) then delete the first char of theTextelse return theTextend ifend repeatend stripReturnsAndSpacesfunction HitTest where, what--stolen from Jon Pugh's HPopUpMenu stack for the little arrow icons--on the ends of popup menusif what = "" or what = "btn" thenrepeat with i = the number of cd btns down to 1if where is within rect of cd btn i thenif visible of cd btn i and name of cd btn i Γëá name of targetthen return "cd btn id " & the id of cd btn iend ifend repeatrepeat with i = the number of bg btns down to 1if where is within rect of bg btn i thenif visible of bg btn i and name of bg btn i Γëá name of targetthen return " bg btn id "& the id of bg btn iend ifend repeatend ifif what = "" or what = "fld" thenrepeat with i = the number of cd flds down to 1if where is within rect of cd fld i thenif visible of cd fld i and name of cd fld i Γëá name of targetthen return "cd fld id " & the id of cd fld iend ifend repeatrepeat with i = the number of bg flds down to 1if where is within rect of bg fld i thenif visible of bg fld i and name of bg fld i Γëá name of targetthen return " bg fld id "& the id of bg fld iend ifend repeatend ifreturn ""end HitTest</script>
  17.     <background id="2681" file="background_2681.xml" name="" />
  18.     <background id="4711" file="background_4711.xml" name="" />
  19.     <card id="2959" file="card_2959.xml" marked="false" name="Main Card" owner="2681" />
  20.     <card id="4900" file="card_4900.xml" marked="false" name="DF Help" owner="4711" />
  21.     <card id="4565" file="card_4565.xml" marked="false" name="DF Headers" owner="4711" />
  22. </stack>
  23.