Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------------
- -- Система визуального программирования FormsMaker от Zer0Galaxy --
- -- http://computercraft.ru/topic/1044-sistema-vizualnogo-programmirovaniia-formsmaker/ --
- -- Последнюю версию программы можно скачать выполнив: pastebin get wA5KMKav fmaker.lua --
- -- Для работы программы требуется библиотека forms: pastebin get iKzRve2g lib/forms.lua --
- ------------------------------------------------------------------------------------------
- forms=require("forms")
- fs = require("filesystem")
- local gpu=require("component").gpu
- local objTouch, objMove, objResize
- local xTouch, yTouch
- local WinW, WinH = gpu.getResolution()
- local activeForm
- local projName
- local projExt=".fmk"
- local noEvent={name=""}
- local eventToEdit
- local len=require("unicode").len
- Objects={}
- TForms={}
- function mainForm()
- forms.activeForm():hide()
- activeForm:setActive()
- end
- function showProp()
- forms.activeForm():hide()
- activeForm:setActive()
- local properties={}
- function addProp(obj)
- for k,v in pairs(obj) do
- if type(v)=="boolean" or type(v)=="number" or type(v)=="string" then
- properties[k]=true end
- end
- end
- addProp(objTouch)
- local TComp=objTouch.__index
- addProp(TComp)
- TComp=getmetatable(TComp)
- addProp(TComp)
- PropList:clear()
- for k in pairs(properties) do
- if string.lower(k):find("color") then PropList:insert(string.format("%-10s│0x%06x",k,objTouch[k]),k)
- else PropList:insert(string.format("%-10s│%s",k,objTouch[k]),k) end
- end
- PropList:sort()
- for k,v in pairs(objTouch.events) do
- v.name=k
- PropList:insert(string.format("%-10s│%s",k,v.proc.name),v)
- end
- PropList.index=0
- PropList.onChange=selProp
- PropInsp:setActive()
- end
- function mouseEv(self,ev,x,y,btn)
- if self.elements then
- for i=#self.elements,1,-1 do
- local e=self.elements[i]
- if x>=e.X and x<e.X+e.W and y>=e.Y and y<e.Y+e.H then
- e.mouseEv(e,ev,x,y,btn)
- return
- end
- end
- end
- if self[ev] then self[ev](self, x-self.X+1,y-self.Y+1,btn) end
- end
- function touch(obj,x,y,btn)
- objTouch=obj
- if btn==0 then --Left click
- xTouch=obj.X+x
- yTouch=obj.Y+y
- if x==obj.W and y==obj.H then --Resize
- objResize=obj
- else --Move
- objMove=obj
- end
- elseif btn==1 then --Right click
- xTouch=x
- yTouch=y
- ObjList.index=0 ObjList.shift=0
- ObjList.lines[1]="Свойства "..obj.name
- ObjList.lines[2]="Удалить "..obj.name
- ObjInsp.left=obj.X+x-1
- if ObjInsp.left>WinW-ObjInsp.W+1 then ObjInsp.left=WinW-ObjInsp.W+1 end
- if ObjInsp.left<1 then ObjInsp.left=1 end
- ObjInsp.top=obj.Y+y-1
- if ObjInsp.top>WinH-ObjInsp.H+1 then ObjInsp.top=WinH-ObjInsp.H+1 end
- if ObjInsp.top<1 then ObjInsp.top=1 end
- ObjInsp:setActive()
- end
- end
- function drag(obj,x,y,btn)
- if btn==0 then
- if not objTouch.parent then
- gpu.setBackground(0)
- gpu.fill(obj.X,obj.Y,obj.W,obj.H," ")
- end
- local dx,dy=obj.X+x-xTouch, obj.Y+y-yTouch
- xTouch=obj.X+x
- yTouch=obj.Y+y
- if objMove then
- objMove.left=objMove.left+dx
- objMove.top=objMove.top+dy
- if objMove.left<1 then objMove.left=1 objMove=nil
- elseif objMove.top<1 then objMove.top=1 objMove=nil end
- end
- if objResize then
- objResize.W=objResize.W+dx
- objResize.H=objResize.H+dy
- if objResize.W<2 then objResize.W=2 objResize=nil
- elseif objResize.H<1 then objResize.H=1 objResize=nil end
- end
- if objTouch.parent then (objTouch.parent):draw()
- else objTouch:draw()
- end
- end
- end
- function drop(obj,x,y,btn)
- objMove=nil
- objResize=nil
- end
- function checkName(name)
- if not name:find("^[_%a][_%w]*$") then return false end
- if Objects[name] then return false end
- for i=1,#evEdtList.items do
- if evEdtList.items[i].name==name then return false end
- end
- return true
- end
- function reName(obj)
- for k,v in pairs(Objects) do
- if v==obj then Objects[k]=nil Objects[obj.name]=obj return end
- end
- end
- function getName(name)
- local i=1
- while true do
- local n=name..i
- if checkName(n) then return n end
- i=i+1
- end
- end
- function getProcName(name)
- local i,n=1,name
- while true do
- if checkName(n) then return n end
- n=name..i
- i=i+1
- end
- end
- function draw(self)
- if self.parent then self.X=self.parent.X+self.left-1 self.Y=self.parent.Y+self.top-1
- else self.X=self.left self.Y=self.top end
- gpu.setBackground(self.color)
- gpu.setForeground(self.fontColor)
- local brd=nil
- if self.border==1 then brd={"┌","─","┐","└","│","┘"}
- elseif self.border==2 then brd={"╔","═","╗","╚","║","╝"}
- end
- if brd then
- gpu.set(self.X,self.Y, brd[1]..string.rep(brd[2],self.W-2)..brd[3])
- for i=self.Y+1,self.Y+self.H-2 do
- gpu.set(self.X,i, brd[5]..string.rep(" ",self.W-2)..brd[5])
- end
- gpu.set(self.X,self.Y+self.H-1, brd[4]..string.rep(brd[2],self.W-2)..brd[6])
- else gpu.fill(self.X,self.Y,self.W,self.H," ") end
- self:paint()
- if self.elements then
- for i=1,#self.elements do
- self.elements[i].draw(self.elements[i])
- end
- end
- end
- function paint(self)
- gpu.set(self.X+(self.W-len(self.name))/2,self.Y+(self.H-1)/2, self.name)
- end
- function setProp(obj,name)
- obj.name=name
- obj.draw=draw
- obj.mouseEv=mouseEv
- obj.touch=touch
- obj.drag=drag
- obj.drop=drop
- Objects[name]=obj
- activeForm:setActive()
- end
- local ignore1={"X","Y","name"}
- function compParams(self,...)
- local ignore2={...}
- local ignore={}
- local str=''
- for i=1,#ignore1 do ignore[ignore1[i]]=true end
- for i=1,#ignore2 do
- ignore[ignore2[i]]=true
- -- if i~=1 then str=str..',' end
- local dat=self[ignore2[i]] or self.events[ignore2[i]]
- if type(dat)=="boolean" or type(dat)=="number" then str=str..","..dat end
- if type(dat)=="string" then str=str..',"'..dat..'"' end
- if type(dat)=="table" then
- if dat.proc.text then str=str..","..dat.proc.name end
- end
- end
- str='('..str:sub(2)..')\n'
- for k,v in pairs(self) do
- if not ignore[k] then
- if v~=self.__index[k] then
- if type(v)=="boolean" or type(v)=="number" then str=str..self.name..'.'..k..'='..tostring(v)..'\n' end
- if type(v)=="string" then str=str..self.name..'.'..k..'="'..v..'"\n' end
- end
- end
- end
- return str
- end
- function compForm(self)
- return self.name..'=forms.addForm'..compParams(self)
- end
- function makeForm()
- local obj=forms.addForm()
- activeForm=obj
- setProp(obj, getName("Form"))
- obj.border=1
- obj.events={onCreate={params={},proc=noEvent}}
- obj.compile=compForm
- table.insert(TForms,obj)
- obj:redraw()
- return obj
- end
- function delActiveForm()
- if #TForms>1 then
- for i=1,#TForms do
- if TForms[i]==activeForm then table.remove(TForms,i) break end
- end
- activeForm=TForms[1]
- mainForm()
- else
- Message("Удалить последнюю форму нельзя.\nДля удаления формы "..activeForm.name.."\nдобавьте еще одну форму в проект.")
- end
- end
- delFormDlg=forms.addForm()
- delFormDlg.W=40
- delFormDlg.H=8
- delFormDlg.left=math.floor((WinW-delFormDlg.W)/2)
- delFormDlg.top =math.floor((WinH-delFormDlg.H)/2)
- delFormDlg.border=2
- delFormDlg.color=0xff0000
- delFormLabel=delFormDlg:addLabel(2,3,"")
- delFormLabel.W=delFormDlg.W-2
- delFormLabel.H=3
- delFormLabel.centered=true
- delFormLabel.autoSize=false
- delFormLabel.color=delFormDlg.color
- delFormDlg:addButton(8,6,"Да",delActiveForm)
- delFormDlg:addButton(24,6,"Нет",mainForm)
- function delForm()
- delFormLabel.caption="Вы действительно хотите удалить форму "..activeForm.name.." со всем ее содержимым?"
- delFormDlg:setActive()
- end
- function compButton(self)
- return self.name..'='..self.parent.name..':addButton'..compParams(self,"left","top","caption","onClick")
- end
- function makeButton(parent,x,y)
- local name=getName("Button")
- local obj=parent:addButton(x,y,name)
- setProp(obj,name)
- obj.events={onClick={params={"user"},proc=noEvent}}
- obj.compile=compButton
- return obj
- end
- function compLabel(self)
- return self.name..'='..self.parent.name..':addLabel'..compParams(self,"left","top","caption")
- end
- function makeLabel(parent,x,y)
- local name=getName("Label")
- local obj=parent:addLabel(x,y,name)
- setProp(obj,name)
- obj.events={}
- obj.compile=compLabel
- return obj
- end
- function compEdit(self)
- return self.name..'='..self.parent.name..':addEdit'..compParams(self,"left","top","onEnter")
- end
- function makeEdit(parent,x,y)
- local obj=parent:addEdit(x,y)
- setProp(obj, getName("Edit"))
- obj.events={onEnter={params={"user"},proc=noEvent}}
- obj.compile=compEdit
- return obj
- end
- function compFrame(self)
- return self.name..'='..self.parent.name..':addFrame'..compParams(self,"left","top","border")
- end
- function makeFrame(parent,x,y)
- local obj=parent:addFrame(x,y)
- setProp(obj, getName("Frame"))
- obj.events={}
- obj.compile=compFrame
- return obj
- end
- function compList(self)
- return self.name..'='..self.parent.name..':addList'..compParams(self,"left","top","onChange")
- end
- function makeList(parent,x,y)
- local obj=parent:addList(x,y)
- setProp(obj, getName("List"))
- obj.events={onChange={params={"line","item","user"},proc=noEvent}}
- obj.compile=compList
- return obj
- end
- function compEvent(self)
- return self.name..'='..self.parent.name..':addEvent'..compParams(self,"eventName", "onEvent")
- end
- function makeEvent(parent,x,y)
- local name=getName("Event")
- local obj=parent:addEvent("")
- setProp(obj,name)
- obj.events={onEvent={params={"..."},proc=noEvent}}
- obj.compile=compEvent
- obj.paint=paint
- return obj
- end
- function compTimer(self)
- return self.name..'='..self.parent.name..':addTimer'..compParams(self,"interval", "onTime")
- end
- function makeTimer(parent,x,y)
- local name=getName("Timer")
- local obj=parent:addTimer(5)
- setProp(obj,name)
- obj.events={onTime={params={},proc=noEvent}}
- obj.compile=compTimer
- obj.paint=paint
- return obj
- end
- function delObj(obj)
- if obj.elements then
- for i=1,#obj.elements do
- delObj(obj.elements[i])
- end
- end
- Objects[obj.name]=nil
- end
- function delComp(comp)
- if comp.parent then
- delObj(comp)
- comp:destruct()
- activeForm:setActive()
- else
- delForm()
- end
- end
- function selObj(self,line,item)
- ObjInsp:hide()
- if type(item)=="function" then item(objTouch,xTouch,yTouch)
- else Message("Опция пока не поддерживается") end
- end
- ObjInsp=forms.addForm()
- ObjInsp.W=20
- ObjInsp.H=12
- ObjList=ObjInsp:addList(1,1,selObj)
- ObjList.W=ObjInsp.W
- ObjList.H=ObjInsp.H
- ObjList:addButton(ObjList.W-2,1,"X",mainForm).W=3
- EdtForm=forms.addForm()
- EdtForm.W=33
- EdtForm.H=10
- EdtForm.left=math.floor((WinW-EdtForm.W)/2)
- EdtForm.top =math.floor((WinH-EdtForm.H)/2)
- EdtForm.border=2
- EdtLabel=EdtForm:addLabel(2,3)
- EdtLabel.W=EdtForm.W-2
- EdtLabel.centered=true
- EdtLabel.autoSize=false
- EdtEdit=EdtForm:addEdit(math.floor((EdtForm.W-20)/2)+1,4)
- EdtForm:addButton(5,8,"Ok",
- function()
- local dat=objTouch[PropList.items[PropList.index]]
- if type(dat)=="number" then dat=tonumber(EdtEdit.text)
- else dat=EdtEdit.text end
- if PropList.items[PropList.index]=="name" then
- if not checkName(dat) then showProp() return end
- if objTouch.caption==objTouch.name then objTouch.caption=dat end
- end
- if dat~=nil then objTouch[PropList.items[PropList.index]]=dat end
- if PropList.items[PropList.index]=="name" then reName(objTouch) end
- showProp()
- end)
- EdtForm:addButton(20,8,"Cancel",showProp)
- function editProp(obj,prop)
- if type(obj[prop])=="boolean" then
- obj[prop]=not obj[prop]
- showProp()
- return
- end
- EdtLabel.caption=obj.name.."."..prop
- if string.lower(prop):find("color") then EdtEdit.text=string.format("0x%06x",obj[prop])
- else EdtEdit.text=tostring(obj[prop]) end
- EdtForm:setActive()
- end
- txtEditForm=forms.addForm()
- txtEditForm.W=WinW-24
- txtEdit=txtEditForm:addEdit(1,1)
- txtEdit.W=txtEditForm.W
- txtEdit.H=txtEditForm.H
- function editEvent()
- if eventToEdit.proc.text then
- if PropInsp.left==1 then
- txtEditForm.left=PropInsp.W+1
- else
- txtEditForm.left=1
- end
- txtEdit.text=eventToEdit.proc.text
- txtEditForm:setActive()
- txtEdit:touch(1,1,0)
- showProp()
- end
- end
- evEdtForm=forms.addForm()
- evEdtForm.W=28
- evEdtForm.H=14
- evEdtForm.left=math.floor((WinW-evEdtForm.W)/2)
- evEdtForm.top =math.floor((WinH-evEdtForm.H)/2)
- evEdtForm.border=2
- evEdtList=evEdtForm:addList(2,2,
- function(self,line,item) eventToEdit.proc=item showProp() end)
- evEdtList.W=evEdtForm.W-2
- evEdtList.border=0
- evEdtList.color=0x404040
- evEdtList:insert("Не назначено",noEvent)
- evEdtForm:addButton(2,13,"New",
- function()
- local name=getProcName(objTouch.name..eventToEdit.name)
- local begin="function "..name.."(self"
- for i=1,#eventToEdit.params do
- begin=begin..", "..eventToEdit.params[i]
- end
- eventToEdit.proc={name=name,text={begin..")","","end"}}
- evEdtList:insert(name,eventToEdit.proc)
- editEvent()
- end).W=8
- evEdtForm:addButton(11,13,"Edit",editEvent).W=8
- evEdtForm:addButton(20,13,"Cancel",showProp).W=8
- function selProp(self,line,item)
- if type(item)=="string" then editProp(objTouch,item)
- elseif type(item)=="table" then
- eventToEdit=item
- evEdtList.index=0
- for i=1,#evEdtList.items do
- if eventToEdit.proc==evEdtList.items[i] then evEdtList.index=i break end
- end
- evEdtForm:setActive()
- elseif type(item)=="function" then item(objTouch)
- else Message("Опция пока не поддерживается") end
- end
- PropInsp=forms.addForm()
- PropInsp.W=WinW-txtEditForm.W
- PropInsp.H=WinH
- PropList=PropInsp:addList(1,1,selProp)
- PropList.W=PropInsp.W
- PropList.H=PropInsp.H
- PropList:addButton(PropList.W-2,1,"X",mainForm).W=3
- PropList:addButton(PropList.W-7,1,"<>",
- function()
- if PropInsp.left==1 then PropInsp.left=WinW-PropInsp.W+1
- else PropInsp.left=1 end
- PropInsp:hide()
- activeForm:draw()
- PropInsp:draw()
- end).W=4
- MsgForm=forms.addForm()
- MsgForm.W=40
- MsgForm.H=8
- MsgForm.left=math.floor((WinW-MsgForm.W)/2)
- MsgForm.top =math.floor((WinH-MsgForm.H)/2)
- MsgForm.border=2
- MsgLabel=MsgForm:addLabel(2,3,"Система визуального программирования\nFormsMaker от Zer0Galaxy")
- MsgLabel.W=MsgForm.W-2
- MsgLabel.H=3
- MsgLabel.centered=true
- MsgLabel.autoSize=false
- MsgForm:addButton(15,6,"Ok",mainForm)
- function Message(mess)
- MsgLabel.caption=mess
- MsgForm:setActive()
- end
- local file
- function compileComp(obj)
- for k,v in pairs(obj.events) do
- if v.proc.text and not v.proc.used then
- file:write("\n")
- for i=1,#v.proc.text do
- file:write(v.proc.text[i].."\n")
- end
- v.proc.used=true
- end
- end
- file:write("\n"..obj:compile())
- if obj.elements then
- for i=1,#obj.elements do compileComp(obj.elements[i]) end
- end
- end
- function compile()
- for i=1, #evEdtList.items do
- evEdtList.items[i].used=nil
- end
- file=io.open(projName..".lua",'w')
- if not file then Message("Неверное имя файла\n"..projName..".lua") return end
- file:write('-- Данный код сгенерирован программой FormsMaker\n')
- file:write('-- http://computercraft.ru/topic/1044-sistema-vizualnogo-programmirovaniia-formsmaker/\n')
- file:write('require("component").gpu.setResolution('..WinW..','..WinH..')\n')
- file:write('forms=require("forms")\n')
- file:write('forms.ignoreAll()\n')
- for i=1,#TForms do compileComp(TForms[i]) end
- file:write('\n')
- for i=1,#TForms do
- if TForms[i].events.onCreate.proc~=noEvent then file:write(TForms[i].events.onCreate.proc.name..'('..TForms[i].name..')\n') end
- end
- file:write('forms.run('..activeForm.name..')')
- file:close()
- Message("Код сгенерирован в файл "..projName..".lua")
- end
- function saveComp(obj)
- if obj.parent then file:write("-- "..obj.type().." at "..obj.parent.name.."\n")
- else file:write("-- "..obj.type().."\n") end
- for k,v in pairs(obj) do
- if v~=obj.__index[k] then
- if type(v)=="boolean" or type(v)=="number" then file:write(k.."="..tostring(v).."\n") end
- if type(v)=="string" then file:write(k..'="'..v..'"\n') end
- end
- end
- for name,ev in pairs(obj.events) do
- if ev.proc~=noEvent then file:write(name.."="..ev.proc.name.."\n") end
- end
- if obj.elements then
- for i=1,#obj.elements do saveComp(obj.elements[i]) end
- end
- end
- SavForm=forms.addForm()
- SavForm.W=33
- SavForm.H=10
- SavForm.left=math.floor((WinW-SavForm.W)/2)
- SavForm.top =math.floor((WinH-SavForm.H)/2)
- SavForm.border=2
- SavLabel=SavForm:addLabel(2,3)
- SavLabel.W=SavForm.W-2
- SavLabel.centered=true
- SavLabel.autoSize=false
- SavLabel.caption="Сохранить проект как:"
- SavEdit=SavForm:addEdit(math.floor((SavForm.W-20)/2)-1,4)
- SavForm:addLabel(25,5,projExt)
- SavForm:addButton(5,8,"Ok",
- function()
- file=io.open(SavEdit.text..projExt,'w')
- if not file then Message("Неверное имя файла\n"..SavEdit.text..projExt) return end
- projName=SavEdit.text
- for i=2,#evEdtList.items do
- file:write("-- function "..evEdtList.items[i].name.." "..#evEdtList.items[i].text.." line(s)\n")
- for j=1,#evEdtList.items[i].text do
- file:write(evEdtList.items[i].text[j].."\n")
- end
- end
- for i=1,#TForms do saveComp(TForms[i]) end
- file:write("-- activeForm "..activeForm.name.."\n")
- file:close()
- Message("Проект сохранен в файл "..projName..projExt)
- end)
- SavForm:addButton(20,8,"Cancel",mainForm)
- function saveProj()
- SavEdit.text=projName
- SavForm:setActive()
- end
- function dubObj(obj)
- if obj.parent then
- local objnew
- if obj:type()=="Button" then objnew=makeButton(obj.parent)
- elseif obj:type()=="Label" then objnew=makeLabel(obj.parent)
- elseif obj:type()=="Edit" then objnew=makeEdit(obj.parent)
- elseif obj:type()=="Frame" then objnew=makeFrame(obj.parent)
- elseif obj:type()=="List" then objnew=makeList(obj.parent)
- end
- objnew.parent=obj.parent
- for k,v in pairs(obj) do
- if type(v)~="table" and k~="name" then objnew[k]=v end
- end
- for k,v in pairs(obj.events) do objnew.events[k].proc=v.proc end
- objnew.left=obj.left+1
- objnew.top=objnew.top+1
- mainForm() activeForm:redraw()
- else
- Message("Форма не подлежит дублированию")
- end
- end
- function selForm(self,line,item)
- activeForm=item
- activeForm:setActive()
- end
- function changeForm()
- activeForm:setActive()
- PropList:clear()
- for i=1,#TForms do
- PropList:insert(TForms[i].name,TForms[i])
- end
- PropList:sort()
- PropList.index=0
- PropList.onChange=selForm
- PropInsp:setActive()
- end
- function insertObj(obj)
- PropList:insert(obj.name,obj)
- if obj.elements then
- for i=1,#obj.elements do
- insertObj(obj.elements[i])
- end
- end
- end
- function selObject(self,line,item)
- objTouch=item
- activeForm=item
- while activeForm.parent do activeForm=activeForm.parent end
- showProp()
- end
- function foundObj()
- activeForm:setActive()
- PropList:clear()
- for i=1,#TForms do
- insertObj(TForms[i])
- end
- PropList:sort()
- PropList.index=0
- PropList.onChange=selObject
- PropInsp:setActive()
- end
- function run()
- compile()
- dofile(projName..".lua")
- mainForm()
- end
- ObjList:insert("Свойства ",showProp)
- ObjList:insert("Удалить ",delComp)
- ObjList:insert("Add button",makeButton)
- ObjList:insert("Add label",makeLabel)
- ObjList:insert("Add edit",makeEdit)
- ObjList:insert("Add frame",makeFrame)
- ObjList:insert("Add list",makeList)
- ObjList:insert("Add event",makeEvent)
- ObjList:insert("Add timer",makeTimer)
- ObjList:insert("Дублировать объект",dubObj)
- ObjList:insert("Найти объект",foundObj)
- ObjList:insert("На передний план")
- ObjList:insert("На задний план")
- ObjList:insert("Добавить форму",makeForm)
- ObjList:insert("Удалить форму",delForm)
- ObjList:insert("Сменить форму",changeForm)
- ObjList:insert("Выполнить",run)
- ObjList:insert("Сохранить проект",saveProj)
- ObjList:insert("Генерировать код",compile)
- ObjList:insert("Выход",forms.stop)
- do
- local arg=({...})[1]
- if arg then
- projName=arg:match("(.*)%"..projExt.."$") or arg
- file=io.open(projName..projExt,'r')
- if file then
- local obj, typ, procname, n
- for line in file:lines() do
- typ,procname,n=line:match("^-- (%w+)%s*(%w*)%s*([_%w]*)")
- if typ then
- if typ=="function" then
- local proc={name=procname,text={}}
- for i=1,n do proc.text[i]=file:read() end
- evEdtList:insert(procname,proc)
- elseif typ=="Form" then
- obj=makeForm()
- elseif typ=="Button" then
- obj=makeButton(Objects[n])
- elseif typ=="Label" then
- obj=makeLabel(Objects[n])
- elseif typ=="Edit" then
- obj=makeEdit(Objects[n])
- elseif typ=="Frame" then
- obj=makeFrame(Objects[n])
- elseif typ=="List" then
- obj=makeList(Objects[n])
- elseif typ=="Event" then
- obj=makeEvent(Objects[n])
- elseif typ=="Timer" then
- obj=makeTimer(Objects[n])
- elseif typ=="activeForm" then
- for i=1,#TForms do
- if TForms[i].name==procname then activeForm=TForms[i] break end
- end
- else error("Неизвестный компонент "..typ.." в файле "..projName..projExt.."\n"..line)
- end
- else
- if obj then
- local field,value=line:match("(%w+)=(.+)")
- if not field then error("Ошибка в файле "..projName..projExt.."\n"..line) end
- if value=="true" or value=="false" then obj[field]=(value=="true")
- elseif tonumber(value) then obj[field]=tonumber(value)
- elseif value:find('^".*"$') then obj[field]=value:match('^"(.*)"$')
- else
- for i=2,#evEdtList.items do
- if evEdtList.items[i].name==value then obj.events[field].proc=evEdtList.items[i] break end
- end
- end
- if field=="name" then reName(obj) end
- else error("Ошибка в файле "..projName..projExt.."\n"..line) end
- end
- end
- file:close()
- else makeForm() end
- else
- projName="Project1"
- makeForm()
- end
- end
- forms.run(MsgForm)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement