|
Dear all,
I am trying to make a script interface for users to select a file, and then pass the filename to syntax by calling the syntax from the script file. Is this possible? I think I might be missing a major concept here, since it isn't working. Thank you all in advance. Jodene Here is the code I am using to test this idea: - Note: the error is : 'A macro symbol is invalid in this context' - Note deux: Test code indicates that a macro !infile when defined within the syntax is indeed OK '------------------------------------------- ' THIS IS THE SCRIPT '------------------------------------------- Sub Main Dim StrGetfile As String StrGetfile = GetFilePath(, "sav", ,"Please select the file to process", 0) ' Define macro for file name CmdStr = "DEFINE !infile() '" & StrGetfile & "' !ENDDEFINE." & vbCr ' Run syntax file Set objSyntaxDoc = objSpssApp.OpenSyntaxDoc ("testpassname.sps") objSyntaxDoc.Visible=True objSyntaxDoc.Run objSyntaxDoc.Close Set objSyntaxDoc = Nothing End Sub *----------------------------. * This is a simplified syntax file 'testpassname.sps'. * I expect !infile from the script to be passed (erroneously?). * SPSS tells me that on the get file statement !infile is invalid. *----------------------------. get file = !infile. exe. __________________ Jodene Goldenring Fine, Ph.D. MSU Center for Neurodevelopmental Study Departments of Psychology and Psychiatry 321 West Fee Hall East Lansing, MI 48854 (517) 353-5035 (517) 432-2662 fax [hidden email] www.psychology.msu.edu/CNS "Be a nice person and see if it works." Chinese Fortune Cookie, Berkeley, CA, circa 1974 _________________________________________ Legal Notice Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues. The material in this transmission may contain confidential information intended for the addressee. If you are not the addressee, any disclosure or use of this information by you is strictly prohibited. If you have received this transmission in error, please delete it and destroy all copies ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
At 05:38 PM 5/7/2008, Jodene Fine wrote:
>I am trying to make a script interface for users to select a file, >and then pass the filename to syntax by calling the syntax from the >script file. Is this possible? I think I might be missing a major >concept here, since it isn't working. Thank you all in advance. It isn't quite fair of me to respond; - you need VB'ers, and I'm not one. Nevertheless, >- Note: the error is : 'A macro symbol is invalid in this context' >- Note deux: Test code indicates that a macro !infile when >defined within the syntax is indeed OK OK. That means the 'DEFINE' is not getting executed, from your VB logic. >'------------------------------------------- >' THIS IS THE SCRIPT >'------------------------------------------- > >Sub Main [...] >' Define macro for file name > CmdStr = "DEFINE !infile() '" & StrGetfile & "' !ENDDEFINE." & vbCr Ignorant question: Where does SPSS 'see' this command? I don't see it referred to in the code below. Anyway, coincidentally I'm on a VB-to-SPSS project myself, now. (No, I'm not the VB person.) The way they do it is, write out ("WriteLine") with the varying information. In your case, that would be the DEFINE; or, if you only want to GET the file, it could be the GET FILE statement. Following the varying information, the little file just written includes an INCLUDE (or INSERT) for the main SPSS code -- in your case "testpassname.sps" -- and then invokes the small file, pretty much as you're doing it. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Jodene Fine
The problem is that the macro definition, which belongs to the domain of syntax, not SaxBasic, is never passed to SPSS to execute. You could execute it by using the Runsyntax function, or you could just execute the GET statement using that same function and forget about the macro altogether.
HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jodene Fine Sent: Wednesday, May 07, 2008 3:38 PM To: [hidden email] Subject: [SPSSX-L] pass a file name from script to syntax Dear all, I am trying to make a script interface for users to select a file, and then pass the filename to syntax by calling the syntax from the script file. Is this possible? I think I might be missing a major concept here, since it isn't working. Thank you all in advance. Jodene Here is the code I am using to test this idea: - Note: the error is : 'A macro symbol is invalid in this context' - Note deux: Test code indicates that a macro !infile when defined within the syntax is indeed OK '------------------------------------------- ' THIS IS THE SCRIPT '------------------------------------------- Sub Main Dim StrGetfile As String StrGetfile = GetFilePath(, "sav", ,"Please select the file to process", 0) ' Define macro for file name CmdStr = "DEFINE !infile() '" & StrGetfile & "' !ENDDEFINE." & vbCr ' Run syntax file Set objSyntaxDoc = objSpssApp.OpenSyntaxDoc ("testpassname.sps") objSyntaxDoc.Visible=True objSyntaxDoc.Run objSyntaxDoc.Close Set objSyntaxDoc = Nothing End Sub *----------------------------. * This is a simplified syntax file 'testpassname.sps'. * I expect !infile from the script to be passed (erroneously?). * SPSS tells me that on the get file statement !infile is invalid. *----------------------------. get file = !infile. exe. __________________ Jodene Goldenring Fine, Ph.D. MSU Center for Neurodevelopmental Study Departments of Psychology and Psychiatry 321 West Fee Hall East Lansing, MI 48854 (517) 353-5035 (517) 432-2662 fax [hidden email] www.psychology.msu.edu/CNS "Be a nice person and see if it works." Chinese Fortune Cookie, Berkeley, CA, circa 1974 _________________________________________ Legal Notice Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues. The material in this transmission may contain confidential information intended for the addressee. If you are not the addressee, any disclosure or use of this information by you is strictly prohibited. If you have received this transmission in error, please delete it and destroy all copies ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
