Is it possible to design a command (for example, in Python) which
will read all syntax surrounding the current cursor position,
starting from DEFINE and ending at !ENDDEFINE?
What I mean is this. Consider I have a macro definition. DEFINE....... bla bla bla bla !ENDDEFINE. To read it into SPSS memory I have to mouse-select everything from DEFINE to !ENDDEFINE. But the code may be very lengthy, so selecting takes time. Instead that, I'd like to be able to put cursor anywhere within the macro body and run some command/button "Read Current Macro Definition" which will automatically select everything within the surrounding DEFINE - !ENDDEFINE range and run it for me. Any ideas? That might be even a good feature to introduce in Statistics itself. ===================== 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 |
Yes and no. For all conventional commands you can hit the F2 button to highlight all of that command. However, for DEFINE/!ENDDEFINE (and I suspect GPL/GGRAPH/MATRIX ect. also), it may not behave entirely as you expect or desire it to.
In Python, it would be possible, but I don't think you can read where the current cursor is - that would be the only limiting factor. Otherwise with python you could read the (saved version of the) file to find the word "DEFINE" and "!ENDDEFINE" in close proximity of the current cursor position. If it is such a large macro, why not just have a dedicate syntax file for the macro itself and then use "Run All" toolbar icon (or run INSERT)? I'd opt for this than write long winded Python code to achive something like this (nice tutorial exercise nonetheless though). To be able to read the cursor position would be a great feature. In data view you can right click variable and run descriptive on the fly, I was hoping to build custom procedures where I go execute in a similar vain, right click run, however there is no way to read which is the selected variable or cursor position to be able to run the procedure on the selected target variable. |
In reply to this post by Kirill Orlov
F2 will select the entire command containing
the cursor, but since a macro definition may contain complete commands,
in that case F2 selection wouldn't work for the entire macro.
Jignesh is right that Python scripting does not have access to the cursor location. It could be used to, say, execute all the DEFINEs in the file if that would help or, perhaps execute the first or last one. With a small custom dialog where you entered a line number, it could find the macro definition that contains that line and execute it. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Kirill Orlov <[hidden email]> To: [hidden email] Date: 05/22/2015 04:07 AM Subject: [SPSSX-L] Run Current Macro Definition Sent by: "SPSSX(r) Discussion" <[hidden email]> Is it possible to design a command (for example, in Python) which will read all syntax surrounding the current cursor position, starting from DEFINE and ending at !ENDDEFINE? What I mean is this. Consider I have a macro definition. DEFINE....... bla bla bla bla !ENDDEFINE. To read it into SPSS memory I have to mouse-select everything from DEFINE to !ENDDEFINE. But the code may be very lengthy, so selecting takes time. Instead that, I'd like to be able to put cursor anywhere within the macro body and run some command/button "Read Current Macro Definition" which will automatically select everything within the surrounding DEFINE - !ENDDEFINE range and run it for me. Any ideas? That might be even a good feature to introduce in Statistics itself. ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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 |
Thank you Jon and Jignesh.
Sad. Jon, if it is not possible with python script then it might be possible, perhaps, within java on which Statistics interface is written. Maybe it is worth to include the option as a new feature in future release. What do you think? 22.05.2015 15:53, Jon K Peck пишет:
F2 will select the entire command containing the cursor, but since a macro definition may contain complete commands, in that case F2 selection wouldn't work for the entire macro. ===================== 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 |
It would be useful to be able to select
and run all sorts of blocks this way, whether macros, Python programs,
or R programs. Please submit this as an enhancement request on the
Request for Enhancement website at
https://www.ibm.com/developerworks/rfe/ It carries more weight if it comes from customers. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Kirill Orlov <[hidden email]> To: [hidden email] Date: 05/22/2015 07:10 AM Subject: Re: [SPSSX-L] Run Current Macro Definition Sent by: "SPSSX(r) Discussion" <[hidden email]> Thank you Jon and Jignesh. Sad. Jon, if it is not possible with python script then it might be possible, perhaps, within java on which Statistics interface is written. Maybe it is worth to include the option as a new feature in future release. What do you think? 22.05.2015 15:53, Jon K Peck пишет: F2 will select the entire command containing the cursor, but since a macro definition may contain complete commands, in that case F2 selection wouldn't work for the entire macro. Jignesh is right that Python scripting does not have access to the cursor location. It could be used to, say, execute all the DEFINEs in the file if that would help or, perhaps execute the first or last one. With a small custom dialog where you entered a line number, it could find the macro definition that contains that line and execute it. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM peck@... phone: 720-342-5621 From: Kirill Orlov <kior@...> To: [hidden email] Date: 05/22/2015 04:07 AM Subject: [SPSSX-L] Run Current Macro Definition Sent by: "SPSSX(r) Discussion" [hidden email] Is it possible to design a command (for example, in Python) which will read all syntax surrounding the current cursor position, starting from DEFINE and ending at !ENDDEFINE? What I mean is this. Consider I have a macro definition. DEFINE....... bla bla bla bla !ENDDEFINE. To read it into SPSS memory I have to mouse-select everything from DEFINE to !ENDDEFINE. But the code may be very lengthy, so selecting takes time. Instead that, I'd like to be able to put cursor anywhere within the macro body and run some command/button "Read Current Macro Definition" which will automatically select everything within the surrounding DEFINE - !ENDDEFINE range and run it for me. Any ideas? That might be even a good feature to introduce in Statistics itself. ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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 LISTSERV@... (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 LISTSERV@... (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 |
It is a long time since I used macros, but why not put the macro in a separate .sps file and <run all> during drafting? (it could be in s separate syntax window.)
Then use INSERT and select that command and run the selected syntax when you want to run the whole macro while drafting the syntax the macro is used in?
Art Kendall
Social Research Consultants |
Art, your advice is inconvenient in my context. When you are sitting
and debugging your macro, rerunning it every minute, it is not wise
to save/Insert it. Besides, the sheet may contain other syntax as
well which you don't want to run.
22.05.2015 23:55, Art Kendall пишет:
It is a long time since I used macros, but why not put the macro in a separate .sps file and <run all> during drafting? (it could be in s separate syntax window.) Then use INSERT and select that command and run the selected syntax when you want to run the whole macro while drafting the syntax the macro is used in? ----- Art Kendall Social Research Consultants -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Run-Current-Macro-Definition-tp5729589p5729599.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 |
In reply to this post by Kirill Orlov
Hi Kirill, With SpssClient you could do something that approximates this: -get the contents of the designated syntax editor -keep only the macros -paste those macros into an invisible new syntax window -run them with RunSyntax -close the invisible window -you could create a custom button for this on the toolbar http://www-01.ibm.com/support/knowledgecenter/SSLVMB_22.0.0/com.ibm.spss.statistics.python.help/spss/programmability_option/python_scripting_spsssyntaxdoc_getsyntax.htm Albert-Jan ------------------------------ On Sat, May 23, 2015 9:39 AM CEST Kirill Orlov wrote: >Art, your advice is inconvenient in my context. When you are sitting and >debugging your macro, rerunning it every minute, it is not wise to >save/Insert it. Besides, the sheet may contain other syntax as well >which you don't want to run. > >22.05.2015 23:55, Art Kendall пишет: >> It is a long time since I used macros, but why not put the macro in a >> separate .sps file and <run all> during drafting? (it could be in s separate >> syntax window.) >> >> Then use INSERT and select that command and run the selected syntax when you >> want to run the whole macro while drafting the syntax the macro is used in? >> >> >> >> >> ----- >> Art Kendall >> Social Research Consultants >> -- >> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Run-Current-Macro-Definition-tp5729589p5729599.html >> Sent from the SPSSX Discussion mailing list archive at Nabble.com. >> >> ===================== >> 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 ===================== 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 |
Albert, thank you too.
The problem is that there can be many macros, and run (read) must be only the current one - surrounding the cursor - and I may not know the sequential number of that one. The ability to read the cursor's location is the key feature. If python cannot do it then it can't help. 23.05.2015 20:40, Albert-Jan Roskam
пишет:
Hi Kirill, With SpssClient you could do something that approximates this: -get the contents of the designated syntax editor -keep only the macros -paste those macros into an invisible new syntax window -run them with RunSyntax -close the invisible window -you could create a custom button for this on the toolbar http://www-01.ibm.com/support/knowledgecenter/SSLVMB_22.0.0/com.ibm.spss.statistics.python.help/spss/programmability_option/python_scripting_spsssyntaxdoc_getsyntax.htm Albert-Jan ===================== 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 Kirill Orlov
Ha!
Unexpectedly run against the "solution" (version 22): Just click (inside macro body) thrice - and the whole body from DEFINE till !ENDDEFINE will be selected. Miraculous. -------- Перенаправленное сообщение --------
Is it possible to design a command (for example, in Python) which will read all syntax surrounding the current cursor position, starting from DEFINE and ending at !ENDDEFINE? What I mean is this. Consider I have a macro definition. DEFINE....... bla bla bla bla !ENDDEFINE. To read it into SPSS memory I have to mouse-select everything from DEFINE to !ENDDEFINE. But the code may be very lengthy, so selecting takes time. Instead that, I'd like to be able to put cursor anywhere within the macro body and run some command/button "Read Current Macro Definition" which will automatically select everything within the surrounding DEFINE - !ENDDEFINE range and run it for me. Any ideas? That might be even a good feature to introduce in Statistics itself. ===================== 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 |
For some reason, I wasn't expecting this to work despite the claim but it does work!
|
Administrator
|
In reply to this post by Kirill Orlov
Thanks for sharing this, Kirill. And by the way, I just discovered that a triple-click also highlights an entire BEGIN DATA - END DATA block. Copy the example below, paste it into a syntax window, and triple-click somewhere between BEGIN DATA and END DATA, and the whole block should be highlighted.
DATA LIST list / REG_TIDPUNKT(DATE11). BEGIN DATA 28-FEB-2011 1-MAR-2011 15-MAR-2011 30-MAR-2011 31-MAR-2011 1-APR-2011 END DATA. There are probably some other settings where this works too, but this is the only one I've found so far. (I have tried within DO-REPEAT and LOOP - END LOOP structures, but it does not work in either of those contexts.)
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
Confirmed!
Also the following exhibit same behavior. BEGIN PROGRAM. END PROGRAM. BEGIN GPL. END GPL.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |