Add item from clipboard

A post on the forums got me thinking that there might be a way to simply add a whole class, module etc to a project just from code copied from the forums.

So I sat and whipped up a little IDE script that takes a clipboard and will convert it to a class or module. Now there are some tricks. One is that because certain aspects of the Xojo text format can be a bit ambiguous there’s a little more markup involved. Nothing really onerous though.

The following is a simple module

Module Module1
  Sub Untitled()
  End Sub

  Property mUntitled1 As Integer

  ComputedProperty untitled1 as integer
      Return mUntitled1
    End Get
     mUntitled1 = value
    End Set
  End ComputedProperty
End Module

When copied to your clipboard and the script is run you get a module on your desktop on macOS. Sorry about this but I haven’t tried this on Windows or Linux yet. And I can’t insert it into the project directly with IDE scripting as it work today 🙁
The following gives a class on your desktop

class TOperInfo
  enum TOperType 
  end enum

  property Priority as Uint8
  property NbOper as TOperType

  Sub Constructor( priority as Uint8, nbOper as TOperType)
    self.priority = priority
    self.NbOper = nbOper
  end sub
end class

Enjoy !