Back to Basic

Moderator: Mike Everman

Post Reply
PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Back to Basic

Post by PyroJoe » Wed Nov 11, 2009 5:30 pm

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
Attachments
screenshot.JPG
code.zip
(877 Bytes) Downloaded 373 times

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 12:15 am

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.
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 12:16 am

Hi Joe,

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
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.

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"
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.
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 12:17 am

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

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]
to dispense with typing in those five parameters from the keyboard and just make the program read them from a file.
Image

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Re: Back to Basic

Post by PyroJoe » Thu Nov 12, 2009 2:03 pm

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.

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 2:56 pm

No problem. I'm glad to read you found it 'interesting'.
Image

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Re: Back to Basic

Post by PyroJoe » Thu Nov 12, 2009 3:07 pm

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.

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 3:38 pm

I moved this thread from the 'off topic' thread to here, where I think it properly belongs.
Image

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Re: Back to Basic

Post by PyroJoe » Thu Nov 12, 2009 3:44 pm

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.
Attachments
pi.JPG
pi.JPG (19.65 KiB) Viewed 10904 times

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 4:19 pm

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

Code: Select all

var pi = 4.0*Math.atan(1.0)
... but you knew that.
Image

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Re: Back to Basic

Post by PyroJoe » Thu Nov 12, 2009 4:50 pm

Thanks, that's got it...maybe
Attachments
code2.zip
(863 Bytes) Downloaded 378 times
atantimes4.JPG

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 8:14 pm

Hmm ... looks like you're off a little with my posted system resonant frequency.

Image

'Continuous beam' is okay, but you begin to deviate when you calculate the 'Lumped Mass' partial system frequency. Check for a typo there.
Image

tufty
Posts: 887
Joined: Wed Dec 24, 2003 12:12 pm
Antipspambot question: 0
Location: France
Contact:

Re: Back to Basic

Post by tufty » Thu Nov 12, 2009 8:30 pm

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.

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Re: Back to Basic

Post by PyroJoe » Thu Nov 12, 2009 10:05 pm

May need more digits after the decimal on the inputs, input4 especially.
input1 .7526
input2 .0777
input3 .006
input4 .457
input5 .0567

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Nov 12, 2009 11:36 pm

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.
Image

Post Reply