How to pass operator in label in titanium alloy - titanium

I have label
<Label id="textArea" text="0" />
I want to add numbers and operators in label, numbers are showing in label but operators are not showing in label.
Same value I tried in console as
Ti.API.info('label = ' + $.textArea.text);
It is showing in console but not in label in app, why so?
Please help I am new in titanium.

The best way to achieve this, as I understand your question, is to create the text elsewhere.
var text = 'The text is 8 + 5 = 13';
$.textArea.setText(text);
If you are having trouble with the operators showing, maybe you are executing the sum operation (as per my text example) in javascript and not adding it as a string?
Failing example:
$.textArea.setText('The text is ' + 8 + 5 + ' = 13');
Hope this helps

Related

Birt export in pdf does not wordwrap long lines

My reports preview is ok.
But now, I need to export to pdf...and I've got an issue : the content of some cells are truncated to the witdh of the column.
For instance, 1 cell should display "BASELINE"...in the preview it's ok...but in pdf, it displays "BASEL".
I've been looking for a solution the whole day and did not find anything...
Of course : I don't want to fit the width of the column on the length of this word "BASELINE" because the content is dynamic...
Instead, I want to fix the column width and then, the cell should display something like that :
BASEL
INE
Any idea ?
Thanks in advance (am a little bit desperated...)
The solution is trivial in BIRT v4.9 if you've integrated the engine into your java code. Just set the PDF rendering options.
RenderOption options = new PDFRenderOption();
options.setOutputStream(out);
options.setOutputFormat("pdf");
options.setOption(PDFRenderOption.PDF_WORDBREAK, true);
options.setOption(PDFRenderOption.PDF_TEXT_WRAPPING, true);
task.setRenderOption(options);
You have to set a special PDF emitter option:
PDFRenderOption options = new PDFRenderOption();
options.setOption(PDFRenderOption.PDF_HYPHENATION, true);
This is if you integrated BIRT into your Java program.
For the viewer servlet, it is possible to set such options, too, AFAIK, but I don't know how; maybe on the URL or using environment variables.
I had the same issue. I found a very good topic about that : http://developer.actuate.com/community/forum/index.php?/topic/19827-how-do-i-use-word-wrap-in-report-design/?s=173b4ad992e47395e2c8b9070c2d3cce
This will split the string in the given number of character you want :
The function to add in a functions.js (for example). To let you know, I create some folder in my report project : one for the reports, one for the template, one for the libraries, another for the resources, I added this js file in the resources folder.
/**
* Format a long String to be smaller and be entirely showed
*
*#param longStr
* the String to split
*#param width
* the character number that the string should be
*
*#returns the string splited
*/
function wrap(longStr,width){
length = longStr.length;
if(length <= width)
return longStr;
return (longStr.substring(0, width) + "\n" + wrap(longStr.substring(width, length), width));
}
You will have to add this js file in the reports : in the properties -> Resources -> Javascript files
This is working for me.
Note: you can add this function in your data directly if you need only once...
The disadvantage of this : you will have to specify a max length for your character, you can have blank spaces in the column if you specify a number to small to fill the column.
But, this is the best way I found. Let me know if you find something else and if it's working.

How do I display the output of a function of multiple qualtrics sliders in real time?

My colleague and I am designing a survey using Qualtrics. On one page respondents must move a series of sliders.
We need to display the output of a function of the values of the sliders on the same page, ideally also in the form of another slider.
All of this must be done while the respondent moves the sliders.
Concretely, suppose the following:
value of slider 1 = 30;
value of slider 2 = 10;
value of slider 3 = 0
Output to be displayed = 30 x 20 + 10 x 5 + 0 x 15 = 650
where the 20, 5 and 15 are just arbitrary constants in the background.
If the user were to move slider 1 to 31, the displayed output should automatically update in real time to 670.
Any tip on how this is done? We're newbies to qualtrics and completely inexperienced with Java, so we'd be very grateful to anyone willing to provide us with working code. Thanks!
An update on my question, and a clarification after a comment received.
We were of course not asking for someone else to do our job. Just for a pointer in the right direction.
Based on an answer to a different question, I've managed to put this javascript together. It works, which is encouraging..
Code follows.
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var that=this.questionId;
jQuery("<p style='width:100%'><br><strong> Output <span id='OUT'>0</span></strong>").insertAfter("table.sliderGrid");
jQuery(document).on('change', function(){
var firstslider=parseInt(jQuery("[id='"+that+"~1~result']").val());
var secondslider=parseInt(jQuery("[id='"+that+"~2~result']").val());
var N=firstlider+secondslider*2;
jQuery("#OUT").text(N);
});

How to display multiplication result in a textbox using Selenium WebDriver?

I am a manual tester and want to switch to automation testing. I've learnt Selenium WebDriver recently. While practicing, I came across a webpage where I was asked to automate the following thing in a web form:
In the form, they have provided two double numbers and have asked us to display the multiplication of thosenumbers in the textbox. Please guide me how can I display the result in the textbox using selenium webdriver.
Screenshot of the xpath
Add screen shot using below steps-
Click "Edit" to your question.
On upper side you can find Image icon or press "Ctrl + G".
Drag & drop the image or attach by providing the path.
[Note: I have added this as an answer because I don't have 50 points yet to add a comment. Forgive me for that.. :)]
If the two double numbers are in separate input field (any other place except input filed) get the data as follows:
double number01 = Double.parseDouble(driver.findElement(By.cssSelector("your selector for element")).getText());
double number02 = Double.parseDouble(driver.findElement(By.cssSelector("your selector for element2")).getText());
Then perform multiplication and use sendkeys to input into the output field:
driver.findElement(By.cssSelector("your selector for element2")).sendKeys((number01 * number02) + "");
Note:
Above answer is based on assumption according to your question.
Edit:
String terms = driver.findElement(By.cssSelector(("#form > form > label:nth-child(89)"))).getText().replaceAll("=", "");//get the expression for multiplication and remove the '=' sign at the end
String [] temp_xy = terms.split("X"); // split the string into multiplicand and multiplier parts
double multiplicand = Double.parseDouble(temp_xy[0].trim());
double multiplier = Double.parseDouble(temp_xy[1].trim());
double product = multiplicand * multiplier;
Now, you put your product in the desired filed. Similarly, you can find the quotient.

Strange string issue in vb.net

This is a simple yet weird one. I have an app that uses a setting to create a string, which then gets put into a rich text box. sounds simple right? But for some weird reason i'm getting an extra line break. Simple example :
if i do this :
head = "Some text :" + " some other text"
richtextbox.AppendText(head)
the output is
Some text : some other text"
as you would expect. but if the app does the following :
my.settings.variable1 = " some other text"
head = "Some text :" + my.settings.variable1
richtextbox.AppendText(head)
the output is
Some text :
some other text"
ie with a line break i never specified. It's not a word wrap or tab issue as i've tried every variation under the sun to eliminate those possibilities. any ideas?
**** EDIT ********
I have narrowed down the cause but still makes little sense. The cause is the setting i am using to provide part of the string. the actual code in my app is :
head = "Your Server : " + My.Settings.Server + "....Bill#" + My.Settings.BinNo
which somehow puts a line break after my.settings.server. However if i have the exact same line but change the code to :
head = "Your Server : " + My.Settings.BinNo + "....Bill#" + My.Settings.BinNo
I no longer see the problem. Bizarre, but progress. Still can't figure out why. Both are string variables, both are same length....
Found the problem. It was strange but simple. There was a recursive bit of code earlier in the module that formatted the string before assigning it to the server setting. It was meant to check the length of the string and pad it to a certain length. However it went awry and added a whole bunch of spaces on the end, so at the end of it all it was not a line feed that made it go to the next line, it was simple word wrap and invisible space characters pushing the text to the right. simple but annoying to find. thanks for the help guys

Scripting enterprise architect: change element compartment visibility

Is it possible to change element notes visibility in script? I.e. to perform in script the same action as [Ctrl-Shift-Y]-[Show notes]?
Yes, but not directly.
style = oldStyle + "Notes=100;"
Repository.Execute("UPDATE t_diagramobjects SET ObjectStyle=" + style + " WHERE InstanceID=" + instanceId)
assuming you have the instanceId of the diagram object you want to change. Also oldStyle has the current contents ObjectStyle, it ends with a semicolon and does not already contain a "Notes=;" string.