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.

Newcomers DBPro Corner / Variable = -Variable , Darkbasic cannot handle it!

Author
Message
yerrel
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Planet Earth.. :-)
Posted: 9th Sep 2003 19:07


Why can't DARKBASIC handle the following statement:
Let's say:

if x<=0 or x>=608 then ax=-ax

So the problem is that with 'ax=-ax' or something else that have 'Variable=-Variable' darkbasic give the error: 'Syntax Error Unrecognised Parameter at line xxx'

Variable = -Variable is a legal statement in DarkBasic Pro, Blitz Etc.. So why not in DarkBasic?

So is there another way to do this?

Thanks,

Yerrel
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Sep 2003 19:45
so you are saying that X+=1 is the same as x=x+1 in dbpro??
I never knew that.

-RUST-
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 9th Sep 2003 19:50
No he's not saying that. He's saying that you can't use that syntax to make a positive value negative or a negative value positive.

You can either use...

var = 0-var

or

var = var*-1

The latter is faster on my computer.

Brains are for idiots.

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 9th Sep 2003 20:09
Quote: "Variable = -Variable is a legal statement in DarkBasic Pro ... So why not in DarkBasic?"


Seems obvious. DBPro is newer.

Theres no place like 127.0.0.1
There are 10 people in this world, those who understand binary and those who don't
Bus station = where bus stops. Train station = where train stops. Workstation = ?
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Sep 2003 20:28
oh, ok. I was gonna be re-pissed off about the help files again if I found out that you can use .net syntax like X+=1 because I didn't see that anywhere.

Why o why can't select-case statements check ranges like other languages?

Select X
case 1 to 10
...
endcase
case 11 to 20
...
endcase
EndSelect

and what's the deal with endcase? it isn't necessary in other languages.



-RUST-
yerrel
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Planet Earth.. :-)
Posted: 9th Sep 2003 23:56
[/quote]No he's not saying that. He's saying that you can't use that syntax to make a positive value negative or a negative value positive.

You can either use...

var = 0-var

or

var = var*-1

The latter is faster on my computer.

Thanks Hamish McHaggis,

Ur the one who helped me out

Best regards,
Yerrel

ABIT NF7-S V2.0, AMD XP1700+ @ 2300MHz ) , ASUS gForce4 Ti4200 8XAGP,
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 10th Sep 2003 00:18
's ok

Brains are for idiots.

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Sep 2003 03:05 Edited at: 10th Sep 2003 03:06
Quote: "Why o why can't select-case statements check ranges like other languages?"


'cos it's not other languages! In Java, you can't "LOAD OBJECT..." to import a 3D model.

If all languages were like other languages...well, we'd only have one language

However...I have noticed you can no longer check against a variable, which you could in classic

e.g


The second case is not allowed in Pro, it is in Classic.

yerrel
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Planet Earth.. :-)
Posted: 10th Sep 2003 03:33
[quote]Why o why can't select-case statements check ranges like other languages

I think this topic can be closed now, coz my question has already been answered.

Thanks to all who have given me an helping hand, especialy:

Hamish McHaggis.

I won't be reading this topic anymore..

All the best..

Thanks guys..

Yerrel

ABIT NF7-S V2.0, AMD XP1700+ @ 2300MHz ) , ASUS gForce4 Ti4200 8XAGP, 2x256Mb Dual Channel .... Still using DARKBASIC PRO. TRIAL :-(( .. coz i am still saving the EURO's... to buy me the Pro.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th Sep 2003 04:22
@ stevieVee:

Like I need you to explain to me that DBP is not "other" langs
All I am saying is that it would be tremendously useful in select-case to be able to test ranges! Most modern versions of, yes, BASIC, can do this! I am sick of people defending dbp's glaring shortcomings and saying "it's BASIC not VB" or whatever. That's just retarded. Do you people still use candles or do you use electricity for light?

Stop defending the problems and improve the language - It's already a great product - it just needs to be refined - and remember this is all IMHO!!

-RUST-
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 10th Sep 2003 09:02
var= 13
print var*-1

Hamish this does print -13 just as you indicated.

Exactly what is this *-1 command doing?
What is it called, and where is it documented?

The more you see, the more you know.
The more you know, the more you see.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 10th Sep 2003 17:06
umm! read it again, its a negative number, multiply minus 1 by the number you had and you change the sign, the other way is to subtract it from zero to get the negative value, try these on a calculator

-1*5=-5 <<<this is same as 5*-1=-5
0-5=-5

same result, different methods, cheers.

Mentor.
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 10th Sep 2003 17:58
DOOOOOH!

Thanks Mentor, I didn't recognize that.

The more you see, the more you know.
The more you know, the more you see.
=C=
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 10th Sep 2003 19:32
a=-variable is half an operator. not many languages I know of recognise this.

+ - / * are operators and they need two parts. a + b or a - b etc.

a+=b is a widely acceptable C shortcut and many languages cater for it.
Anyway BD caters for that with the inc a, b function even if it is not C like.

a = variable * -1 is a proper orthodox operator use.

Now if DBPro support a=-a, well... thats the last thing DBPro needs to support and I am surprised they do because i never even thought of using this call.

-------------------------------
Pointy birds, Oh pointy pointy
Anoint my head, Anointy 'nointy
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Sep 2003 20:01
CattleRustler: If you use negativity like "Why o why " and "What's the deal with" you will get a defensive answer.

Try this...
CattleRustler: It would be good if TGC could extend the CASE statement to include ranges. I've seen this in other languages and it makes programming a whole lot easier.

Me: Yes, it would.

Then you wouldn't have to call your fellow forum members retarded

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th Sep 2003 20:56 Edited at: 10th Sep 2003 20:57
I didn't call anyone retarded, I referred to the "way of thinking" as retarded. I apologize if I come off too strong sometimes but I am just passionate. I see we agree though, that's good

It's just frustrating to see such small, simple things missing from what is otherwise an awesome product.

hopefully no hard feelings


-RUST-
ChipOne
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 10th Sep 2003 22:24
the sizzle sells the steak. try to enjoy your meat without minding the fact they forgot to drizzle lemon juice on the plate.

no excuse, that's for sure, but tgc has had to concenrate on the 'otherwise an awesome product' parts in order to lure you in here. there are shortcomings, deficiencies and workarounds in every language and products (otherwise i wouldn't have a job) and they are trying to work through them.

in the instance of the select range, you could always try hashing your numbers down, or use an interim step to evaluate the variable prior to the select, or better yet, encapsulate logic to be reused in functions.

the easiest solution would be to just use compound nested ifs. when it comes down to it, selects and ifs look identical in machine code and perform no differently.

cheers.

-= i only do what my rice krispies tell me to do =-
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Sep 2003 23:02 Edited at: 10th Sep 2003 23:05
CattleRustler: No hard feelings. I'm also passionate about what I do (which isn't DB in the main), but it's often hard to express yourself correctly in a forum.

I run my own business, so I tend to be over-protective of other people trying hard to make good products.

I hope you appreciate my rewrite of your idea. Believe me, positive attitude makes a huge difference, and gets you respect. I'm not trying to patronise, it's very true.

I should listen to my own advice sometime!

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th Sep 2003 23:33


-RUST-

Login to post a reply

Server time is: 2024-11-25 06:28:51
Your offset time is: 2024-11-25 06:28:51