Simple-Form


This script will generate a skeleton in clipboard for a simple Rebol View Form like this one below:

Rebol View Form
as explained in this Rebol Tutorial.

Rebol [
    Title: "header template"
    Author-Url: http://askcodegeneration.com/rebol
    Script-Url:  http://askcodegeneration.com/rebol/rebol-view-skeleton
    Date:  06-Sep-2009
    Purpose: "Create a Rebol View Skeleton"
]

if/else value? code-block [
    template: code-block/2
][
    print "copy template into clipboard ..."
    input
    template: read clipboard://
]

build-simple-form: func[][
  fields-layout: copy []
  count: 0
  Foreach field fields-block [
    count: count + 1
    field-name: fields-block/:count
    Append fields-layout 'label 
    Append fields-layout field-name
    Append fields-layout 'tab 
    Append fields-layout to-set-word field-name
    Append fields-layout  'field
    Append fields-layout Rejoin ["Enter" " " fields-block/:count]
    Append fields-layout 'Return  
  ]
  fields-template-output: copy head remove back tail (remove mold fields-layout)
  build-markup template
]

if/else not value? 'simple-form.fields-block [
  title: ask "title: "
  fields: ask "fields (ex. First Name, Last Name): "
  fields-block: parse/all fields ","
  write clipboard:// rejoin [build-simple-form newline "View Window"]
  print "copied to clipboard ..."
  input
][
  title: simple-form.title
  fields-block: simple-form.fields-block
  build-simple-form
]


Template1 (in the future there may be several templates available):
  window: layout [
      text "<%title%>"
      across
      <%fields-template-output%>
      tab
      button "Submit" [
          ;close the window for the program to continue
          unview
      ]
      button "Cancel" [unview]
  ]

WordPress plugins that are to be activated from the plugins folder should go here. You must activate the plugins page from Site Admin->Options first however.