home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1998 December / WPCDEC98.ISO / dxrs / Sofwpc12.dxr / 00198_convertxl.ls < prev    next >
Encoding:
Text File  |  1998-10-12  |  5.6 KB  |  127 lines

  1. on convertxl
  2.   loadtext()
  3.   createnewdatabasescript()
  4. end
  5.  
  6. on loadtext
  7.   set fioObject to new(xtra("fileio"))
  8.   set fileName to displayOpen(fioObject)
  9.   openFile(fioObject, fileName, 1)
  10.   set content to readFile(fioObject)
  11.   closeFile(fioObject)
  12.   set fioObject to EMPTY
  13.   put content into field "loadedtext"
  14. end
  15.  
  16. on createnewdatabasescript
  17.   global SOFfeaturedlist, SOFentertainmentlist, SOFdevelopmentlist, SOFsoholist, SOFutilitieslist
  18.   set SOFfeaturedlist to list()
  19.   set SOFentertainmentlist to list()
  20.   set SOFdevelopmentlist to list()
  21.   set SOFsoholist to list()
  22.   set SOFutilitieslist to list()
  23.   set numberofrecords to the number of lines in field "loadedtext"
  24.   if line numberofrecords of field "loadedtext" = EMPTY then
  25.     set numberofrecords to numberofrecords - 1
  26.   end if
  27.   repeat with i = 1 to numberofrecords
  28.     set thisrecord to line i of field "loadedtext"
  29.     set thispropertylist to puttextstringintopropertylist(thisrecord)
  30.     case the section of thispropertylist of
  31.       "entertainment":
  32.         set howmanyrecords to count(SOFentertainmentlist)
  33.         set itemNumber to howmanyrecords + 1
  34.         set thispropertyname to "prog" & itemNumber
  35.         if itemNumber = 1 then
  36.           set actionstring to "set SOFentertainmentlist = [" & thispropertyname & ":thispropertylist]"
  37.           do(actionstring)
  38.         else
  39.           addProp(SOFentertainmentlist, thispropertyname, thispropertylist)
  40.         end if
  41.       "development":
  42.         set howmanyrecords to count(SOFdevelopmentlist)
  43.         set itemNumber to howmanyrecords + 1
  44.         set thispropertyname to "prog" & itemNumber
  45.         if itemNumber = 1 then
  46.           set actionstring to "set SOFdevelopmentlist = [" & thispropertyname & ":thispropertylist]"
  47.           do(actionstring)
  48.         else
  49.           addProp(SOFdevelopmentlist, thispropertyname, thispropertylist)
  50.         end if
  51.       "utilities":
  52.         set howmanyrecords to count(SOFutilitieslist)
  53.         set itemNumber to howmanyrecords + 1
  54.         set thispropertyname to "prog" & itemNumber
  55.         if itemNumber = 1 then
  56.           set actionstring to "set SOFutilitieslist = [" & thispropertyname & ":thispropertylist]"
  57.           do(actionstring)
  58.         else
  59.           addProp(SOFutilitieslist, thispropertyname, thispropertylist)
  60.         end if
  61.       "soho":
  62.         set howmanyrecords to count(SOFsoholist)
  63.         set itemNumber to howmanyrecords + 1
  64.         set thispropertyname to "prog" & itemNumber
  65.         if itemNumber = 1 then
  66.           set actionstring to "set SOFsoholist = [" & thispropertyname & ":thispropertylist]"
  67.           do(actionstring)
  68.         else
  69.           addProp(SOFsoholist, thispropertyname, thispropertylist)
  70.         end if
  71.     end case
  72.     if the featured of thispropertylist = "1" then
  73.       set howmanyrecords to count(SOFfeaturedlist)
  74.       set itemNumber to howmanyrecords + 1
  75.       set thispropertyname to "prog" & itemNumber
  76.       if itemNumber = 1 then
  77.         set actionstring to "set SOFfeaturedlist = [" & thispropertyname & ":thispropertylist]"
  78.         do(actionstring)
  79.         next repeat
  80.       end if
  81.       addProp(SOFfeaturedlist, thispropertyname, thispropertylist)
  82.     end if
  83.   end repeat
  84.   set SOFfeaturedliststring to string(SOFfeaturedlist)
  85.   set SOFentertainmentliststring to string(SOFentertainmentlist)
  86.   set SOFdevelopmentliststring to string(SOFdevelopmentlist)
  87.   set SOFutilitiesliststring to string(SOFutilitieslist)
  88.   set SOFsoholiststring to string(SOFsoholist)
  89.   set scriptstring to EMPTY
  90.   put "on setupdatabaseglobals" & RETURN & RETURN after scriptstring
  91.   put "global SOFfeaturedlist,SOFentertainmentlist,SOFdevelopmentlist,SOFsoholist,SOFutilitieslist" & RETURN & RETURN after scriptstring
  92.   put "set SOFfeaturedlist = " & SOFfeaturedliststring & RETURN & RETURN after scriptstring
  93.   put "set SOFentertainmentlist = " & SOFentertainmentliststring & RETURN & RETURN after scriptstring
  94.   put "set SOFdevelopmentlist = " & SOFdevelopmentliststring & RETURN & RETURN after scriptstring
  95.   put "set SOFutilitieslist = " & SOFutilitiesliststring & RETURN & RETURN after scriptstring
  96.   put "set SOFsoholist = " & SOFsoholiststring & RETURN & RETURN after scriptstring
  97.   put "end setupdatabaseglobals" after scriptstring
  98.   set the scriptText of member "setupdatabaseglobals" to scriptstring
  99.   set SOFfeaturedlist to EMPTY
  100.   set SOFentertainmentlist to EMPTY
  101.   set SOFdevelopmentlist to EMPTY
  102.   set SOFutilitieslist to EMPTY
  103.   set SOFsoholist to EMPTY
  104. end
  105.  
  106. on puttextstringintopropertylist thisrecord
  107.   set DataEntryThisRecordData to [#productName: EMPTY, #version: EMPTY, #platform: EMPTY, #category: EMPTY, #productinfo: EMPTY, #systemreqs: EMPTY, #uninstallinfo: EMPTY, #playinstcopy: EMPTY, #size: EMPTY, #salesenquiries: EMPTY, #techsupport: EMPTY, #weblink: EMPTY, #section: EMPTY, #installpathname: EMPTY, #screenshot: EMPTY, #sound: EMPTY, #video: EMPTY, #featured: EMPTY]
  108.   set fieldtext to EMPTY
  109.   set startcharacter to 1
  110.   set fieldnumber to 1
  111.   repeat with i = 1 to the number of chars in thisrecord
  112.     if char i of thisrecord = TAB then
  113.       set fieldtext to chars(thisrecord, startcharacter, i - 1)
  114.       set thisproperty to getPropAt(DataEntryThisRecordData, fieldnumber)
  115.       setaProp(DataEntryThisRecordData, thisproperty, fieldtext)
  116.       set startcharacter to i + 1
  117.       set fieldnumber to fieldnumber + 1
  118.     end if
  119.     if (char i of thisrecord <> TAB) and (i = the number of chars in thisrecord) then
  120.       set fieldtext to chars(thisrecord, startcharacter, the number of chars in thisrecord)
  121.       set thisproperty to getPropAt(DataEntryThisRecordData, fieldnumber)
  122.       setaProp(DataEntryThisRecordData, thisproperty, fieldtext)
  123.     end if
  124.   end repeat
  125.   return DataEntryThisRecordData
  126. end
  127.