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.

AppGameKit Chat / App Game Kit V108 Beta 8 - Over 200 New Commands

Author
Message
JimHawkins
7
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 21st Jan 2014 19:08
Personally I think it's ghastly!

Can you be sure that TRUE is 1? It could be any non-zero value.

-- Jim - When is there going to be a release?
IBOL
Moderator
13
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 22nd Jan 2014 00:40
this one we're discussing in another thread is much worse. I can re-write equate lines. this seems completely a BUG.

I keep getting this error:

array accessed with too few subscripts



But my arrays are properly dimensioned just like they have been for 6 months.

Dim m[100] as MonsterMaster

with monster master big and long but properly defined.

Ancient Lady
13
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 22nd Jan 2014 17:25
Quote: "n=rnd(3,9)*10 * (1+ ( ( rnd(0,6) * (Rnd(0,66)=33) ) ) )"

This is basically not correct programming.

I am assuming that you expect this bit '(Rnd(0,66)=33)' to return 0 or 1. And it doesn't work that way in any language that I know when presented that way.

Maybe you mean to use '(Rnd(0,66)=33?1:0)'. This is the proper way to use boolean logic within an mathematic equation.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Scary Little Rabbit
7
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 31st Jan 2014 17:56
sometimes I also use it this way:
+ Code Snippet

error #1:
"too many stars, too many stares. disembody."
WIP: MIND!! | free fonts for your AGKs
Marl
5
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 2nd Feb 2014 12:26 Edited at: 2nd Feb 2014 12:27
The logic is sound
Quote: "This is basically not correct programming."

I have to disagree, I think this comment is a little unfair and overly critical.
Quote: "I am assuming that you expect this bit '(Rnd(0,66)=33)' to return 0 or 1. And it doesn't work that way in any language that I know when presented that way."

The statement is perfectly valid in a number of languages.
Quote: "Maybe you mean to use '(Rnd(0,66)=33?1:0)'. This is the proper way to use boolean logic within an mathematic equation."

Perhaps in a world where every language is C. But in our world, the real one, (Rnd(0,66)=33) should return true or false.

The only variation is what constitutes True, traditionally this had been -1, but AppGameKit uses 1.

Over 30 years ago, I was introduced to such Boolean coding with the simple statement;

x = x + ( key = left ) - ( key = right )

which is as valid today as it ever was.
JimHawkins
7
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 2nd Feb 2014 13:36
personally, I think it's ghastly, dangerous programming!

-- Jim - When is there going to be a release?
Ancient Lady
13
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Feb 2014 20:24 Edited at: 2nd Feb 2014 20:44
Quote: "I have to disagree, I think this comment is a little unfair and overly critical."

It wasn't my intent to be either. It was meant to indicate I didn't think it was correct.

Quote: "
The statement is perfectly valid in a number of languages."

'(Rnd(0,66)=33)' is valid in any language that uses '=' as equality in logic statements. In other languages it would be '(Rnd(0,66)==33)'. But in any case, it is not used to return a numerical value in an equation. It should not be assumed that 'true' is one and 'false' is zero.

Quote: "Perhaps in a world where every language is C. But in our world, the real one, (Rnd(0,66)=33) should return true or false."

Yes, I am aware of that and have used it in logical things frequently.

But the code is using it in a math formula.

'(Rnd(0,66)=33?1:0)' is valid in AppGameKit Basic, Perl, C, Javascript, Java, PHP and lots of languages. But note that the first one I listed is AppGameKit Basic.

Since the issue the poster mentioned was not getting the correct numeric results, I was pointing out a possible problem with how he was trying to get the results.

And, even though it might work, as JimHawkins says, it is dangerous programming.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
JimHawkins
7
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 2nd Feb 2014 23:16 Edited at: 2nd Feb 2014 23:16
AFAIK there is no requirement for any language to maintain an arithmetical value for truth or falsity. The idea that there is a "real world" where true is always 1 and false is always 0 is nonsensical.

Add to this the fact that most compilers will stop evaluating an expression when the result is known makes doing arithmetic on Boolean values even more prone to produce inexplicable bugs. And to what end? To produce a clever-looking compressed line of code. Modern compilers are quite capable of efficient compression of statements without the kind of tricks which have caused banking systems to fail and aircraft to fall out of the sky because of their reliance on false assumptions.

-- Jim - When is there going to be a release?

Login to post a reply

Server time is: 2017-06-25 09:46:59
Your offset time is: 2017-06-25 09:46:59