Simple-Form

This script will generate a skeleton in clipboard for a simple Rebol View Form.

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/simple-form/
    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 replace/all trim 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:// source-code: rejoin [build-simple-form newline "View Window"]
  do source-code
  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 [
      H1 "<%title%>"
      across
      <%fields-template-output%>
      tab
      button "Submit" [
          ;close the window for the program to continue
          unview
      ]
      button "Cancel" [unview]
  ]
Bookmark and Share

Comments

[...] “All Rebol Code Generators”, Click “Simple Form”, Copy and paste the Url (http://askcodegeneration.com/rebol/simple-form/) to the [...]

Leave a comment

Spam Protection by WP-SpamFree