load_response set datafile discussions set page_title "NeoWebScript Demo Discussion Board" set background_color "#ffffff" set homepage "http://hosting.dynamis.net/neowebscript/userinfo/library.nhtml" set emit_scriptname discuss1.nhtml set create_scriptname discuss2.nhtml set num_to_show 50 proc display_responses {the_id } { global datafile page_title background_color webenv response global homepage emit_scriptname create_scriptname num_to_show set idlist [dbkeys $datafile *] set num_ids [llength $idlist] set sorted_ids [lsort -integer $idlist] if {$num_to_show > $num_ids} {set num_to_show $num_ids} set first_id [expr $num_ids - $num_to_show] if {$first_id < 0} {set first_id 0} set work_ids [lrange $sorted_ids $first_id end] foreach id [lsort -integer -decreasing $work_ids] { dbfetch $datafile $id dbarray if {$dbarray(response_id) == $the_id} { html "

" html "

" } } } proc emit_subjectlist {display} { global datafile page_title background_color webenv response global homepage emit_scriptname create_scriptname num_to_show html "" html "" html "$page_title" html "" html "" html "

$page_title

" html "
Post a message

" html "
Back to the NeoWebScript Demo Page

" html "Currently, the discussion board will show up to the 50 most recent" html " messages. " set idlist [dbkeys $datafile *] if {[catch {set idlist [dbkeys $datafile *]} firsttime] != 0} { set num_ids 0 set first_id 0 } else { set num_ids [llength $idlist] set sorted_ids [lsort -integer $idlist] if {$num_to_show > $num_ids} {set num_to_show $num_ids} set first_id [expr $num_ids - $num_to_show] if {$first_id < 0} {set first_id 0} set work_ids [lrange $sorted_ids $first_id end] html "Here are the last $num_to_show, of $num_ids" html " currently active messages.

" html "


" foreach id [lsort -integer -decreasing $work_ids] { dbfetch $datafile $id dbarray if {$dbarray(response_id) == 0} { html "

" html "

" } } } html "" html "" } proc emit_message {} { global datafile page_title background_color webenv response global homepage emit_scriptname create_scriptname set id $response(mode) html "" html "" html "$page_title" html "" html "" set num_to_show 50 set idlist [dbkeys $datafile *] set num_ids [llength $idlist] set sorted_ids [lsort -integer $idlist] if {$num_to_show > $num_ids} {set num_to_show $num_ids} set first_id [expr $num_ids - $num_to_show] if {$first_id < 0} {set first_id 0} set work_ids [lrange $sorted_ids $first_id end] dbfetch $datafile $id dbarray html "

$page_title

" html "
Post a Response

" html "
Back to the NeoWebScript Demo Page

" html "
" html "

" html "" html "" html "" html "" html "" html "" html "
$id) $dbarray(name)
" html "" html "$dbarray(email)
$dbarray(subject)
Entry made at " html "[clock format $dbarray(time) -format $webenv(NEO_TIME_FORMAT)]" html " using $dbarray(user_agent) " html "from $dbarray(remote_host)
" html "" html "" html "

$dbarray(comments)
" html "


" html "" } if {![array exists response]} { emit_subjectlist 10 } elseif {[string compare $response(mode) emit_subjectlist] == 0} { emit_subjectlist 10 } else { emit_message }