hey together,

i'm working on some textures for my ui, and have this bunch of code for a dynamic background.
how can i write a template out of this (Inventory, Bank, GBank, etc.) so that it is more memory friendly, or is it not possible?

thx for helping me
vyntrox

Code:
-----------------------------------------------------------------------------------------------
-- ARKINVENTORY BACKGROUND --
-----------------------------------------------------------------------------------------------
 if (IsAddOnLoaded("ArkInventory")) then
  do
--------------------------------------------------- 
-- INVENTORY --------------------------------------
---------------------------------------------------
local MyInventoryBG = zInterfaceTextureTemplate(nil, ARKINV_Frame1, ARKINV_Frame1:GetWidth(), ARKINV_Frame1:GetHeight())
MyInventoryBG:SetPoint("TOPLEFT",-5,-10)
MyInventoryBG:SetPoint("BOTTOMRIGHT",5,5)
MyInventoryBG:SetFrameStrata("MEDIUM")
MyInventoryBG:SetFrameLevel(0)  
local t = MyInventoryBG:CreateTexture()
    t:SetParent(MyInventoryBG)
    t:SetAllPoints(MyInventoryBG)
    t:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_Background.tga")

-- || TOPLEFT || --    
local My_Inventory_TL = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_TL:SetPoint("TOPLEFT", MyInventoryBG, -9, 9)
      My_Inventory_TL:SetFrameStrata("MEDIUM")
      My_Inventory_TL:SetFrameLevel(1)
      My_Inventory_TL:SetHeight(64)
      My_Inventory_TL:SetWidth(64)

    local My_Inventory_TL_Tex = My_Inventory_TL:CreateTexture(nil,"BACKGROUND")
          My_Inventory_TL_Tex:SetParent(My_Inventory_TL)
          My_Inventory_TL_Tex:SetAllPoints(My_Inventory_TL)
          My_Inventory_TL_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_TL.tga")  
-- || TOPRIGHT || -- 
local My_Inventory_TR = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_TR:SetPoint("TOPRIGHT", MyInventoryBG, 9, 9)
      My_Inventory_TR:SetFrameStrata("MEDIUM")
      My_Inventory_TR:SetFrameLevel(1)
      My_Inventory_TR:SetHeight(64)
      My_Inventory_TR:SetWidth(64)

    local My_Inventory_TR_Tex = My_Inventory_TR:CreateTexture(nil,"BACKGROUND")
          My_Inventory_TR_Tex:SetParent(My_Inventory_TR)
          My_Inventory_TR_Tex:SetAllPoints(My_Inventory_TR)
          My_Inventory_TR_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_TR.tga") 
-- || BOTTOMRIGHT || --
local My_Inventory_BR = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_BR:SetPoint("BOTTOMRIGHT", MyInventoryBG, 9, -9)
      My_Inventory_BR:SetFrameStrata("MEDIUM")
      My_Inventory_BR:SetFrameLevel(1)
      My_Inventory_BR:SetHeight(64)
      My_Inventory_BR:SetWidth(64)

    local My_Inventory_BR_Tex = My_Inventory_BR:CreateTexture(nil,"BACKGROUND")
          My_Inventory_BR_Tex:SetParent(My_Inventory_BR)
          My_Inventory_BR_Tex:SetAllPoints(My_Inventory_BR)
          My_Inventory_BR_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_BR.tga") 
-- || BOTTOMLEFT || --
local My_Inventory_BL = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_BL:SetPoint("BOTTOMLEFT", MyInventoryBG, -9, -9)
      My_Inventory_BL:SetFrameStrata("MEDIUM")
      My_Inventory_BL:SetFrameLevel(1)
      My_Inventory_BL:SetHeight(64)
      My_Inventory_BL:SetWidth(64)

    local My_Inventory_BL_Tex = My_Inventory_BL:CreateTexture(nil,"BACKGROUND")
          My_Inventory_BL_Tex:SetParent(My_Inventory_BL)
          My_Inventory_BL_Tex:SetAllPoints(My_Inventory_BL)
          My_Inventory_BL_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_BL.tga")
-- || TOP || --
local My_Inventory_T = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_T:SetPoint("RIGHT", My_Inventory_TR, "LEFT", 0 ,0)
      My_Inventory_T:SetPoint("LEFT",  My_Inventory_TL, "RIGHT", 0 ,0)
      My_Inventory_T:SetFrameStrata("MEDIUM")
      My_Inventory_T:SetFrameLevel(1)
      My_Inventory_T:SetHeight(64)
      
    local My_Inventory_T_Tex = My_Inventory_T:CreateTexture(nil,"BACKGROUND")
          My_Inventory_T_Tex:SetParent(My_Inventory_T)
          My_Inventory_T_Tex:SetAllPoints(My_Inventory_T)
          My_Inventory_T_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_Top.tga")
-- || BOTTOM || --
local My_Inventory_B = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_B:SetPoint("RIGHT", My_Inventory_BR, "LEFT", 0, 0)
      My_Inventory_B:SetPoint("LEFT", My_Inventory_BL, "RIGHT", 0, 0)
      My_Inventory_B:SetFrameStrata("MEDIUM")
      My_Inventory_B:SetFrameLevel(1)
      My_Inventory_B:SetHeight(64)

    local My_Inventory_B_Tex = My_Inventory_B:CreateTexture(nil,"BACKGROUND")
          My_Inventory_B_Tex:SetParent(My_Inventory_B)
          My_Inventory_B_Tex:SetAllPoints(My_Inventory_B)
          My_Inventory_B_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_Bottom.tga") 
-- || LEFT || --
local My_Inventory_L = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_L:SetWidth(64)
      My_Inventory_L:SetPoint("TOP", My_Inventory_TL, "BOTTOM", 0 ,0)
      My_Inventory_L:SetPoint("BOTTOM", My_Inventory_BL, "TOP", 0 ,0)
      My_Inventory_L:SetFrameStrata("MEDIUM")
      My_Inventory_L:SetFrameLevel(1)

    local My_Inventory_L_Tex = My_Inventory_L:CreateTexture(nil,"BACKGROUND")
          My_Inventory_L_Tex:SetParent(My_Inventory_L)
          My_Inventory_L_Tex:SetAllPoints(My_Inventory_L)
          My_Inventory_L_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_Left.tga")           
-- || RIGHT || --
local My_Inventory_R = CreateFrame("FRAME", nil, MyInventoryBG)
      My_Inventory_R:SetWidth(64)
      My_Inventory_R:SetPoint("TOP", My_Inventory_TR, "BOTTOM", 0 ,0)
      My_Inventory_R:SetPoint("BOTTOM", My_Inventory_BR, "TOP", 0 ,0)
      My_Inventory_R:SetFrameStrata("MEDIUM")
      My_Inventory_R:SetFrameLevel(1)
      
    local My_Inventory_R_Tex = My_Inventory_R:CreateTexture(nil,"BACKGROUND")
          My_Inventory_R_Tex:SetParent(My_Inventory_R)
          My_Inventory_R_Tex:SetAllPoints(My_Inventory_R)
          My_Inventory_R_Tex:SetTexture("Interface\\Addons\\zMedia\\textures\\DynBorder\\Dyn_Border_Right.tga")
          
end