I have shell command which runs batch file with parameters below code all works fine
WshShell.Run ( '"H:\\Workspace\\testcomplete\\TCAF - QIKSilver\\test.bat" ' + + a + ' ' + b + ' ' + c);
The batch file path is not constant I would like to pass it dynamically
d= Project.Path; // I get the path of my project
value = d.replace(/\\/g, "\\\\");// replace single backslash with double slash
filepath = value.concat("test.bat") // value of filepath varialbe is -H:\\Workspace\\testcomplete\\TCAF - QIKSilver\\test.bat
Following is not working:
WshShell.Run ('filepath' + a + ' ' + b + ' ' + c);
any suggestions please
This code is written inside test complete using java script
You need to use filepath as a variable, not string, and you need to add quotes since your path contains spaces:
WshShell.Run('"' + filepath + '" ' + a + ' ' + b + ' ' + c);
Try this:
WshShell.Run (filepath+' '+ a + ' ' + b + ' ' + c);
Related
I have a Google Apps Script I am writing that combines a number of reports into a consolidated tab-delimited (TSV) format. However, I am noticing that whenever I write to file, the tabs in my strings are being converted into spaces. Is there some other string literal that I should use?
var content =
data.parameters.time[0] + "\t" +
data.parameters.url[0] + "\t" +
data.parameters.code_name[0] + "\t" +
data.parameters.app_name[0] + "\t" +
data.parameters.version[0] + "\t" +
data.parameters.cookies[0] + "\t" +
data.parameters.lang[0] + "\t" +
data.parameters.platform[0] + "\t" +
data.parameters.user_agent[0] + "\t" +
data.parameters.ex[0];
fld.createFile(makeid() + ".tab", content, ContentService.MimeType.CSV);
Nothing is wrong with using the \t string literal - rather you're using the wrong MimeType enum, from the ContentService. DriveApp methods expect MimeType as a string. Try:
fld.createFile(makeid() + ".tab", content, MimeType.CSV);
Here's a snippet that shows the tab characters survive the file write when the MimeType is properly set:
function myFunction() {
var content =
'time' + "\t" +
'url' + "\t" +
'code_name' + "\t" +
'etcetera';
Logger.log("Initial TSV: " + JSON.stringify(content.split("\t")));
var newFile = DriveApp.createFile("Delete-me" + ".tab", content, MimeType.CSV);
// Check our result, by reading back the file
var blob = newFile.getBlob();
var docContent = blob.getDataAsString()
Logger.log("Result TSV: " + JSON.stringify(docContent.split("\t")));
}
Logs:
[15-04-07 14:53:08:767 EDT] Initial TSV: ["time","url","code_name","etcetera"]
[15-04-07 14:53:09:542 EDT] Result TSV: ["time","url","code_name","etcetera"]
I am using jQchart to display a graph. However, the title property seems to display only a single line of text. Currently, the graph displays the following title:
text: chartTypeText + ': ' + chartTitle + ", " + $('#baselineResidentialLocationCity option:selected').text() + ', ' + $("#baselineResidentialLocationState option:selected").val() + ' ' + $('#baselineResidentialStandardYear option:selected').text() + ' ' + baselinePeriod + ' year'
However, I basically need to display each variable on a different line (hopefully use linebreaks to separate each piece of information). I tried using "" but it displays the string literal.
Is there any way I could display each variable under the title of the graph with different fonts etc?
If you are looking for series title customization, it can be customized with tooltipFormat event.
[Use some separator(I use ; as a separator) and format with html, css]
In below statement, I changed separator to ;
text: chartTypeText + ': ' + chartTitle + ";" + $('#baselineResidentialLocationCity option:selected').text() + ', ' + $("#baselineResidentialLocationState option:selected").val() + ';' + $('#baselineResidentialStandardYear option:selected').text() + ' ' + baselinePeriod + ' year'
<script lang="javascript" type="text/javascript">
$(function () {
$('#ChartClientID').bind('tooltipFormat', function (e, data) {
var t=data.series.title.split(";");
//OR here you can dynamically build here it self
return "<b>" + t[0] + "</b><br />"
+ (t[1] || "") + "<br />"
+ (t[2] || "");
});
});
</script>
see this link for reference: http://www.jqchart.com/aspnet/chart/ChartFeatures/Tooltips
I'm trying to add a href link to jquery append. The link opens an ajax modal when clicked.
here's what I have
$('<div/>').text(message.text).prepend($('<em/>')
.text('Opponent: '+ opponentName + ',' + ' ' + 'Game amount: ' + message.amount + ' ' + 'tokens,' + ' ' + 'Game: ' + message.game + ' ' + 'accept')).appendTo($('#pendingChallenges'));
$('#pendingChallenges')[0].scrollTop = $(' #pendingChallenges')[0].scrollHeight;
You need to use html instead of text to have your html string to be represented as html instead of textcontent which is what happens when you use text.
$('<div/>').text(message.text).prepend($('<em/>')
.html(...
The ultimate aim is to return a page displaying the following sentence
Once upon a time there was a GENDER named NAME who had a PET named PET NAME.
<SCRIPT language="JavaScript">
var heroGender, heroName, petType, petName;
heroGender = window.prompt('Is the hero female or male? Enter F or M', 'F');
heroName = window.prompt('What is the hero\'s name?','');
petType = window.prompt('What type of pet does the hero have?','');
petName = window.prompt('What is name of the pet?','');
document.write('Once upon a time there was a ');
if (heroGender == ('F'))
{
document.write('girl');
}
else
{
document.write('boy');
}
document.write('Once upon a time there was a ' + heroGender + ' named ' + heroName '.''<BR>' +
heroName + ' had a ' + petType + ' called ' + petName + '.');
</SCRIPT>
While your waiting for the books!
Learn from Mozilla Developer Centre !
An Example:
Example
Fixed version
document.write(
'Once upon a time there was a ' + heroGender +
' named ' + heroName + '.' + '<BR>' + heroName +
' had a ' + petType + ' called ' + petName + '.');
Broken version
You were missing to + symbols.
document.write(
'Once upon a time there was a ' + heroGender +
' named ' + heroName /* + */ '.' /* + */ '<BR>' + heroName +
' had a ' + petType + ' called ' + petName + '.');
Try using
Firefox and Firebug and its console tab (Hit F12)
IE9 and the build in console (Hit F12. Make sure the console is open then refresh).
Chrome and the build in console (Hit Ctrl+Shift+J)
To watch for any error messages.
If that's too much effort then try
window.onerror = function(e) {
alert(e.message);
}
Here's an "improved" more standards compliant version. Example Link!
HTML:
<label> Your Hero's gender </label><input id="heroGender"/><br/>
<label> Your Hero's name </label><input id="heroName"/><br/>
<label> Your Hero's pet type </label><input id="petType"/><br/>
<label> Your Hero's pet name </label><input id="petName"/><br/>
<button> Make me a hero! </button>
<div id="output"></div>
JavaScript:
// make your hero when you press the button
document.getElementsByTagName("button")[0].addEventListener("click", function() {
// get all the values from the text boxes
var gender = document.getElementById("heroGender").value,
name = document.getElementById("heroName").value,
petType = document.getElementById("petType").value,
petName = document.getElementById("petName").value;
// set the text on your output.
document.getElementById("output").textContent =
"Once upon a time there was a " + gender +
" named " + name + ". " + name + " had a pet " +
petType + " called " + petName;
}, false);
The above code will break for IE8 or less :(. Making JavaScript work cross browser is a right pain.
So I you could read the documentation for browsers at
Firefox's MDN
Microsoft JavaScript docs and HTML docs
But those are not easy to read or navigate. A great visual guide for cross browser scripting is the visibone BrowserBook.
It will show cross browser support (red is firefox, blue is IE) :
Give it a few months and you'll know how to use all that comfortably.
I think you had some typos in your final document.write.You're missing a '+' after heroName... and you've got some duplicative document.writes.
Here's what I believe should be your final code:
var heroGender, heroName, petType, petName;
heroGender = window.prompt('Is the hero female or male? Enter F or M', 'F');
heroName = window.prompt('What is the hero\'s name?','');
petType = window.prompt('What type of pet does the hero have?','');
petName = window.prompt('What is name of the pet?','');
if (heroGender == ('F')) { heroGender ='girl'; } else { heroGender = 'boy'; }
document.write('Once upon a time there was a ' + heroGender + ' named ' + heroName + '. ' + heroName + ' had a ' + petType + ' called ' + petName + '.');
There is a syntax error in this line:
document.write('Once upon a time there was a ' + heroGender + ' named ' + heroName '.''<BR>' + heroName + ' had a ' + petType + ' called ' + petName + '.');
specifically, here:
heroName '.''<BR>' + heroName
If you change it to this, your should work as expected:
document.write(' named ' + heroName + ' who had a ' + petType + ' called ' + petName + '.');
Notice that I also removed the redundancy from the first part of the phrase, since you already included it before your "if 'F', then 'girl'" statement.
Too many quotes and a missing plus
Error: missing ) after argument list
Source File: http://fiddle.jshell.net/_display/
Line: 41, Column: 83
Source Code:
document.write('Once upon a time there was a ' + heroGender + ' named ' + heroName '.''<BR>' +
should be
document.write(' named ' + heroName + '.<BR>' +
heroName + ' had a ' + petType + ' called ' + petName + '.');
http://jsfiddle.net/mplungjan/zHGsD/
document.write('Once upon a time there was a ' + heroGender + ' named ' + heroName **+** '.' **+** '<BR>' +
heroName + ' had a ' + petType + ' called ' + petName + '.');
I got it to run by adding the two + that I've wrapped in **
The problem is on your last line. Corrected as follow
document.write('Once upon a time there was a ' + heroGender + ' named ' + heroName + '.' + '<BR>' + heroName + ' had a ' + petType + ' called ' + petName + '.');
how to call javascript function from anchor tag which is part of a javascript string?
var htmlVar = '<span> Name: ' + arNames[j] + '</span></br><span> Last: ' + arLast[j] + '</span><br/><a javascript:setProfile(\\"+ dob[j]+\\",\\"+state[j]+\\") >View</a>';
If I'm understanding your intention correctly (having a string that contains the HTML for a link that is a Javascript link), you could do it thus:
var htmlVar = '<span> Name: ' + arNames[j] + '</span></br><span> Last: ' + arLast[j] + '</span><br /><a onclick="javascript:setProfile(\\"' + dob[j] + '\\",\\"' + state[j] + '\\")">View</a>';