Changeset 228 for trunk/lingosource/castlib2
- Timestamp:
- 03/20/09 18:08:22 (3 years ago)
- Location:
- trunk/lingosource/castlib2
- Files:
-
- 5 edited
-
GetSetPrefs.ls (modified) (1 diff)
-
PseudoXMLPS.ls (modified) (19 diffs)
-
aleXtrasMovieScript.ls (modified) (2 diffs)
-
commonMovieScript.ls (modified) (4 diffs)
-
memberInfo.xml (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lingosource/castlib2/GetSetPrefs.ls
r186 r228 179 179 -- delete line 1 of prefsText 180 180 181 gPrefs = call(#mGetListFromXMLString , mGetXScript(#PseudoXMLPS), prefsText)181 gPrefs = call(#mGetListFromXMLStringX, mGetXScript(#PseudoXMLPS), prefsText) 182 182 if objectP(gPrefs) then globs[#gPrefs] = gPrefs 183 183 -
trunk/lingosource/castlib2/PseudoXMLPS.ls
r215 r228 2 2 ----------------------------------- 3 3 -- CREATED: 4 -- 06.03.20084 -- 2002 5 5 -- 6 6 -- DESCRIPTION: 7 7 -- Pseudo XML by Alex da Franca c2003 8 -- Convert a lingo list to a XML like string and back8 -- Convert a lingo list to a XML like string and back 9 9 10 10 -- 11 11 -- REQUIRES: 12 -- (Prerequisites) 12 -- only the functions mSaveList_2_XML() and mReadXML_2_List() require my system of library scripts 13 -- in order to write and read text with fileio. All other functions have no dependencies 14 -- Either get these scripts from my website, or replace the write/read stuff with your own fileIO handlers 15 -- That is: 16 -- * movie script "aleXtrasMovieScript" 17 -- * parent script "commonMovieScript" 18 -- * parent script "FileIOFunktionen" 13 19 -- 14 20 -- USAGE: 21 -- ---------- please see the comments for each handler for a how-to. 22 -- ---------- nonetheless here are some fast start comments with the minimum amount of parameters 23 -- PseudoXMLPS = new(script "PseudoXMLPS") 24 -- -- Convert a list to an xml string: 25 -- xmlString = PseudoXMLPS.mGetXMLStringFromList(["one", "two", [#prop: 3]]) 26 -- lingolist = PseudoXMLPS.mGetListFromXMLStringX(xmlString) 27 -- ---------- basically that's it 28 -- 29 -- ---------- another "hack" to be aware of is the following: 30 -- ---------- linear lists get identified by having a nodename which starts with the exact string "item" 31 -- ---------- so if an xml node like <item1>one</item1> is encountered, it is treated as linear list: ["one"] 32 -- ---------- and NOT as [#item1:"one"] 33 -- 34 -- ---------- the mGetXMLStringFromList() function escapes the reserved xml chars <> and & and ' and " by default 35 -- ---------- if for some reason you rather want to enclose the contents in a <![CDATA[ tag, use the dontReplaceGT flag. 36 --------------------------------------------- EXAMPLE for <dontReplaceGT = 1> (dontReplaceGT means don't replace "greater than" btw...): 37 -- 15 38 -- myList = [#stringWithInvalidChars:"A string with invalid chars like <> and & and ' and " & QUOTE] 16 39 -- myList[#stringWithInvalidChars] = "<![CDATA[" & myList[#stringWithInvalidChars] & "]]>" … … 28 51 -- end if 29 52 -- end repeat 53 --------------------------------------------- please note, that the above example is ONLY needed, if you use dontReplaceGT = 1 !! 30 54 -- 31 55 -- HISTORY: … … 129 153 -- ACTION: Convert lingo list (also nested lists) to XML stylish string 130 154 -- INPUT: 131 --<listref> format: property list or linear list132 --<docName> format: #string; optional. if omitted "Untitled" is used for the XML document name155 -- <listref> format: property list or linear list 156 -- <docName> format: #string; optional. if omitted "Untitled" is used for the XML document name 133 157 -- <strict> => boolean; avoid spaces in tag names 134 158 -- <dontReplaceGT> => boolean; dont replace < and > 135 159 -- <withParams> => boolean; write attribute in tag for the lingo ilk => bigger xml files and unfortunately it is slower to parse 136 ----------------------------- (I thought avoiding value() would help, but in this case the additional text parsing of the attributes tag slows down)160 ----------------------------- (I thought avoiding value() would help, but in this case the additional text parsing of the attributes tag slows down) 137 161 -- RETURNS: string 138 162 -- EXAMPLE: saveString = mGetXMLStringFromList(me, lingo_list, "documentName") … … 173 197 -- ACTION: Description 174 198 -- INPUT: 175 --<str> format: #string; split a string using <> and </> tags into lingo list176 --<convertValues> #integer 0=>don't convert (fast, all values are strings), 1 => convert only numbers (slower); 2 => try to convert all data, even colors (slow)199 -- <str> format: #string; split a string using <> and </> tags into lingo list 200 -- <convertValues> #integer 0=>don't convert (fast, all values are strings), 1 => convert only numbers (slower); 2 => try to convert all data, even colors (slow) 177 201 -- <withParams> : #boolean : parse parameters too. new, not very well tested 178 202 -- RETURNS: property list … … 224 248 -- BUT it must be a valid xml string, the above is slower but allows more malformed xml 225 249 -- INPUT: 226 --<str> format: #string; split a string using <> and </> tags into lingo list227 --<convertValues> #integer228 ---- -- 0 => don't convert (fast, all values are strings)229 ---- -- 1 => convert only integer() and float() (slower)230 ---- -- 2 => try to convert all data with value(), even parse for colors in hexstring format (slow)250 -- <str> format: #string; split a string using <> and </> tags into lingo list 251 -- <convertValues> #integer 252 -- -- -- 0 => don't convert (fast, all values are strings) 253 -- -- -- 1 => convert only integer() and float() (slower) 254 -- -- -- 2 => try to convert all data with value(), even parse for colors in hexstring format (slow) 231 255 -- RETURNS: property list 232 256 -- EXAMPLE: lingo_list = mGetListFromXMLStringX(me, saveString) … … 306 330 li = mConvertXMLPropList(me, [xx], convertValues, dontEscapeSpecialChars) 307 331 308 -- put "x" && the milliseconds - ms332 -- put "PseudoXMLPS: mGetListFromXMLStringX:" && the milliseconds - ms 309 333 310 334 if not(listP(li)) then return [:] … … 328 352 329 353 dertext = xscr(#FileIOFunktionen).mGetTextFromFile(thePath) 330 if length(dertext) > 0 then return xscr(#PseudoXMLPS).mGetListFromXMLStringX(dertext)354 if length(dertext) > 0 then return mGetListFromXMLStringX(me, dertext) 331 355 return [:] 332 356 end … … 345 369 346 370 if not(listP(theList)) then return 0 347 theResult = xscr(#PseudoXMLPS).mGetXMLStringFromList(theList)371 theResult = mGetXMLStringFromList(me, theList) 348 372 return xscr(#FileIOFunktionen).mSaveToTextFile(theResult, thePath) 349 373 end … … 757 781 758 782 if val.length = 7 then 759 if (val.char[1] = "#") and (offset(val.char[2], "abcdef0123456789") > 0) then return rgb(val) 783 if (val.char[1] = "#") then 784 isColor = 1 785 repeat with n = 2 to 7 786 if (offset(val.char[n], "abcdef0123456789") < 1) then 787 isColor = 0 788 exit repeat 789 end if 790 end repeat 791 if isColor = 1 then return rgb(val) 792 end if 760 793 end if 761 794 … … 921 954 if count(val) then 922 955 if ilk(retlist) = #proplist then 923 retlist.addProp(symbol(inputlist[n].getaprop(#name)), mConvertXMLPropList(me, val, convertValues, dontEscapeSpecialChars))924 else956 retlist.addProp(symbol(inputlist[n].getaprop(#name)), mConvertXMLPropList(me, val, convertValues, dontEscapeSpecialChars)) 957 else 925 958 retlist.add(mConvertXMLPropList(me, val, convertValues, dontEscapeSpecialChars)) 926 959 end if … … 943 976 944 977 -- unescape <>&'" 945 if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val)978 if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val) 946 979 947 980 #integer: … … 988 1021 989 1022 -- unescape <>&'" 990 if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val)1023 if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val) 991 1024 992 1025 … … 1000 1033 1001 1034 if ilk(retlist) = #proplist then 1002 retlist.addProp(symbol(inputlist[n].getaprop(#name)), val)1035 retlist.addProp(symbol(inputlist[n].getaprop(#name)), val) 1003 1036 else 1004 1037 retlist.add(val) … … 1022 1055 -- INPUT: <theText> ; string ; required => xml formatted string 1023 1056 -- RETURNS: property list 1024 -- EXAMPLE: plist = xscr(#PseudoXMLPS).mParseExcelXML(xscr(#FileIOFunktionen).mGetTextFromFile())1057 -- EXAMPLE: plist = new(script "PseudoXMLPS").mParseExcelXML(xscr(#FileIOFunktionen).mGetTextFromFile()) 1025 1058 ----------------------------------- 1026 1059 … … 1061 1094 1062 1095 else 1063 call(#mPut, mGetXScript(), "mParseExcelXML: Row "&n&" Cell "&m&" is not a property list")1096 put "mParseExcelXML: Row "&n&" Cell "&m&" is not a property list" 1064 1097 end if -- if ilk(thisCell) = #proplist then 1065 1098 … … 1067 1100 1068 1101 else 1069 call(#mPut, mGetXScript(), "mParseExcelXML: Row "&n&" is not a list")1102 put "mParseExcelXML: Row "&n&" is not a list" 1070 1103 end if -- if listP(currRow) then 1071 1104 … … 1073 1106 1074 1107 else 1075 call(#mPut, mGetXScript(), "mParseExcelXML: Table not found")1108 put "mParseExcelXML: Table not found" 1076 1109 end if -- if listP(xmlList) then 1077 1110 1078 1111 else 1079 call(#mPut, mGetXScript(), "mParseExcelXML: Worksheet not found")1112 put "mParseExcelXML: Worksheet not found" 1080 1113 end if -- if ilk(xmlList) = #proplist then 1081 1114 1082 1115 else 1083 call(#mPut, mGetXScript(), "mParseExcelXML: Workbook not found")1116 put "mParseExcelXML: Workbook not found" 1084 1117 end if -- if ilk(xmlList) = #proplist then 1085 1118 1086 1119 else 1087 call(#mPut, mGetXScript(), "mParseExcelXML: ROOT is not a property list")1120 put "mParseExcelXML: ROOT is not a property list" 1088 1121 end if --if ilk(xmlList) = #proplist then 1089 1122 1090 1123 else 1091 call(#mPut, mGetXScript(), "mParseExcelXML: Xml parser makelist() returned empty list")1124 put "mParseExcelXML: Xml parser makelist() returned empty list" 1092 1125 end if -- if count(xmlList) > 0 then 1093 1126 1094 1127 else 1095 call(#mPut, mGetXScript(), "mParseExcelXML: Xml parser makelist() failed")1128 put "mParseExcelXML: Xml parser makelist() failed" 1096 1129 end if -- if listP(xmlList) then 1097 1130 1098 1131 else 1099 call(#mPut, mGetXScript(), "mParseExcelXML: Xml parser error: "&xmlp.getError())1132 put "mParseExcelXML: Xml parser error: "&xmlp.getError() 1100 1133 end if -- if voidP(xmlp.getError()) then 1101 1134 … … 1113 1146 -- INPUT: <pfad> ; string ; full pathname to plist file. This is optional, if it is void or "" a file selection dialog is displayed 1114 1147 -- RETURNS: property list 1115 -- EXAMPLE: plist = xscr(#PseudoXMLPS).mReadPList()1148 -- EXAMPLE: plist = new(script "PseudoXMLPS").mReadPList() 1116 1149 ----------------------------------- 1117 1150 … … 1186 1219 1187 1220 on mGetListFromPListString me, str 1188 return mConvertKeyList(me, mGetListFromXMLString (me, str, 0))1221 return mConvertKeyList(me, mGetListFromXMLStringX(me, str, 0)) 1189 1222 end 1190 1223 -
trunk/lingosource/castlib2/aleXtrasMovieScript.ls
r186 r228 49 49 halt 50 50 end if 51 52 if voidP(cms.script) then -- strangely enough this happened suddenly, dunno why... 53 -- until now it happened only in authoring with the stopped movie 54 -- therefore I just exit here without alert 55 halt 56 end if 57 51 58 alextras = rawnew(cms.script) 52 59 if ilk(alextras) <> #instance then … … 55 62 end if 56 63 (script "aleXtrasMovieScript").pAleXtras = alextras 64 57 65 end if 58 66 return alextras -
trunk/lingosource/castlib2/commonMovieScript.ls
r215 r228 387 387 -- ACTION: Create/Get timeout object 388 388 -- This handler works the same with the old player <10 and the new player >=10 389 -- INPUT: || ÊtheName || string || name for new timeout object||390 -- || ÊtheDuration || integer || timeout perios in milliseconds||389 -- INPUT: || theName || string || name for new timeout object|| 390 -- || theDuration || integer || timeout perios in milliseconds|| 391 391 -- || theHandler || symbol || handler to be called on each timepout event|| 392 392 -- || theTarget || object || object to be sent the timeout event <theHandler>|| … … 1705 1705 -- dummy handler for translate function 1706 1706 1707 on mTranslate me, aString 1707 on mTranslate me, aString, variablesList 1708 1708 theGlobs = mGetGlobalList(me) 1709 1709 uebersetzungsListe = theGlobs.getaprop(#gUebersetzung) … … 1711 1711 uebersetzung = uebersetzungsListe.getaprop(aString) 1712 1712 if voidP(uebersetzung) then 1713 if listP(variablesList) then return mReplacePlaceHoldersInString(me, aString, variablesList) 1713 1714 return aString 1714 1715 else … … 1725 1726 end 1726 1727 1728 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1729 1730 on mReplacePlaceHoldersInString me, aString, variablesList 1731 if ilk(variablesList) = #proplist then 1732 cnt = count(variablesList) 1733 if cnt > 0 then 1734 repeat with n = 1 to cnt 1735 str = string(variablesList[n]) 1736 prop = variablesList.getPropAt(n) 1737 srchStr = "%%" & prop & "%%" 1738 len = length(srchStr) - 1 1739 offs = offset(srchStr, aString) 1740 repeat while offs > 0 1741 put str into char offs to offs + len of aString 1742 offs = offset(srchStr, aString) 1743 end repeat 1744 end repeat 1745 end if 1746 else if ilk(variablesList) = #list then -- printf like replacement 1747 if count(variablesList) > 0 then 1748 offs = offset("%s", aString) 1749 str = string(variablesList[1]) 1750 repeat while offs > 0 1751 put str into char offs to offs + 1 of aString 1752 if count(variablesList) > 1 then variablesList.deleteAt(1) 1753 offs = offset("%s", aString) 1754 end repeat 1755 end if 1756 end if 1757 return aString 1758 end 1727 1759 1728 1760 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
trunk/lingosource/castlib2/memberInfo.xml
r198 r228 5 5 <comments>~/Documents/Scripts/lingo/commonMovieScript.ls</comments> 6 6 <memberName>commonMovieScript</memberName> 7 <f Name>commonMovieScript</fName>7 <fname>commonMovieScript</fname> 8 8 </commonmoviescript> 9 9 <FileIOFunktionen> … … 11 11 <comments>~/Documents/Scripts/lingo/FileIOFunktionen.ls</comments> 12 12 <memberName>FileIOFunktionen</memberName> 13 <f Name>FileIOFunktionen</fName>13 <fname>FileIOFunktionen</fname> 14 14 </FileIOFunktionen> 15 15 <GetSetPrefs> … … 17 17 <comments>~/Documents/Scripts/lingo/GetSetPrefs.ls</comments> 18 18 <memberName>GetSetPrefs</memberName> 19 <f Name>GetSetPrefs</fName>19 <fname>GetSetPrefs</fname> 20 20 </GetSetPrefs> 21 21 <aleXtrasMovieScript> … … 23 23 <comments>~/Documents/Scripts/lingo/aleXtrasMovieScript.ls</comments> 24 24 <memberName>aleXtrasMovieScript</memberName> 25 <f Name>aleXtrasMovieScript</fName>25 <fname>aleXtrasMovieScript</fname> 26 26 </aleXtrasMovieScript> 27 27 <PseudoXMLPS> … … 29 29 <comments>~/Documents/Scripts/lingo/PseudoXMLPS.ls</comments> 30 30 <memberName>PseudoXMLPS</memberName> 31 <f Name>PseudoXMLPS</fName>31 <fname>PseudoXMLPS</fname> 32 32 </PseudoXMLPS> 33 33 <simpleGoToAction> … … 35 35 <comments>/Users/alex/Documents/ALIEN/myLinkedScripts/simpleGoToAction.ls</comments> 36 36 <memberName>simpleGoToAction</memberName> 37 <f Name>simpleGoToAction</fName>37 <fname>simpleGoToAction</fname> 38 38 </simpleGoToAction> 39 39 <SpriteNameBeaver> … … 41 41 <comments>~/Documents/Scripts/lingo/SpriteNameBeaver.ls</comments> 42 42 <memberName>SpriteNameBeaver</memberName> 43 <f Name>SpriteNameBeaver</fName>43 <fname>SpriteNameBeaver</fname> 44 44 </SpriteNameBeaver> 45 45 <subversionVersionChecker> … … 47 47 <comments>~/Documents/Scripts/lingo/subversionVersionChecker.ls</comments> 48 48 <memberName>subversionVersionChecker</memberName> 49 <f Name>subversionVersionChecker</fName>49 <fname>subversionVersionChecker</fname> 50 50 </subversionVersionChecker> 51 51 </Untitled>
Note: See TracChangeset
for help on using the changeset viewer.
