Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Advance Logic & Arithmetic upgrade pack for Dark Basic

Author
Message
PeteyM5
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 3rd Jan 2010 20:28
I know the subject of having an Elseif statement be useful for Dark Basic to help tidy up code. But it would make a good upgrade pack to include some additional logic and math structures.

I know DB has Repeat...Until, but add While...End also.

Add Sgn() also.

I am sure people on here can make a few suggestions. Adding some commands will make programming easier.

Adding these things would make it easier to port code over the Dark Basic from other Basics like Visual Basic or Pure Basic.
Kryogenik
16
Years of Service
User Offline
Joined: 22nd Sep 2009
Location: Heidelberg, Germany
Posted: 3rd Jan 2010 20:47
I think DBPro has While and Endwhile already. The subject of an Elseif statement has been a hot topic, but has far as I know, TGC doesn't plan to change DBPro's core language. What is Sgn, anyway? But would be cool.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Jan 2010 21:35
DO / LOOP (and EXIT)
IF / ELSE / ENDIF
REPEAT / UNTIL
WHILE / ENDWHILE
FOR / NEXT / STEP
GOTO
GOSUB
CASE / ENDCASE

If you want extra raw functionality, Matrix Utils has most of it

PeteyM5
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 3rd Jan 2010 22:34 Edited at: 3rd Jan 2010 22:44
SGN (Sign) returns 1 if a number is positive, -1 if negative, and 0 if 0. Common in other versions of Basic.

I thought about a setting that returns all SIN and COS results as degrees rather than Radians. I remember the old Atari 8-bit basic had DEG and RAD to do that setting. I am not sure if DB has ArcSine, ArcCosine, and ArcTangent, but if we do all sorts of 3D calculations, that also helps.

I checked the Matrix Command List. Dark Basic also does not have ABS?
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 3rd Jan 2010 23:09
I am 100% sure DB has ABS (haha). Try typing it into the editor.

It also has inverse sine calculations: ASIN, ATAN, ACOS.

DB does not have SGN by default, but the Matrix1 dlls do.

Mr Lewis
16
Years of Service
User Offline
Joined: 28th Dec 2009
Location: East Midlands UK
Posted: 4th Jan 2010 01:21
why not just write a simple logic statement to find the sign?

like:

(I know it's dodgy code, I'm using GOTO, and to be fair you'd be better off using SELECT, but I'm only just getting back into DBPro)
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jan 2010 01:38
Quote: "I thought about a setting that returns all SIN and COS results as degrees rather than Radians."


Quote: "Dark Basic also does not have ABS?"


I suggest you find out what the existing DBPro commands do first.
PeteyM5
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 4th Jan 2010 03:04 Edited at: 4th Jan 2010 03:12
yes, ASIN, ATAN, ACOS are there, I must have been thinking about earlier versions of basic.

I am in the process of developing a game that I started in Visual Basic many moons ago and feel Dark Basic has more of what is needed to make things work for it.


I see all the trigonometric functions in degrees rather than radians. I thought all versions of Basic defaulted to radians. Dark Basic is not ordinary Basic. Something that always confused me about Visual Basic is who really uses Radians in the real world. However it would be nice to have a setting to control that.
gbark
20
Years of Service
User Offline
Joined: 14th Oct 2005
Location: US - Virginia
Posted: 4th Jan 2010 06:18 Edited at: 4th Jan 2010 06:19
Mr Lewis, even better than using any sort of conditionals would be to simply use greater-than and less-than logic operators.


I would definitely like to see ELSE-IF, however. I can't think of too many other logic operators I could use that aren't already available. With the basic AND NOT OR etc, math operators, and bitwise shifts, those should be able to handle the majority of simple logic operations you'd need.
PeteyM5
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 10th Jan 2010 18:56 Edited at: 10th Jan 2010 19:04
I should have taken a more detailed look at the help index. I and many others would like to see Elseif to help streamline our code. SGN (Sign) be a nice addition also, I see may programmers have to add a function to do the same job. The other logic update I can think of is Exclusive Or (XOR or EXOR).

I know Select Case can be used in its place, but be nice if it did not require ENDCASE after each CASE statement and be able to do combinations and ranges like 1 to 5 or 1,3,5. It may do these things already, but it is not listed in the help.

By the way, how would you install those matrix command functions anyway? There are several broken links on those pages.
sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 10th Jan 2010 19:31 Edited at: 10th Jan 2010 19:43
I too hate the case/endcase statements they add many lines to your code with lots of indents just to do simple comparisons. I usually just do seperate lines with if..thens although it's not really good programming practice.

You can use else if on single line statements easily enough:


Also, I consider IanM's matrix utils to be `part` of dbpro anyway, if you're not using them you're making life (and programming!) a lot harder... Link is at the bottom of any of his posts.
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Jan 2010 19:57
i use xor to encrypt network messages in my multiplayer games.

Altho am not sure off hand if its a native command or one from IanM's plugin.

BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 10th Jan 2010 21:50
Quote: "The other logic update I can think of is Exclusive Or (XOR or EXOR)."

xor is native to DBP. You really ought to try these before claiming they don't exist.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jan 2010 23:41
Quote: "By the way, how would you install those matrix command functions anyway? There are several broken links on those pages. "

Follow the first link in my signature, or if you can't find a post from me in future, you can simply look for the thread in the DLLs forum - it's usually near the top.

The only thing I really use my old site for is to hold a copy of the help files for my plug-ins, so you can see what you are getting before you install (that's the second link) so don't bother looking for anything else there. One day I'll make time to clean it up.

PeteyM5
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 24th Feb 2010 22:53
Using Dark Basic Steadily for the last for months working on my game, I realized there may be still some tweaking to the core language.

Adding ElseIf and SGN() be a good start. I came to realize there is nothing there to format the display for numerics, leading 0s, fixed decimal places, leading money symbol, etc. Maybe Print Using be a cool addition also. I see Mid$ is primitive and can just look at a single character.

I mentioned a tweak to Select, Case, EndCase, EndSelect Structure, and that is with using combinations like CASE 1,2,3 or CASE 1 and b=17 or CASE 1 to 50.

I know Dark Basic is geared toward Game and Graphics applications, but I come across situations where having some of these things make a Game easier to program.

I can make a function to simulate Print Using.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 25th Feb 2010 01:55
on a side note, a ternary operator would be nice, though it's easy enough to make a function to do it yourself.

Just in case you missed the meaning of green gandalf's comment...
Quote: "I thought about a setting that returns all SIN and COS results as degrees rather than Radians."

sin and cos do not return angles, and therefore the results are the same if you use the same angle whether it's in degrees or radians (in the same way that you wait the same time whether time is in units minutes or hours).

degrees/radians issues only come into play in the input of standard trig functions, and the output of inverse standard trig functions.

Quote: "is who really uses Radians in the real world"

Radians make a lot more sense mathematically. Why use a scale that goes from 0 to some arbitrary number, and ignore what is an integral part of the circle (pi)? A lot of the time, if you have something like 1/8*pi radians, that makes things a lot simpler than say 13 degrees. Basically, it makes more sense mathematically, and it could be considered more "elegant".


Login to post a reply

Server time is: 2026-07-28 15:38:39
Your offset time is: 2026-07-28 15:38:39