[GEN] Template Handler

new topic     » topic index » view thread      » older message » newer message

I've sent Robert a program called "Template Handler", which intends to make
it easy to store & retrieve snippets or "templates" of code, for both
Euphoria and Win32Lib (could be extended to EDS etc, too).  Anyone who's
interested, please check it out & let me know what you think of it.

It seems to work well, except I don't have many TEMPLATES to include
with it!

So I'm hoping maybe some of you will contribute code snippets for
it.  You could either *use* the Template Handler to create template
contributions (good exercise for it), or just send code snippets here so
others could comment upon or improve them (could make for better snippets).

With "comment or improve" in mind, here's a sample template I might include
with it later (if you want to use it with the Handler, just save it to a
file and use an extent ".etp", for "Euphoria TemPlate"); it has two
templates in it, and the Handler does NOT show all the "!!" comments, just
the name, description, and code.

Dan Moyer

following could be put into a file, eg "Seq1.etp", to use with the handler:

!!  THIS IS A EUPHORIA CODE TEMPLATE FILE
!!
!!    EUPHORIA Sequence Manipulation TEMPLATES
!!
!! COMMENTS START WITH !! AT THE *FIRST* SPACE IN LINE
!! <<CATEGORY defines the CATEGORY of TEMPLATES in this file
!! <<NAME defines the NAME of a TEMPLATE
!! <<DESC defines the DESCRIPTION of a TEMPLATE
!! everything else is TEMPLATE CODE
!!
!! in order to allow ACTUAL blank lines INSIDE templates code,
!! blank lines in TEMPLATE FILE "comments" MUST be preceded by !!
!!
<<CATEGORY Sequence Manipulation
!!
<<NAME & Operator
<<DESC How to use "&" to append
--  ADDING THINGS INTO SEQUENCES:  JUST USE "&"

-- for simplicity and to avoid confusion, forget about whether to use
-- "append" or the concatenation operator "&" to add things to a sequence;
--  just use "&" to do both:

-- if you want to add the ELEMENTS of a sequence
-- to the end of the ELEMENTS of another sequence,
--  just use "&" normally:

sequence something
something={"a string"}
something[1] &= " of letters"       -- appends  " of letters" to end of
something

--so, something =  {"a string of letters"}

-- but if you want to add another SEQUENCE to the end of a sequence,
-- use "&" and put the sequence to add INSIDE curly braces:

something &= {"another string"}  -- appends a new dimmed subscript (2)

.. something will now look like this..
   {"a string of letters","another string"}

--Chris Bensler

<<NAME ArrayMakeFill
<<DESC Make an array to N dimensions & fill it
-- Make & Fill an Array
-- an easy way to create and fill an array of various dimensions:

-- the syntax of the function is:
-- <sequence> = array( <filler>, {<dim1>, <dim2>,...<dimN>} )
-- eg., s = array( 0, {8,10}) gives an array of 8 by 10, filled with 0's
--    Note:  will work for more than 2 dimensions

-- created by Lucius L. Hilley III

sequence s  -- to make as an array

function array(object filler, sequence dimensions)
  object x

  x = filler
  for A = 1 to length(dimensions) do
    x = repeat(x, dimensions[A])
  end for
  return x
end function

s = array(0,{8,10})  -- make an 8 by 10 array, filled with 0's

print(1,s)  -- show the array

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu