home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2000 January / PCW0001.ISO / software / sw / outils / rebol031.exe / feedback.r next >
Encoding:
Rebol source code  |  1999-10-26  |  5.5 KB  |  206 lines

  1. REBOL [
  2.    Title:   "Feedback Submitter"
  3.    Date:    13-Jan-1999
  4.    Author:  "Bohdan Lechnowsky"
  5.    File:    %feedback.r
  6.    Email:   bo@rebol.com
  7.    Purpose: {
  8.       To send feedback from REBOL users to REBOL Technologies.
  9.    }
  10. ]
  11.  
  12. menu: [
  13.    ["Change Feedback Category" [feedback-type: feedback]]
  14.    ["Change Name" [change-name true]]
  15.    ["Change Email Address" [change-email true]]
  16.    ["Change Date/Time" [change-date true]]
  17.    ["Change Description" [desc: change-desc]]
  18.    ["Change Subject Line" [subj: change-subject]]
  19.    ["Send It!" [send-it]]
  20.    ["Quit" [halt]]
  21. ]
  22.  
  23. feedback-func: func [] [
  24.    print newline
  25.    while [not integer? (feedback-choice: load ask trim
  26.       {^/FEEDBACK CATEGORY
  27.       ====================
  28.       1 > Bug report
  29.       2 > General Question
  30.       3 > Enhancement idea
  31.       4 > Comment/Praise
  32.       5 > Documentation note
  33.       6 > Other
  34.       7 > Quit
  35.  
  36.       -> })] [print "^/Please enter the number of your selection!^/"]
  37.    if feedback-choice > 6 [halt]
  38.    if feedback-choice < 1 [feedback-choice: 1]
  39.    return pick [ "[BUG]" "[SUPPORT]" "[ENHANCEMENT]" "[COMMENT]" "[DOC]" "[OTHER]" ] feedback-choice
  40. ]
  41.  
  42. change-name: func [change] [
  43.    either any [(none? name: system/user/name) (change)] [
  44.       name: ask "^/Please enter your name: "
  45.    ][
  46.       print ["^/Your name:" name]
  47.    ]
  48. ]
  49.  
  50. change-email: func [change] [
  51.    either any [(none? email: system/user/email) (change)] [
  52.       system/user/email: email: ask "^/Enter your email address: "
  53.    ][
  54.       print ["^/Your email address: " email]
  55.    ]
  56. ]
  57.  
  58. change-date: func [change] [
  59.    prin {^/Date/Time }
  60.    either change [
  61.       until [
  62.          all [(not error? try [time: load ask "DD/MM/YY/hh:mm>"]) (date? time)]
  63.       ]
  64.    ][
  65.       print time: now
  66.    ]
  67. ]
  68.  
  69. change-desc: func [] [
  70.    print newline
  71.    print trim {^/--------------------------------------------------
  72.                     Please enter your feedback.
  73.  
  74.                     *** THE FIRST LINE WILL BE USED AS THE  ***
  75.                     ***       FEEDBACK'S SUBJECT LINE       ***
  76.  
  77.                     Enter .. (two dots) on a new line
  78.                     to delete the previous line and a . (dot)
  79.                     on its own line to finish the description.
  80.                     --------------------------------------------------}
  81.  
  82.    reprint: func [] [
  83.       output: make string! 1
  84.       print "^/-----"
  85.       foreach line lines [append output reduce [line newline]]
  86.    ]
  87.  
  88.    lines: make block! 1
  89.    until [
  90.       append lines input
  91.       if (last lines) = ".." [
  92.          clear back back tail lines
  93.          reprint
  94.          prin output
  95.       ]
  96.       if positive? length? lines [
  97.          (last lines) = "."
  98.       ]
  99.    ]
  100.  
  101.    clear back tail lines
  102.  
  103.    either positive? length? lines [
  104.       subj: first lines
  105.    ][
  106.       subj: "(No Subject)"
  107.    ]
  108.    insert head lines {^/}
  109.  
  110.    reprint
  111.    return output
  112. ]
  113.  
  114. change-subject: func [] [
  115.    ask "^/Please enter the subject: "
  116. ]
  117.  
  118.  
  119. send-it: func [/local header] [
  120.    header: make system/standard/email [
  121.       from: :email
  122.       subject: append copy feedback-type to-string reduce [" " copy/part subj 40]
  123.       organization: "REBOL 2.0 User"
  124.    ]
  125.  
  126.    if (none? system/schemes/smtp/host) and (none? defserv: system/schemes/default/host) [
  127.       either found? defserv [
  128.          print "^/*** Setting your SMTP server to your default server address ***"
  129.          system/schemes/smtp/host: defserv
  130.       ][
  131.          until [
  132.             system/schemes/smtp/host: ask "Please enter your SMTP server (i.e. mail.domain.com): "
  133.             correct: ask "Is this correct (yes/no)? "
  134.             any [(correct = "yes") (correct = "y")]
  135.          ]
  136.       ]
  137.    ]
  138.    send/header feedback@rebol.com mold reduce [
  139.       name
  140.       email
  141.       system/version
  142.       time
  143.       desc
  144.    ] header
  145.  
  146.    print "^/Message sent!"
  147.  
  148.    print newline
  149. ]
  150.  
  151. display: func [] [
  152.    print newline
  153.    prin line: {************************************************************}
  154.    print reduce [{^/   CATEGORY: } feedback-type
  155.                  {^/       NAME: } name
  156.                  {^/      EMAIL: } email
  157.                  {^/    VERSION: } system/version
  158.                  {^/       DATE: } time
  159.                  {^/    SUBJECT: } subj
  160.                  {^/DESCRIPTION:^/} desc]
  161.    print line
  162. ]
  163.  
  164. feedback-type: feedback-func
  165. change-name false
  166. change-email false
  167. print ["^/Using REBOL v" system/version]
  168. change-date false
  169. desc: change-desc
  170.  
  171. print {^/You now have the option to send this message or edit the message fields.}
  172. either (ask {^/(S)end this message or (E)dit it (s/e)? }) = "s" [
  173.    send-it
  174. ][
  175.    until [
  176.       display
  177.  
  178.       until [
  179.          print {^/^/Enter the number of your selection:}
  180.          index: 0
  181.          prin newline
  182.          foreach item menu [
  183.             index: index + 1
  184.             print [index ">" first item]
  185.          ]
  186.          prin "^/-> "
  187.          integer? choice: load input
  188.       ]
  189.       either (choice > index) or (choice < 1) [
  190.          print "^/*** INVALID OPTION ***"
  191.       ][
  192.          reduce second pick menu choice
  193.       ]
  194.  
  195.       (choice >= (index - 1))
  196.    ]
  197. ]
  198.  
  199. print newline
  200. print trim {^/--------------------------------------------------
  201.                  Thank you for submitting this feedback.
  202.                  It will help us to provide you with an even higher
  203.                  quality product in the future.
  204.                  --------------------------------------------------
  205.                  ^/^/}
  206.