Back to Basic
Moderator: Mike Everman
Back to Basic
With all the IT security dance, anti-viral stuff doesn't appear to be the least bit concerned with BASIC. So I decided to transfer some of Forrest code (from the topic: the hunt for an easier way) into a program called Just Basic v1.01
Appears to be working fine, not sure how to dress up the units to print correctly.
The included text file contains the code that can be readily copied into a .BAS file
Appears to be working fine, not sure how to dress up the units to print correctly.
The included text file contains the code that can be readily copied into a .BAS file
- Attachments
-
- code.zip
- (877 Bytes) Downloaded 373 times
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
Neat. I haven't programmed in BASIC since ... forever.
Sorry to read you cannot run my JavaScript program.
I'll look into your 'units issue' later today if someone doesn't beat me to it.
Sorry to read you cannot run my JavaScript program.
I'll look into your 'units issue' later today if someone doesn't beat me to it.
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
Hi Joe,
Here are just a few words (159 to be exact).
1. My basic interpreter did not like this line at all:
Please change to atn(1.0). The argument, which is not critical here, should be a float and not an integer value.
2. These lines do not sub- and super-script in my terminal window. They are just printed literally.
The <sub></sub> and <sup></sup> tags are html.
To get the point across, just use lbm and lbf and in^2 , in^3 , and in^4.
Here are just a few words (159 to be exact).
1. My basic interpreter did not like this line at all:
Code: Select all
9 pi = asn(1) * 2
2. These lines do not sub- and super-script in my terminal window. They are just printed literally.
Code: Select all
29 print "Young's modulus, E: " ; E ; " lb<sub>f</sub>/in<sup>2</sup>"
30 print "density: " ; rho ; " lb<sub>m</sub>/in<sup>3</sup>"
...
34 print "1st moment of inertia: " ; I ; " in<sup>4</sup>"
35 print "mass per unit length: " ; m ; " lb<sub>m</sub>/in"
To get the point across, just use lbm and lbf and in^2 , in^3 , and in^4.
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
One thing I couldn't do in JavaScript was file I/O for all platforms. I could in IE, but I decided against the whole idea since I wouldn't want a rogue javascript accessing (reading and writing) to my hard drive.
I now understand why numerous viruses attack µSoft machines through Internet Explorer.
However, since you are now using BASIC, you can use the command
to dispense with typing in those five parameters from the keyboard and just make the program read them from a file.
I now understand why numerous viruses attack µSoft machines through Internet Explorer.
However, since you are now using BASIC, you can use the command
Code: Select all
OPEN O|I|R, [#]device-number, file-name [,record length]
file-name FOR INPUT|OUTPUT|APPEND AS [#]device-number [LEN = record-length]
Re: Back to Basic
Thanks for the help,
Will update the code and repost in a few days. I kind of like the manual input of the parameters, small price to pay.
Thanks for doing the heavy lifting and posting your original code, will be following along.
Will update the code and repost in a few days. I kind of like the manual input of the parameters, small price to pay.
Thanks for doing the heavy lifting and posting your original code, will be following along.
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
No problem. I'm glad to read you found it 'interesting'.
Re: Back to Basic
More than interesting,
Petal valves have been a primary component in small valved engines for decades. Advances in efficiency, valve life, as well as a basic understanding in operating parameters would surely be welcome.
Petal valves have been a primary component in small valved engines for decades. Advances in efficiency, valve life, as well as a basic understanding in operating parameters would surely be welcome.
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
I moved this thread from the 'off topic' thread to here, where I think it properly belongs.
Re: Back to Basic
Thanks for moving this topic Forrest,
For some reason my BASIC program is producing a different output with atn(1) for pi. Probably some default in the settings I need to update.
For some reason my BASIC program is producing a different output with atn(1) for pi. Probably some default in the settings I need to update.
- Attachments
-
- pi.JPG (19.65 KiB) Viewed 10904 times
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
Let's review some trigonometry.
sin(π/2) = 1.0 so arcsin(1.0) = π/2
tan(π/4) = 1.0 so arctan(1.0) = π/4
So, your last number is π/4.
My basic interpreter can only do arctan's so I had to use the definition in my original coding
... but you knew that.
sin(π/2) = 1.0 so arcsin(1.0) = π/2
tan(π/4) = 1.0 so arctan(1.0) = π/4
So, your last number is π/4.
My basic interpreter can only do arctan's so I had to use the definition in my original coding
Code: Select all
var pi = 4.0*Math.atan(1.0)
Re: Back to Basic
Thanks, that's got it...maybe
- Attachments
-
- code2.zip
- (863 Bytes) Downloaded 378 times
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
Hmm ... looks like you're off a little with my posted system resonant frequency.
'Continuous beam' is okay, but you begin to deviate when you calculate the 'Lumped Mass' partial system frequency. Check for a typo there.
'Continuous beam' is okay, but you begin to deviate when you calculate the 'Lumped Mass' partial system frequency. Check for a typo there.
-
- Posts: 887
- Joined: Wed Dec 24, 2003 12:12 pm
- Antipspambot question: 0
- Location: France
- Contact:
Re: Back to Basic
Or a floating point error. For all of this, you'd both be better served using languages that can do arbitrary precision maths. Just saying, like.
Re: Back to Basic
May need more digits after the decimal on the inputs, input4 especially.
input1 .7526
input2 .0777
input3 .006
input4 .457
input5 .0567
input1 .7526
input2 .0777
input3 .006
input4 .457
input5 .0567
-
- Posts: 3716
- Joined: Tue Dec 07, 2004 6:51 pm
- Antipspambot question: 0
- Location: 41d 1' N 80d 22' W
Re: Back to Basic
I don't think it's a floating point error. BASIC is pretty accurate (no double precision, though, like FORTRAN) right out of the box.
Your numbers, even intermediate ones, match mine almost digit for digit for the 'continuous beam' calc.
Something is different between my program's calculation and yours for the 'lumped mass' case. This will of course, 'throw off' the final computation.
I'll take a look at your code between now and tomorrow. You really should try and match my numbers.
However, we are only accurate to 3 significant figures, so, technically, fs = 252 Hz is as accurate as we can get.
Your numbers, even intermediate ones, match mine almost digit for digit for the 'continuous beam' calc.
Something is different between my program's calculation and yours for the 'lumped mass' case. This will of course, 'throw off' the final computation.
I'll take a look at your code between now and tomorrow. You really should try and match my numbers.
However, we are only accurate to 3 significant figures, so, technically, fs = 252 Hz is as accurate as we can get.