- This topic has 9 replies, 4 voices, and was last updated 10 years, 8 months ago by support-octavio.
-
AuthorPosts
-
rprosserMemberI am trying to write a simple app. but the execution doesn’t get far, so as I check I put the code into http://www.jslint.com/
That came up with several errors. most notable ones to do with the generated portion of the property names:
var m1-dicepool-D3_range = 0; var m1-dicepool-D4_range = 0; var m1-dicepool-D6_range = 0; var m1-dicepool-D8_range = 0; var m1-dicepool-D10_range = 0; var m1-dicepool-D12_range = 0; var m1-dicepool-D20_range = 0; var m1-dicepool-D100_range = 0; var m1-dicepool-D3_default_threshold = 0; var m1-dicepool-D4_default_threshold = 0; var m1-dicepool-D6_default_threshold = 0; var m1-dicepool-D8_default_threshold = 0; var m1-dicepool-D10_default_threshold = 0; var m1-dicepool-D12_default_threshold = 0; var m1-dicepool-D20_default_threshold = 0; var m1-dicepool-D100_default_threshold = 0;
In the above, my unique IDs contain underscores.
Expected ‘;’ and instead saw ‘-‘.
var m1-dicepool-D3_range = 0;
line 1 character 7
Expected ‘-‘ at column 1, not column 7.
var m1-dicepool-D3_range = 0;
line 1 character 8
‘dicepool’ was used before it was defined.
var m1-dicepool-D3_range = 0;
line 1 character 16
Missing space between ‘dicepool’ and ‘-‘.
var m1-dicepool-D3_range = 0;
line 1 character 17
Missing space between ‘-‘ and ‘D3_range’.
var m1-dicepool-D3_range = 0;
line 2 character 7
Expected ‘;’ and instead saw ‘-‘.
var m1-dicepool-D4_range = 0;
line 2 character 7
Expected ‘-‘ at column 1, not column 7.Further, from http://stackoverflow.com/questions/1661197/valid-characters-for-javascript-variable-names, variables should ‘match. the regular expression
[a-zA-Z_$][0-9a-zA-Z_$]*
. In other words, the default “-” sign seems to be invalid.
So what is to be done about that, please?
Thanks …
Richard
Code_AMemberThe best thing to do here would be for you to post your project or am example of your project so we can see what is going on and understand what you are trying to accomplish, and then we can guide you in the right direction.
To answer your question, no, the generated names are not invalid. You just need to know how and where to reference them within m1.
rprosserMemberWell the Chrome Inspector/Debugger tool complains about an “unexpected token” (‘-‘) and JSLint does as well, plus the relevant Javascript standard indicates that ‘minus’ characters may not be used to form valid identifiers, understandably.
In the variables given above, I replaced all of the minus signs with underscores and now the ‘tracking’ alert() calls that I have in place pop up as expected. Therefore I can only conclude that there IS a problem with the generated default names.
Unfortunately that means (I believe) that I will not be able to use MDC as it stands, though I am surprised that this issue has not been encountered before. I accept that I may have done something “wrong” but the fact remains that in my development environment, variables with underscores are OK but those with the auto-generated minus/dash characters are not.
If you can suggest a work-around or (better, perhaps) a configuration change that will use underscores in identifiers then please do so.
Sorry but I don’t want to give full details because I am concerned about the commercial issues. I suppose that a private message may be possible.
FYI:
Chrome Version 34.0.1847.116 m
Mobione Design Center 2.6.2
Windows 8.1
Asus N56VRegards,
Richard
Code_AMemberI understand your privacy concerns, so I would ask that you recreate a simplified example that shows the exact same issue and we can go from there. Zip the project file(s) up and upload them to this post for review. Maybe someone else will know right off the bat what the issue is, but I need to see more of your project to fully understand the issue and what you are trying to achieve.
Are you trying to create new variables, or are you just trying to reference the widgets by name? Is your code in the <screen>_custom.js file?
The auto-generated widget names can be referenced within m1 by using the following code example:
$('#m1-dicepool-D3').val();
rprosserMember@Code A wrote:
I understand your privacy concerns, so I would ask that you recreate a simplified example that shows the exact same issue and we can go from there.
Unfortunately my trial period has expired and I am not prepared to buy a licence for a product that does not appear to work properly. Nor can I supply you with an example of course, unless I can extend the trial somehow.
I can only suggest that you create a small text box yourself and extend the name with underscores, then add some simple code for the corresponding ‘OnChange’ event. If I am correct that will not work, due to the ‘illegal’ use of dashes in the name.
Regards,
Richard
Code_AMemberIn the example I gave above, the textbox name would be “D3” and the mobi screen name would be “dicepool”. I could rename my textbox to “D3_range” or “D3-range” and then get the values from those text boxes by using the following code, either in the OnChange event or in the <screen>_custom.js file.
var val1 = $('#m1-dicepool-D3_range').val(); var val2 = $('#m1-dicepool-D3-range').val();
I can set the values of the text boxes using this code:
$('#m1-dicepool-D3_range').val("test1"); $('#m1-dicepool-D3-range').val("test2");
There is no need to create new vars with the same names in your code because they are auto-generated and accessible through M1. Again, I may not be understanding your problem completely but the auto-generated names do work.
rprosserMemberWell I bought a licence, on the grounds that if the product really was faulty then I could get a refund, plus there do not appear to be any other tools that are as easy to use.
I did some more testing/checking and it transpires that I was trying to set some UI variables that didn’t exist! I am not sure if that was the problem or not but after some more debugging I have got things working now, so far. Please accept my apologies for any inconvenience caused.
I have to say however that the error reporting and debugging facilities could be improved. Javascript seems to fail silently by default, which is really annoying. I now have some try … catch blocks in place but they will all have to be removed when it comes to releasing my app. I also tried adding a “debugger;” statement but that didn’t really work either. The only valid entry point I found was to set a breakpoint for the OnChange Listener event in the Chrome debugger.
Thanks for your help and your patience …
Richard
support-michaelKeymasterHi Richard,
>Well I bought a licence
Thanks for your support.
>I am not sure if that was the problem or not but after some more debugging I have got things working now
Great! Thanks for providing the feedback.
>I have to say however that the error reporting and debugging facilities could be improved
I’m giving this some thought to better understand the core problem and if it is in a context that MobiOne tools or code-generation can detect errors. One of the reasons for implementing the Simulator on Chrome is due to its ever increasingly great web inspection and debugging tools. When a project is run on the Simulator, simply open the inspector and you can see any syntax errors with line numbers identifed in the console. From there you can view the src load in the Simulator and set breakpoints, modify the DOM and JS variables, … <all that good stuff>
rprosserMemberYes I get that – though it took me a while to work our how to invoke the Chrome debugger – but I still think that errors should be clearly ‘announced’.
Also it would be nice if the ‘debugger;’ statement worked correctly.
Richard
PS Can you implement an anti-spam technique that is quicker to use, please?
support-octavioMemberHi Richard,
I kicked this topic up to the dev team.
I also shared your request to improve the captcha mechanism with our IT team that own the forum and security software. We have tried a few different approaches and when we relax it the forums quickly start to fill with spam and everyone is annoyed by it. Let’s see what they say. -
AuthorPosts