Jump to content

Running a simple self-written program on windows

JGalsky

Hello all! I am new to writing code and would like to get started with some simple programming.  

I want to write a program to calculate the price of a certain object with specific measurements.  I want the program to ask what the width, height, and depth of such product and give me a price depending on what input I give it.  

Here's my question, I want to be able to run it on any windows computer, is it possible to write it in a text file and run it as a .bat file?  What language would I have to write it in for it to be able to run?

Thanks!

Link to comment
Share on other sites

Link to post
Share on other sites

It's probably easiest to open up Visual Studio (Code is free), and write a .NET forms/console program.

That way you can create a .exe to run on a Windows machine.

The language would be C# in that case.

 

Alternatively, you can look into Python for example.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, minibois said:

It's probably easiest to open up Visual Studio (Code is free), and write a .NET forms/console program.

That way you can create a .exe to run on a Windows machine.

The language would be C# in that case.

 

Alternatively, you can look into Python for example.

So, I write it on Visual Studio and just save it as a .exe file?  If I were to send it through email to my co-worker would it be able to run?

Yes, I know that sending an executable through email is suspicious.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, JGalsky said:

So, I write it on Visual Studio and just save it as a .exe file?  If I were to send it through email to my co-worker would it be able to run?

Yes, I know that sending an executable through email is suspicious.

You gotta build the application for your project. Default shortcut for that is Ctrl+Shift+B

See the top bar of Visual Studio > Build for more options.

The default location of your .exe will be the path to the project + \bin\Debug

e.g. C:\Users\YourName\source\repos\MyCoolProject\bin\Debug

I don't think anything else was needed together with that .exe, but don't quote me on that.. be sure to try it out.

 

Alternatively, you can convert your program to a website and host it locally.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

C# is hard to learn.

Python is the contrary.

Ryzen 5700g @ 4.4ghz all cores | Asrock B550M Steel Legend | 3060 | 2x 16gb Micron E 2666 @ 4200mhz cl16 | 500gb WD SN750 | 12 TB HDD | Deepcool Gammax 400 w/ 2 delta 4000rpm push pull | Antec Neo Eco Zen 500w

Link to comment
Share on other sites

Link to post
Share on other sites

I know some C, c++, java and some Python, and for me the easiest to learn is Python. There's a guy called freeCodeCamp.org on youtube that offers great tutorials and that's what i'm following to learn python. Alternatively there's c++ , but you'd have to learn some of the basics of lower level programming (i mean, it's not like c,c++ and java are low level, they're just lower than Python). 

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, minibois said:

You gotta build the application for your project. Default shortcut for that is Ctrl+Shift+B

See the top bar of Visual Studio > Build for more options.

The default location of your .exe will be the path to the project + \bin\Debug

e.g. C:\Users\YourName\source\repos\MyCoolProject\bin\Debug

I don't think anything else was needed together with that .exe, but don't quote me on that.. be sure to try it out.

 

Alternatively, you can convert your program to a website and host it locally.

I'll try that out.  But I gotta write the program first hehe

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, SupaKomputa said:

C# is hard to learn.

Python is the contrary.

I know some C already, so that'll help.  But I'll probably end up learning Python eventually anyway.

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Epimetheus said:

I know some C, c++, java and some Python, and for me the easiest to learn is Python. There's a guy called freeCodeCamp.org on youtube that offers great tutorials and that's what i'm following to learn python. Alternatively there's c++ , but you'd have to learn some of the basics of lower level programming (i mean, it's not like c,c++ and java are low level, they're just lower than Python). 

Thanks for the input! I'll definitely be taking a look at that channel.   

Link to comment
Share on other sites

Link to post
Share on other sites

53 minutes ago, JGalsky said:

Hello all! I am new to writing code and would like to get started with some simple programming.  

I want to write a program to calculate the price of a certain object with specific measurements.  I want the program to ask what the width, height, and depth of such product and give me a price depending on what input I give it.  

Here's my question, I want to be able to run it on any windows computer, is it possible to write it in a text file and run it as a .bat file?  What language would I have to write it in for it to be able to run?

Thanks!

This may sound over simplified, but why not just create a MS excel spreadsheet and have it perform the calculations for you based on user input.

 

Just save the spreadsheet and any Windows PC with office will be able to run it...below is just a very simple, stupid example but you should be able to create something more complex that looks a lot better.

 

image.png.f812bb5a6d18573287c7916b0516b865.png

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, steelo said:

This may sound over simplified, but why not just create a MS excel spreadsheet and have it perform the calculations for you based on user input.

 

Just save the spreadsheet and any Windows PC with office will be able to run it...below is just a very simple, stupid example but you should be able to create something more complex that looks a lot better.

 

image.png.f812bb5a6d18573287c7916b0516b865.png

This is the perfect sort of thing for excel or if you really want to use a programming language then a html form with javascript to do the calculations 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, vorticalbox said:

This is the perfect sort of thing for excel or if you really want to use a programming language then a html form with javascript to do the calculations 

Plus you can use another sheet to make a simple quotation report right away without any hassle.

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, JGalsky said:

Hello all! I am new to writing code and would like to get started with some simple programming.  

I want to write a program to calculate the price of a certain object with specific measurements.  I want the program to ask what the width, height, and depth of such product and give me a price depending on what input I give it.  

Here's my question, I want to be able to run it on any windows computer, is it possible to write it in a text file and run it as a .bat file?  What language would I have to write it in for it to be able to run?

Thanks!

For a complete beginner, my advice would be to go with either Javascript or something like Go (golang)

 

For Javascript, you can basically start by making a basic HTML file and placing in that a javascript portion :

 

<html> 
 <head>
  <title> Title of the page </title>
  </head>
<body>

  Number 1: <input id="number1" type="number" value="100" /><br />
  Number 2: <input id="number2" type="number" value="10" /><br />

  Sum: <input id="sum" type="number" value="" /><br />

  <button onclick="javascript:calculate();"> Print sum </button>
  <!-- when clicking button, browser goes to calculate() and does what's written inside that javascript function -->
  
  <script type="text/Javascript">

// this is a comment line. Anything you write between < script > and < / script > 
// tags is interpreted by browser. 

console.log("This text will show up in Console. (press Ctrl+Shift+I)")

// you can read numbers from a form on your html page and do stuff with them 

// ex. Above the script tag, you could have 
// <input id="number" type="number" value="100" />
//
// you can get the contents from that input box and put it in a variable called a:

var a = document.getElementById('number').value 


function calculate() {
  var x = document.getElementById('number1').value
  var y =  document.getElementById('number1').value
  document.getElementById('sum').value = x + y
  
}

</script>
</body>
</html>

Benefit of Javascript is that you can simply open the HTML file anywhere and do stuff, no need for executables.

 

As for Go, it's a super simple programming language to learn and do stuff quickly in it, as long as you're fine with command line applications (text only). Making programs with visual interfaces is a bit more difficult. But basically, for your needs, you could edit a text file with the data you need, save, then run your program which reads the data from text file, does calculations and then prints the results to another text file or makes a pretty html file or anything you want. 

 

You can use Visual Studio Code to write the programs, or even notepad. VS Code is free and lightweight (other than disk space, a few hundred mb). 

 

You can make executables (as simple as typing go build program.go and you get program.exe)  but you can also just run them from the source code just as easily ( go run program.go in command prompt / powershell / bash etc)

 

Here's a very good tutorial, watch the first 30 minutes or so and see if it's easy enough for you :

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, steelo said:

This may sound over simplified, but why not just create a MS excel spreadsheet and have it perform the calculations for you based on user input.

 

Just save the spreadsheet and any Windows PC with office will be able to run it...below is just a very simple, stupid example but you should be able to create something more complex that looks a lot better.

 

image.png.f812bb5a6d18573287c7916b0516b865.png

I like your post, simple but elegant.  A lot of people seem to overlook the power of a spreadsheet.  You can do so much stuff in excel (in a such an easy to understand way).  [Having written a few inhouse programs now, I can say I write more excel "programs" than regular programs for work; mainly because it has a good interface, it can do what is needed (and can be enhanced with VBA), and in general I find it easier for the end user to accept]

3735928559 - Beware of the dead beef

Link to comment
Share on other sites

Link to post
Share on other sites

As someone who programming in C# for over 8 year. I find C# easy to learn when moving from C.  Here want to do in C#  click on publish. When it done go to that folder, zip the folder up then send to your co-worker. The folder can be renamed, but he will need all the DLL and EXE. He just open the program but click on the EXE.  If you use .NET Core it should run on Windows, Linux, Mac. 

 

I have just by zip up EXE you get not problem with email it.

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, A51UK said:

As someone who programming in C# for over 8 year. I find C# easy to learn when moving from C.  Here want to do in C#  click on publish. When it done go to that folder, zip the folder up then send to your co-worker. The folder can be renamed, but he will need all the DLL and EXE. He just open the program but click on the EXE.  If you use .NET Core it should run on Windows, Linux, Mac. 

 

I have just by zip up EXE you get not problem with email it.

Then you have the issue of transferring binaries over email, which is probably fine but also an attack vector (out of scope for this post)

 

HTML and javascript has the benefit of working on any device with a browser.

 

Can even host it for free on github pages if you really wanted.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
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

×