Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

Python and custom dialog builder.

110000D4XK gravatar image
Question by SystemAdmin  (532) | Apr 28, 2009 at 10:39 AM spssstatisticsextensibilitypython

Hello,

I'm using the code provided below packed inside a custom dialog. The inplace variable %%item_5%% results in one long line that generates an error:

>Error # 6892. Command name: begin program >The string's length is more than 251. >This command not executed.



begin program.
import spss, spssaux
dict=spssaux.VariableDict()
xvars="""
%%item_5%%
"""
yvars="""
%%item_4%%
"""
xvars=xvars.split()
yvars=yvars.split()

for x in xvars:
for y in yvars:
spss.Submit("""do some stuff"")

end program.

How can I circumvent this?


Thanks,


Olav

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

8 answers

  • Sort: 
110000D4XK gravatar image

Answer by SystemAdmin (532) | Apr 28, 2009 at 03:39 PM

 What kind of control is item_5, and what type of values can it contain?
  
             
Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D4XK gravatar image

Answer by SystemAdmin (532) | Apr 28, 2009 at 08:07 PM

 Yes, that would have been handy to explicitely mention. <br>


It's a target variable box with the multiple variables option on.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D4XK gravatar image

Answer by SystemAdmin (532) | Apr 28, 2009 at 08:12 PM

 In that case, the pasted text should have been line wrapped. Can you send me the spd file (peck@spss.com)?
  
             
Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270004AQDV gravatar image

Answer by sweetDisplayName (0) | Jun 22, 2011 at 05:00 PM

 having same problem<br>


can you line wrap the text that is substituted for "%%item_5%%", as the text will not be known until run time?

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D4XK gravatar image

Answer by SystemAdmin (532) | Jun 22, 2011 at 05:10 PM

 None of the Python code can be line wrapped by the dialog box or the Syntax Editor, because those components do not parse anything but standard SPSS code. If you can't manage just by putting the item on a line by itself in the CDB syntax window, you would need to create an extension command so that the dialog could be expressed in standard-style SPSS syntax. That would then be wrapped automatically just as if it were built-in SPSS syntax.<br>


Information on creating extension commands is available on this site and via the programmability documentation installed with the Essentials. You can also find many examples in the Extension Commands collection in the downloads area.

HTH,
Jon Peck

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270004AQDV gravatar image

Answer by sweetDisplayName (0) | Jun 22, 2011 at 09:33 PM

 Thanks for replying, I will look into extension commands.<br>


Do you know if I would still be able to reference the variables from the dialog's target list from within the extension command, and how I would go about that, or if there is any other way to access the variables in the dialog's target list without the %%this_value%%?

Don't know if I'm completely missing something but it seems like I'd still have to dump the target list string into the syntax editor in order to pass it to the extension command? Or maybe just easier to do it without using the dialog builder?

Seems like one of those things that is way more complicated than it should be.

Basically what I'm doing is splitting the string of variables from the target list to do some repetitive renaming/recoding, but if I add more than about 10 variables at a time it hits the 251 byte limit, so it works fine but could be a little nicer.

Thanks again, much appreciated.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D4XK gravatar image

Answer by SystemAdmin (532) | Jun 22, 2011 at 11:52 PM

 The strategy would be to define the extension command syntax with a keyword like<br>
  VARIABLES of type VariableNameList. The XML below could be the entire command definition, although you might want to have other parameters, too.<br>
  This is then processed by the extension.py module, which calls your Python code with the keyword values as parameters. This will be more obvious if you look at one of these commands. You define the syntax tokens to be received and between the SPSS parser and the extension module code, the error checking/command validation is all done for you.<br>


SPSSINC CREATE DUMMIES is a simple extension command you could use as an example.

This text would be in a file named, say, MY_WHATEVER.xml, and your Python module would be named
MY_WHATEVER.py

<Command xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="extension.xsd" Name="MY WHATEVER" Language="Python">
<Subcommand Name="" IsArbitrary="False" Occurrence="Optional">
<Parameter Name="VARIABLES" ParameterType="VariableNameList"/>
</Subcommand>

Then, in the CDB, you would declare your syntax like
MY WHATEVER VARIABLES=%%this_value%%

That text can be wrapped by the SPSS line wrapper code in the dialog subsystem, because it follows the rules for SPSS syntax. And to the user, everything looks like a standard SPSS Statistics command. Python can't be wrapped by SPSS code, because it has a very different set of rules about where lines can be broken.

HTH,
Jon Peck

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270004AQDV gravatar image

Answer by sweetDisplayName (0) | Jun 23, 2011 at 03:33 PM

 Ok I think it's making sense now, should have it from here.<br>
  merci
  
             
Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

46 people are following this question.

Answers

Answers & comments

Related questions

Exporting output tables into multiple XL sheets? 3 Answers

output export 11 Answers

Close SPSS database in external mode 2 Answers

Cannot install PLS extension bundle 2 Answers

Commenting within Python 3 Answers

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges