Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window

Ignore:
Timestamp:
03/20/09 18:08:22 (3 years ago)
Author:
alex
Message:

added handler to export only scripttext with metadata for the member and added new handler to svn quicklinks to update all castlibs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lingosource/castlib2/PseudoXMLPS.ls

    r215 r228  
    22----------------------------------- 
    33-- CREATED: 
    4 -- 06.03.2008 
     4-- 2002 
    55-- 
    66-- DESCRIPTION: 
    77--              Pseudo XML by Alex da Franca c2003 
    8 -- Convert a lingo list to a XML like string and back 
     8--              Convert a lingo list to a XML like string and back 
    99 
    1010-- 
    1111-- 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" 
    1319-- 
    1420-- 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-- 
    1538-- myList = [#stringWithInvalidChars:"A string with invalid chars like <> and & and ' and " & QUOTE] 
    1639-- myList[#stringWithInvalidChars] = "<![CDATA[" & myList[#stringWithInvalidChars] & "]]>" 
     
    2851--   end if 
    2952-- end repeat 
     53--------------------------------------------- please note, that the above example is ONLY needed, if you use dontReplaceGT = 1 !! 
    3054-- 
    3155-- HISTORY: 
     
    129153  -- ACTION: Convert lingo list (also nested lists) to XML stylish string 
    130154  -- INPUT:  
    131 -- <listref> format: property list or linear list 
    132 -- <docName> format: #string; optional. if omitted "Untitled" is used for the XML document name 
     155  --              <listref> format: property list or linear list 
     156  --              <docName> format: #string; optional. if omitted "Untitled" is used for the XML document name 
    133157  --              <strict>        => boolean; avoid spaces in tag names 
    134158  --              <dontReplaceGT> => boolean; dont replace < and > 
    135159  --              <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) 
    137161  -- RETURNS: string 
    138162  -- EXAMPLE: saveString = mGetXMLStringFromList(me, lingo_list, "documentName") 
     
    173197  -- ACTION: Description 
    174198  -- INPUT: 
    175 -- <str> format: #string; split a string using <> and </> tags into lingo list 
    176 -- <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) 
    177201  --          <withParams> : #boolean : parse parameters too. new, not very well tested 
    178202  -- RETURNS: property list 
     
    224248  --         BUT it must be a valid xml string, the above is slower but allows more malformed xml 
    225249  -- INPUT:  
    226 -- <str> format: #string; split a string using <> and </> tags into lingo list 
    227 -- <convertValues> #integer 
    228 -- -- -- 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) 
    231255  -- RETURNS: property list 
    232256  -- EXAMPLE: lingo_list = mGetListFromXMLStringX(me, saveString) 
     
    306330  li = mConvertXMLPropList(me, [xx], convertValues, dontEscapeSpecialChars) 
    307331   
    308  -- put "x" && the milliseconds - ms 
     332  -- put "PseudoXMLPS: mGetListFromXMLStringX:" && the milliseconds - ms 
    309333   
    310334  if not(listP(li)) then return [:] 
     
    328352   
    329353  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) 
    331355  return [:] 
    332356end 
     
    345369   
    346370  if not(listP(theList)) then return 0 
    347   theResult = xscr(#PseudoXMLPS).mGetXMLStringFromList(theList) 
     371  theResult = mGetXMLStringFromList(me, theList) 
    348372  return xscr(#FileIOFunktionen).mSaveToTextFile(theResult, thePath) 
    349373end 
     
    757781   
    758782  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 
    760793  end if  
    761794   
     
    921954      if count(val) then 
    922955        if ilk(retlist) = #proplist then 
    923         retlist.addProp(symbol(inputlist[n].getaprop(#name)), mConvertXMLPropList(me, val, convertValues, dontEscapeSpecialChars)) 
    924       else 
     956          retlist.addProp(symbol(inputlist[n].getaprop(#name)), mConvertXMLPropList(me, val, convertValues, dontEscapeSpecialChars)) 
     957        else 
    925958          retlist.add(mConvertXMLPropList(me, val, convertValues, dontEscapeSpecialChars)) 
    926959        end if 
     
    943976               
    944977              -- unescape <>&'" 
    945                if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val) 
     978              if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val) 
    946979               
    947980            #integer: 
     
    9881021             
    9891022            -- unescape <>&'" 
    990            if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val) 
     1023            if dontEscapeSpecialChars <> 1 then val = mUnEscapeSpecialChars(me, val) 
    9911024             
    9921025             
     
    10001033         
    10011034        if ilk(retlist) = #proplist then 
    1002         retlist.addProp(symbol(inputlist[n].getaprop(#name)), val) 
     1035          retlist.addProp(symbol(inputlist[n].getaprop(#name)), val) 
    10031036        else 
    10041037          retlist.add(val) 
     
    10221055  -- INPUT: <theText> ; string ; required => xml formatted string 
    10231056  -- RETURNS: property list 
    1024   -- EXAMPLE: plist = xscr(#PseudoXMLPS).mParseExcelXML(xscr(#FileIOFunktionen).mGetTextFromFile()) 
     1057  -- EXAMPLE: plist = new(script "PseudoXMLPS").mParseExcelXML(xscr(#FileIOFunktionen).mGetTextFromFile()) 
    10251058  ----------------------------------- 
    10261059   
     
    10611094                         
    10621095                      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" 
    10641097                      end if -- if ilk(thisCell) = #proplist then 
    10651098                       
     
    10671100                     
    10681101                  else 
    1069                     call(#mPut, mGetXScript(), "mParseExcelXML: Row "&n&" is not a list") 
     1102                    put "mParseExcelXML: Row "&n&" is not a list" 
    10701103                  end if -- if listP(currRow) then 
    10711104                   
     
    10731106                 
    10741107              else 
    1075                 call(#mPut, mGetXScript(), "mParseExcelXML: Table not found") 
     1108                put "mParseExcelXML: Table not found" 
    10761109              end if -- if listP(xmlList) then 
    10771110               
    10781111            else 
    1079               call(#mPut, mGetXScript(), "mParseExcelXML: Worksheet not found") 
     1112              put "mParseExcelXML: Worksheet not found" 
    10801113            end if -- if ilk(xmlList) = #proplist then 
    10811114             
    10821115          else 
    1083             call(#mPut, mGetXScript(), "mParseExcelXML: Workbook not found") 
     1116            put "mParseExcelXML: Workbook not found" 
    10841117          end if -- if ilk(xmlList) = #proplist then 
    10851118           
    10861119        else 
    1087           call(#mPut, mGetXScript(), "mParseExcelXML: ROOT is not a property list") 
     1120          put "mParseExcelXML: ROOT is not a property list" 
    10881121        end if --if ilk(xmlList) = #proplist then 
    10891122         
    10901123      else 
    1091         call(#mPut, mGetXScript(), "mParseExcelXML: Xml parser makelist() returned empty list") 
     1124        put "mParseExcelXML: Xml parser makelist() returned empty list" 
    10921125      end if -- if count(xmlList) > 0 then 
    10931126       
    10941127    else 
    1095       call(#mPut, mGetXScript(), "mParseExcelXML: Xml parser makelist() failed") 
     1128      put "mParseExcelXML: Xml parser makelist() failed" 
    10961129    end if -- if listP(xmlList) then 
    10971130     
    10981131  else 
    1099     call(#mPut, mGetXScript(), "mParseExcelXML: Xml parser error: "&xmlp.getError()) 
     1132    put "mParseExcelXML: Xml parser error: "&xmlp.getError() 
    11001133  end if -- if voidP(xmlp.getError()) then 
    11011134   
     
    11131146  -- INPUT: <pfad> ; string ; full pathname to plist file. This is optional, if it is void or "" a file selection dialog is displayed  
    11141147  -- RETURNS: property list 
    1115   -- EXAMPLE: plist = xscr(#PseudoXMLPS).mReadPList() 
     1148  -- EXAMPLE: plist = new(script "PseudoXMLPS").mReadPList() 
    11161149  ----------------------------------- 
    11171150   
     
    11861219 
    11871220on mGetListFromPListString me, str 
    1188   return mConvertKeyList(me, mGetListFromXMLString(me, str, 0)) 
     1221  return mConvertKeyList(me, mGetListFromXMLStringX(me, str, 0)) 
    11891222end 
    11901223 
Note: See TracChangeset for help on using the changeset viewer.