Dwedit's Board

Enjoy the board

You are not logged in.

Announcement

Welcome, fellow visitors from other websites!
Whenever you download a file, I'd appreciate it if you posted a nice "Thank You" message, then tell me which site you came from. Thanks.
- Dwedit

#1 2005-12-22 8:02:21 pm

Vash The Stampede
Don Flamenco
Don Flamenco
From: Philadelphia Area
Registered: 2004-12-16
Posts: 253
Website

Basic Programming

Basic as in simple.  I'm trying to create an IF statement and having a lot of trouble.  I want it to be IF 1<B<5, but it won't let me have the two signs.  Also, how can I have it so only integers are allowed to be entered into prompts and inputs?


http://forums.reg-exp.org

It's a small, fun forum.  If you'd like an invite, e-mail me.

Offline

#2 2005-12-23 12:52:51 am

Quietust
Pierce Brosnan
Pierce Brosnan
Registered: 2004-12-13
Posts: 91

Re: Basic Programming

1. IF 1<B AND B<5

2. Depends on the calculator. On the 85, you can't force it to accept only integers (you either tell it to accept numbers or strings; for the former, it'll evaluate it as an expression and 'crash' if you give it a bad input), though the later calculators probably allow you to be more strict.


* Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

Offline

#3 2005-12-23 3:53:40 am

leofox
Don Flamenco
Don Flamenco
From: Balmora
Registered: 2004-12-23
Posts: 262

Re: Basic Programming

Also, how can I have it so only integers are allowed to be entered into prompts and inputs?

Repeat X=int(X
Prompt X
End

This will keep on doing prompt until X is integer. You can add stuff like a message to tell you to only add integers if a non integer value is inputted, or ClrHome to clear the screen every time it asks again (so your screen doesnt get flooded with 'X?')

Offline

#4 2005-12-23 8:18:51 pm

Quietust
Pierce Brosnan
Pierce Brosnan
Registered: 2004-12-13
Posts: 91

Re: Basic Programming

On the older calculators (85, 86), you can't reference undefined variables, so you need to resort to something like this:

Prompt X

While X≠int(X
Prompt X
End

* Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

Offline

#5 2005-12-24 3:02:31 am

leofox
Don Flamenco
Don Flamenco
From: Balmora
Registered: 2004-12-23
Posts: 262

Re: Basic Programming

nah, you can always use 0->X before doing the repeat loop, to define that variable.

Offline

#6 2005-12-24 5:34:41 pm

Quietust
Pierce Brosnan
Pierce Brosnan
Registered: 2004-12-13
Posts: 91

Re: Basic Programming

In that case, 0.1->X would work a bit better, but the overall effect is the same (though it'd take a few more bytes of code).


* Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

Offline

#7 2005-12-25 1:45:43 am

leofox
Don Flamenco
Don Flamenco
From: Balmora
Registered: 2004-12-23
Posts: 262

Re: Basic Programming

if you use Repeat it'll run at least once anyway. Repeat only checks at the end of the loop, so by then X will already exist.

Offline

#8 2005-12-29 8:49:09 pm

Vash The Stampede
Don Flamenco
Don Flamenco
From: Philadelphia Area
Registered: 2004-12-16
Posts: 253
Website

Re: Basic Programming

I have an 83+ and I'm just finding something to do during math class.  I'll definitely try these after I'm tired of my PSP.


http://forums.reg-exp.org

It's a small, fun forum.  If you'd like an invite, e-mail me.

Offline

Quick reply

Write your message and submit

Board footer

Powered by FluxBB