Hi,
may be you can help me on the following: I created a custom dialog which is working but some strange problem occcur if I have more variables: If I drag too many variables in the target list, they are all be written in one row in the syntax which leads to an error message. s = sorted(varlist, key=f) spss.Submit(r"""ADD FILES FILE=* /KEEP=c_0014 c_0015 v_1 v_2 v_3 v_4 v_5 v_6 v_7 v_8 v_9 v_10 v_11 v_12 v_13 v_14 v_15 v_16 v_17 v_18 v_19 v_20 v_21 v_22 v_23 v_24 v_25 v_26 v_27 v_28 v_29 v_30 v_31 v_32 v_33 v_34 v_35 v_36 v_37 v_38 v_39 v_40 v_41 v_42 v_43 v_44 v_45 v_46 v_47 v_48 v_49 v_50 v_51 v_52 v_53 v_54 v_55 v_56 v_57 v_58 v_59 v_60 v_61 v_62 v_63 v_64 v_65 v_66 v_67 v_68 v_69 v_70 v_71 %s.""" % " ".join(s)) end program. All in bold is written in one row. Is there an option to insert a word wrap anywhere in the custom dialog? Thank you! |
The CDB will line wrap regular Statistics syntax, but it cannot wrap Python or R code, since the language syntax rules are different. The best solution for this is to make the program into an extension command, so then the syntax in the dialog box would follow the regular Statistics rules and could be wrapped. The only alternative here would be to use several variable list controls with each one on a separate line in the template syntax. Not foolproof, but it would help. On Mon, Feb 20, 2017 at 2:39 AM, emma78 <[hidden email]> wrote: Hi, |
Administrator
|
In reply to this post by emma78
Perhaps you should post the error message?
Maybe attach the CD file as well? ----
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?" |
In reply to this post by Jon Peck
Hi,
I tried it in the extension command, but I got the same message here. this is the syntax: begin program. import spss, spssaux varlist = spssaux.VariableDict().variables varlist.pop(varlist.index('%%Name_of_first_variable%%')) def f(key): key = key.split("_") if len(key) == 3: return (int(key[2]), int(key[1])) else: return (0, int(key[1])) for k, item in enumerate(key): try: item = int(item) except: pass key[k] = item return key s = sorted(varlist, key=f) spss.Submit(r"""ADD FILES FILE=*\n/KEEP=%%not_sort%% %s.""" % " ".join(s)) end program. and this is the error message >Error # 6892. Command name: begin program >The string's length is more than 251. >Execution of this command stops. end program. File "<string>", line 21 |
Sorry, but that is not an extension command. An extension command has regular, Statistics-style syntax but is implemented in Python, R, or Java. Besides the optional custom dialog box, it has a small xml file that defines the command name, subcommand names, and keywords and an implementation file in one of these languages. There is more information on building extensions in the Help system or various articles on the IBM Predictive Analytics Community site. On Mon, Feb 20, 2017 at 8:29 AM, emma78 <[hidden email]> wrote: Hi, |
That's what I write in the custom dialog box
|
The code does not go in the CDB. It goes in a Python (.py) file that is part of the extension. What goes in the CDB syntax might look like EMMA MYADD VARIABLES=%%keeplist%%. There might be other keywords and subcommands, too. The generated syntax would then look just like regular syntax and would be properly wrapped by the CDB as needed. When executed, the syntax is checked by the Statistics syntax parser and passed to Python code in a special form for execution. On Mon, Feb 20, 2017 at 8:38 AM, emma78 <[hidden email]> wrote: That's what I write in the custom dialog box |
Ok, I will get to know the extension command later ;-)
I try to adapt this: The only alternative here would be to use several variable list controls with each one on a separate line in the template syntax. Not foolproof, but it would help. I can generate several variable lists in the custom dialog but how can I set a maximum of variables which can be dragged in the target list? Like as it is in the frequency dialog: only 500 variables are possible to drag, can I add this here too? |
In the v24 CDB, you can specify the minimum and maximum number of entries in a variable list control, but this is not possible in earlier versions. Even with V24, though, since the number of variables that would work depends on the length of the variable names, this isn't a perfect solution. You can add a text comment, though, in the dialog to instruct the user about this. On Tue, Feb 21, 2017 at 3:31 AM, emma78 <[hidden email]> wrote: Ok, I will get to know the extension command later ;-) |
Is this really possible in the custom dialog builder?
I can only see this in the CBD for extensions, may be you can give me another hint :-)? |
The V24 CDB is not backwards compatible, but if the users are all on that version, when you create a target list, it has minimum and maximum number properties. If you do go with 24, be sure that everyone has the fixpack for V24 installed as there were significant problems with the enhanced CDB in 24.0.0.0. Also, to clarify, with the V24 CDB, every custom dialog is formally an extension, but it can be just a dialog box. You can just take your existing dialog and open it upgrading and you have access to all the new properties and controls. On Tue, Feb 21, 2017 at 8:35 AM, emma78 <[hidden email]> wrote: Is this really possible in the custom dialog builder? |
Ok thank you :-)
Just one last question: I build it and in the preview I got an error message when I drag too many (Out of range...) But it doesn't work after installing it and try it in the live version. I can drag all variables without any message. Has this something to to with a bug or do I make a mistake somewhere? |
The behavior should be the same in Preview mode and live. But it is broken :-( I'll report this to development. Sorry. On Wed, Feb 22, 2017 at 1:59 AM, emma78 <[hidden email]> wrote: Ok thank you :-) |
Free forum by Nabble | Edit this page |