Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AHHHHH... Young BASIC programmer in need of HELP!

AHHHHH... Young BASIC programmer in need of HELP!
Thread Tools
Forum Regular
Join Date: Jan 2001
Location: Maryland
Status: Offline
Reply With Quote
Jul 6, 2001, 08:12 PM
 
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
Reply With Quote
Jul 7, 2001, 02:11 PM
 
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
Reply With Quote
Jul 8, 2001, 07:26 AM
 
Yes... I know that... it still won't work. Everything is positive unless the random command goes from a negative number to the positive random, (ie. -10,10 instead of 1,10 or 0,10) It's based on an RPG. I need to subtract health when you attack an enemy... PLEASE HELP. SOMEONE MUST have had this problem before!

Thanks for the suggestion.... but it still doesn't work
     
Forum Regular
Join Date: May 2001
Location: Hong Kong
Status: Offline
Reply With Quote
Jul 8, 2001, 02:59 PM
 
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
Reply With Quote
Jul 9, 2001, 10:28 PM
 
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
Reply With Quote
Jul 14, 2001, 01:11 PM
 
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
Reply With Quote
Jul 14, 2001, 08:32 PM
 
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"
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:08 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2