The blog contains mostly brain-dead programming tutorials, because it seems like you can never find any programming tutorials brain-dead enough.
This Could Be Better: Insulting your intelligence since 2011.
The blog contains mostly brain-dead programming tutorials, because it seems like you can never find any programming tutorials brain-dead enough.
This Could Be Better: Insulting your intelligence since 2011.
Hi,
I happened to come across your page by accident. it is amazing to actually see some great programs and passion.
I’m going to be cheeky, because someone once said, if you don’t ask, you don’t know.. I am desperate for some help on small program that allows you to fill in 5 text boxes and submit them. once submitted, I need them to save into the same excel workbook on a different line each time.
I built this system in excel VBA, but our excel versions at work are so dated! that they don’t all run the code.
would you be able to help in any way?
many thanks,
ash
Hi, Ashley. I’m not sure what your experience level is, but basically how I would do it is: 1. Create an HTML5 interface with five inputs and a button. 2. Add a click event on the button that takes the values from the inputs, converts them to an Excel file format (or maybe the relatively simple CSV format would work), and then 3. prompt the user to download that data as a file.
To get you started, you might take a look at my HTML5 text editor program at https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/, and learn more about the CSV format at https://en.wikipedia.org/wiki/Comma-separated_values
Hello I am totally desperate as I am not a programmer, and need to get some javascript running from articulate storyline. Here is the code which you will probably laugh at, but all I need to do is pull some variables and export them to a .txt file on my computer so that each time someone clicks on the complete button, the javascript runs:
alert(“Thankyou…”);
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=month + “/” + day + “/” + year
var player = GetPlayer();
var Firstname = player.GetVar(“FirstName”);
var Surname = player.GetVar(“Surname”);
var DateofBirth = player.GetVar(“DateofBirth”);
player.SetVar(“SystemDate”,dateString);
var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var s = fso.OpenTextFile(“D:\\Test.txt”, 8, true, 0);
s.WriteLine(“FirstName: ” + Firstname);
s.WriteLine(“Surname: ” + Surname);
s.WriteLine(“DateofBirth: ” + DateofBirth);
s.WriteLine(“DateofCompletion: ” + SystemDate);
s.WriteLine(“==========”);
s.Close();
Do I need to create the Test.txt file before I run this on my D:/ or will the code do this for me? I’m so stuck!
THANKS
It looks like your code uses ActiveX, which is not really something I know very much about, nor do I wish to. Sorry. If you haven’t already looked at it, you might take a look at my post at https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip, which uses HTML5 rather than ActiveX to allow loading and saving of text.
I’ll try to post another reply after this one with some code adapted from that post that you might find helpful, but it’s pretty legendarily difficult to post code in a WordPress comment. I’ll do my best.
Save Text
function buttonSaveText_Clicked()
{
var textToSave = document.getElementById(“inputTextToSave”).value;
var fileNameToSaveAs = document.getElementById(“inputFileName”).value;
saveTextAsFile(textToSave, fileNameToSaveAs)
}
function saveTextAsFile(textToSave, fileNameToSaveAs)
{
var textToSaveAsBlob = new Blob([textToSave], {type:”text/plain”});
var textToSaveAsObjectURL = window.URL.createObjectURL(textToSaveAsBlob);
var downloadLink = document.createElement(“a”);
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = “Download File”;
downloadLink.href = textToSaveAsObjectURL;
downloadLink.onclick = function(event) { document.body.removeChild(event.target); }
downloadLink.style.display = “none”;
document.body.appendChild(downloadLink);
downloadLink.click();
}
<html>
<body>
<!– ui –>
<button id=”buttonSaveText” onclick=”buttonSaveText_Clicked();”>Save Text</input>
function buttonSaveText_Clicked()
{
var textToSave = document.getElementById(“inputTextToSave”).value;
var fileNameToSaveAs = document.getElementById(“inputFileName”).value;
saveTextAsFile(textToSave, fileNameToSaveAs)
}
function saveTextAsFile(textToSave, fileNameToSaveAs)
{
var textToSaveAsBlob = new Blob([textToSave], {type:”text/plain”});
var textToSaveAsObjectURL = window.URL.createObjectURL(textToSaveAsBlob);
var downloadLink = document.createElement(“a”);
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = “Download File”;
downloadLink.href = textToSaveAsObjectURL;
downloadLink.onclick = function(event) { document.body.removeChild(event.target); }
downloadLink.style.display = “none”;
document.body.appendChild(downloadLink);
downloadLink.click();
}
</body>
</html>
Hey thiscouldbebetter 🙂 I like your blog and have been running some of your coding projects locally to see what happens and how they work!
Thanks for publishing this all online 🙂 You’re awesome!
Hi,
Love your site, I’ve been playing with your RPG combat engine, do you have any suggestions on a good javascript tutorial/book as I would like to make my own.
Thanks for enhance my coding results. Have bought your book now. It will be my companion the next weeks. What is your noteworthy «thiscouldbebetter» post?
Thank you! I hope the book is helpful.
The motto “This Could Be Better” is not about a single post, but about life in general. It could be seen either as really optimistic or really pessimistic, or both, which describes my personal philosophy pretty well
Well, your code could not be much better; darn good!
I have a question about the .wav synth. It seems like the .wav input file and output file are the same. I can’t find where you set a different input .wav file.
My understanding is: input a .wav sample and the musical notes in text and output a .wav of the combination.
Is that correct?
Thanks, Tom Meyers
Thanks!
I’m not sure which of my posts your question is about. I have a few things that might be called a “wav synth”. There’s a synthesizer in Java from a long time ago, one in JavaScript that was adapted from that one, a more recent “music tracker” that’s more or less a synthesizer, and some other stuff besides. If you can comment on the particular page for the code in question, I’d be happy to try and clarify what I was trying to do there.
Hi thiscouldbebetter. What a palette of cool stuff! Really generous of you to share like this!
I hope this will not be seen as spam; Have you seen TiddlyWiki? https://tiddlywiki.com/
It’s an open source tool made entirely in JS. Some compare it to Evernote but designed to be super hackable. It is really useful for a zillion things.
Here’s github: https://github.com/Jermolene/TiddlyWiki5
…and the super active community forum: https://groups.google.com/forum/#!forum/tiddlywiki
…and the dev forum – I actually just made a post about your stuff, here:
https://groups.google.com/forum/#!topic/tiddlywikidev/yLOG1_v-t5Q
Matias a.k.a Mat <:-)