跳轉至內容

SuperCard 程式設計/提示與技巧/堆疊作為文件模板

來自華夏公益教科書

堆疊作為文件

[編輯 | 編輯原始碼]

一種方法是將模板儲存為使用者屬性,並在需要新文件時將其寫出。


storeDoc 在您準備應用程式時執行一次

on storedoc
  answer file "Choose a template to use:"
  if it is "" then exit storeDoc
  put it into tFile
  open file tFile
  read from file tfile until end
  close file Tfile
  define the UDoc of this proj
  set the uDoc of this proj to it
end storeDoc


newDoc 在您需要新文件時執行

on newDoc
  ask file "Name your doc:"
  if it is "" then exit newDoc
  put it into tFile
  put the fileType into toldType
  set the fileType to RUNXMDOX
  --Or your standalone's creator and file Type
  open file tfile
  write the uDoc of this proj to file tfile
  close file tfile
  set the fileType to toldType

  set the itemdel to colon
  put last item of tfile into tWindowName
  set the name of wd 1 of proj tFile to tWindowName

  open proj tFile
end newDoc


對於捆綁應用程式,也可以將模板儲存在捆綁包中的某個位置,並在需要新專案時將其複製出來。

顯然,如果您想開啟一個無標題文件,該文件類似於標準文件並需要顯式儲存,則事情會變得更加複雜。

Keith 對 Graham Samuel 關於獨立應用程式的筆記進行了更新:[[1]]

華夏公益教科書