Jump to content

Writing a java script on the desktop off line


jamesadrian

Recommended Posts

I am just starting to learn some java script. I am looking for a way to write a script on my desktop (which I have done) and see it work on two files on my desktop. I have only seen java script work on my website.

 

Thank you for your help.

 

Jim Adrian

Link to comment
Share on other sites

You can do it all in one file.

<!DOCTYPE html>
<head lang="en">
<meta charset="UTF-8">
<title>test</title>
<style>
h1{color:red}
</style>
</head>

<body>

<h1>TEST</h1>

<div id="msg">
</div>

<script>
var str = "<b>Hello World!</b>";
document.getElementById('msg').innerHTML = str;
</script>

</body>
</html>
Link to comment
Share on other sites

When you say on your desktop, what do you mean? A native application or running in a web browser?

Link to comment
Share on other sites

I have copied the code given above into a text editor and gave it the name test.htm and when I have it on my desktop and click on it my browser renders it as a local file without going on line. This is great!

 

I hope that I can make a few text files and have a script in test.htm manipulate data in the files on my desktop. Of course I will need to know much more javascript to do that. I am willing to learn it all if this goal can be done.

 

Will any additional software be needed in order to do this?

 

Thank you for your help.

 

 

Jim Adrian

Link to comment
Share on other sites

Is this just for something you are doing on your own, or something you are looking to share with other people, so they can run it too?

Link to comment
Share on other sites

Is this just for something you are doing on your own, or something you are looking to share with other people, so they can run it too?

 

I want to write programs that other people can run on their desktop.

 

Does anything prevent this?

 

Thank you for your help.

 

Jim Adrian

Edited by jamesadrian
Link to comment
Share on other sites

No, that's not a problem per se. It's just that writing code and distributing code are different objectives and often involve different skill sets, especially if you are specifically targeting desktop users. That said, it's more of a disclaimer is all.

 

Have you heard of Node? It is a JavaScript runtime (akin to what you get when running JavaScript in the browser) except that it is a program that you can have your users install ahead of time and can be run on their own machines, like a native app. From there, you could publish this project to NPM and then users could also use it to install your project (with all its source and dependencies) and from there a single command could be run in order to launch your app.

 

Any reason you are favoring desktop vs. the web though?

Link to comment
Share on other sites

No, that's not a problem per se. It's just that writing code and distributing code are different objectives and often involve different skill sets, especially if you are specifically targeting desktop users. That said, it's more of a disclaimer is all.

 

Have you heard of Node? It is a JavaScript runtime (akin to what you get when running JavaScript in the browser) except that it is a program that you can have your users install ahead of time and can be run on their own machines, like a native app. From there, you could publish this project to NPM and then users could also use it to install your project (with all its source and dependencies) and from there a single command could be run in order to launch your app.

 

Any reason you are favoring desktop vs. the web though?

I want the simplest way for users to use the program. I would like to email it to them and have it run without any other downloading or complications on their desktop.

 

Can this be done?

 

Jim Adrian

Link to comment
Share on other sites

Moderator,

 

I want the program to take a byte from file A, and another from file B, and use an arithmetic or logical operation on the two bytes and place the result in file C.

 

All three files would be offline, possibly in a folder on the desktop.

 

The program would need to increment the byte address in all cases.

 

I don't care what I would need to use as names of the files or what file types might be used, so long as any eight bits would work as a byte.

 

I would not appreciate a severe limit on the size of these files. One megabyte might be acceptable.

 

If I can't create a file with the script, I would e happy to create them before the script is run.

 

If file C happens to contain only ASCII characters that can theoretically be displayed, I would hope there would be a way to display them or use file C as a text file after the fact (after the script has run).

 

Secondarily, it would be nice if I could interleave a file or use one file to determine a permutation of another file.

 

Thank you for your help.

 

Jim Adrian

Link to comment
Share on other sites

You should look into a real programming language like C++, Java or something of the sort. Javascript can only read files in particular cases and it cannot write to any files. On a desktop it is even more limited.

Link to comment
Share on other sites

I would suggest Java. You can download the JDK and a developer IDE here...

 

http://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-142931.html

 

For security reasons Javascript is severely restricted when it comes to accessing files.

 

Other options would be C# or Python. C++ is rather old and clunky.

Link to comment
Share on other sites

I think the important thing here to keep in mind for the OP is not just looking for development environment, but simple distribution pipeline as well.

 

For that reason, I would still recommend Node. You can continue to write in JS, there are installers for Windows / OSX that anybody can install from to keep that overhead low, and it comes with a package manager. On top of that, you can use Node / NPM to install a webserver for users as well. All in all, it provides a very robust ecosystem for developers, and a pretty straightforward consumption process for users.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...