Type of script |
Function |
Script |
Button script |
Save text to a file in a designated location
|
-- Note: the card field name here must be
the same name as the -- field in which the student will type
the dictation.
on mouseUp
-- prompt for the file name
ask file "Enter a name for the file" with ""
-- the file name is put in the variable "it";
-- if you clicked Cancel, "it" will be empty
if it is not empty then
-- open the file
put it into fileName
open file fileName
put cd fld "studentfile" into stuff
open file output
write stuff & return to file fileName
close file output
-- close the file
close file fileName
delete file "stuff"
delete file "output"
end if
end mouseUp |
Button script |
collect several fields of text in one file |
-- Note: the card field name here must be
the same name as the
-- field in which the student will type the dictation.
on mouseUp
-- prompt for the file name
ask file "Enter a name for the file" with ""
-- the file name is put in the variable "it";
-- if you clicked Cancel, "it" will be empty
if it is not empty then
-- open the file
put it into fileName
open file fileName
put cd fld "answer1" & return & return & cd
fld "answer2" & return & return & cd
fld "answer3" into info
open file output
write info & return to file fileName
close file output
-- close the file
close file fileName
delete file "output"
delete file "info"
end if
end mouseUp |
continue button |
assign a global variable to the student's username;
trap in case the student doesn't type anything
go to the next card |
on mouseUp
global gusername
put field "username" into gusername
if gusername
is "username" or field "username" is
empty
then answer "Please type your Pitt username." with "OK"
go next card
end mouseup
|
submit button |
submit text file via ftp
put contents of text field into a file
display the "wait" field
uploads the textfile to the server
(Note: put in your own username, password, and server
address)
check to see if the file is uploaded to the server
then hide "wait" field
show "finished" field |
on mouseup
global gusername
put field "studentfile" into
URL ("file:" & "results.txt")
put gusername & ".txt" into filename
show field "wait"
set the sockettimeoutinterval to 20000
libURLftpUploadFile results.txt, "ftp://usenamer:password@server.domainname.edu/"&"/" & filename, "loadDone"
end mouseUp
on loadDone pUrl, pStatus
if pstatus is "uploaded" then
hide field "wait"show field "finished"
end if
end loadDone |
button script |
when user clicks on a button, record that choice
in a text field |
on mouseUp
put "a" into field "datafile"
end mouseUp |
button script |
invisible button with the name of an object;
when user clicks, that name is recorded in a text field |
on mouseUp
put the short name of me & return after field "datafile"
end mouseUp |
button script |
track the time and date of each button clicked
assign the name
of the button to "myvar"
assign the current
time to "timevar"
assign the current
date to "datevar"
put the above information in a text field |
on mouseUp
put the short name of me into myname
put the time into timevar
put the date into datevar
put myname && timevar && datevar & return after field "datafile"
end mouseUp |
card script |
record start date and start time |
on opencard
global gstarttime, gstartdate
put the time into gstarttime
put the date into gstartdate
end opencard |
button card |
put start date into text field
(assumes that the above card script was used when the card
was opened) |
on mouseUp
global gstartdate
put return & gstartdate after field "datafile"
end
mouseUp |
button card |
put start time into text field
|
on mouseUp
global gstarttime
put return & gstarttime after field "datafile"
end
mouseUp |
button script |
record end time |
on mouseup
global gendtime
put the time into gendtime
put return & gendtime after field "datafile"
end mouseup |