 |
 |
AHHHHH... Young BASIC programmer in need of HELP!
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: Maryland
Status:
Offline
|
|
 grrrrrrrrrrr  ...... I can't get thisa one piece of code to work. It's a rather large block and since it's on a PC and I have no floppy drive I can't get it on my mac so I'll just describe my problem. I have a number of command operators dealing with simple equations. Such opperators as + and - are used. = is also used. My problem comes when I place a command such as
A=B-C
PRINT A
in this command, the computer adds b and c together instead of subtracting them. I tried fliping the sign (ie. +=- and -=+) but it still added. I'm sure that this is something that I'm missing just because I'm new at this. If any of you can help..... PLEASE, PLEASE DO!
Regards;
Andy Polack
A.L.P.S.
Andy Lyon Polack Studios
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: May 2001
Location: Hong Kong
Status:
Offline
|
|
If C is a negative number, then subraction is equal to addition.
Check the value of C.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: Maryland
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: May 2001
Location: Hong Kong
Status:
Offline
|
|
What are the values of B and C? If B and C are so large, that will cause overflow error, as a result of incorrect answer.
Also, if B and C are different data types, that will cause incorrect answer also.
What BASIC compiler/interpreter do you use?
I do not have any problem when I use Chipmunk BASIC to write programs.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: In a van down by the river
Status:
Offline
|
|
Well, you might want to confirm that the variables A, B & C are declared as numbers (int, long, etc..).
Perhaps if you displayed an actual code sniplet we could get to the root of the problem.
What development environment are you using? VB?
If it's VB then the following code should work:
Sub Simple_Math()
Dim A As Integer
Dim B As Integer
Dim C As Integer
B = 5
C = 10
A = 0
A = B + C
Debug.Print A
End Sub
|
|
respect mah athoritah!
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: Maryland
Status:
Offline
|
|
NOTE: Please feel free to e-mail me about this, I don't check this forum too often so it might take me a while to get back to you if you leave your message here!
I use DarkBASIC (http://www.darkbasic.com/) . I am just learning it and I'm sure that it's some dumb error at the root of my code. Problem is... it's on a PC and I only have an internet connection on my Mac. Furthermore, I never bothered to get a floppy drive for it so I can not transfer files. The equation is in an If Then command (however, I tend to make it an if, endif command instead.) The overflow is a possabilty but the numbers that I'm dealing with start at 100 and 80. I do a standard declair... (ie, a=100... b=80) Then I declair the battle function... (battle
Prehaps you can help me with another problem I have. I use the gosub and return commands and the program exceutes without a glitch, but after one or two user commands have been input, the CLI comes up and tereminates the program. If anyone knows how to deactivate the CLI, that would also be helpful.
DarkBASIC allows you to program in Direct3D while useing BASIC, could this be part of the problem? Am I attempting to do 2D in a 3D only app? Thanks for your continued help and support.
Andy Polack
A.L.P.S.
Andy Lyon Polack Studios
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: Maryland
Status:
Offline
|
|
Sorry to double post, solved the problem... in return for ANOTHER one. Is it just me, or do all programmers go through this hell? The below is a copy of a message that I left in the OSX Developer forum. I left it there as well since I plan on programming for both PC and OSX (come on now.... I'm a loyal Mac fan, if it comes to the PC it's got to be on the Mac too!) So here it is... my next problem..... (and if u get luckey... I'll actually get a copy of my poor script work down here soon! Just got a zip drive!
"OK.. thanks for the help.... I had to use a dec command as it turned out. Boy, do I feel dumb. PLEASE give me a break about useing BASIC, it's the only one that I can get my hands on cheap and get alot of help online.
NEWSFLASH: WHAT A SUPRISE, I HAVE ANOTHER PROBLEM AND THE CODE IS ON MY PC UPSTAIRS
PLEASE help with this one too! I have everything working except for one if then command, I have checked the command over and over again, but I can not get the computer to recconize that there is a command there. Might it have something to do with the fact that it is inside of about 5 other if, then commands? Or is it the fact that I leave off the "then" and simply place at the end, an "endif" command. Or is it something else? I need bigtime help here and I feel cheap asking you all, but even the guy from Pangeasoft can't help me..... (I instant messaged him and asked him if he knew BASIC, responce, "haven't touched it in 20 years."
Regards,
Andy Polack
A.L.P.S.
Andy Lyon Polack Studios"
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|