1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
' This script asks for the user name, then defines the macro !usrname which gives the user name
' It then prints the user name in the Log file.
' Usage:
' After running this script, the username may be printed anywhere in 
' the Output using, for instance, the following syntax
' DO IF $CASENUM=1.
' Print /'*** Syntax ran by ' !usrname.
' End If.
' EXECUTE.

' It is possible to have SPSS automatically run the script each time SPSS starts
' see "Automatically run a script or syntax when SPSS starts.SBS" in
' http://pages.infinit.net/rlevesqu/SampleScripts.htm#Utils
' Raynald Levesque 2002/01/27

Option Explicit

Sub Main
Dim username As String
Dim CmdStr As String
    username = InputBox$("Enter your name:","Input Box")
'   Debug.Print username
	Cmdstr = "DEFINE !usrname()" & "'" & username & "'" & "!ENDDEFINE." & vbCr & "Execute." & vbCr
	Cmdstr = Cmdstr & "DO IF $CASENUM=1." & vbCr
	Cmdstr = Cmdstr & "STRING #tmpstr(A20)." & vbCr
	Cmdstr = Cmdstr & "COMPUTE #tmpstr=!usrname." & vbCr
	Cmdstr = Cmdstr & "PRINT /'*** Syntax ran by ' #tmpstr." & vbCr
	Cmdstr = Cmdstr & "END IF." & vbCr
	Cmdstr = Cmdstr & "EXECUTE." & vbCr
	objSpssApp.ExecuteCommands Cmdstr,True

'	objSpssApp.GetDesignatedOutputDoc.PrintOptions.FooterText = "Ran by: " & username 
	
End Sub