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 / global variable inside IF...no reading...

Author
Message
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 20th Jan 2009 18:27
I try to put a global variable inside a IF function, the program not read it...but if i put outside the IF, it show sth...What is going on..



Thanks for your helps...
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 20th Jan 2009 19:03
Uhm... your snippet reads STARTPOINT(I) (capital i); I'm pretty sure that you want to put a 1 (one) there instead (if I is not declared as a variable somewhere earlier in your code, it will be regarded as having the default value of zero, hence returning STARTPOINT(0) which haven't been set and thus, that too will have a value of zero).


-> Oh, come on...
feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 21st Jan 2009 02:47
Just gotta add, while the scope is global if it's at the top of the program... (or should be), it doesn't work like that. I've run into issues myself so make sure to add "global". Also the syntax is very specific, it compiles 2 ways and only 1 way actually makes it global.

That is this way:


or basically global _variablename_ as _type_

global var = N works but I have found that not to actually globalize the variable before.

Just a quirk I thought I'd add, since the topic is relevant enough

Signed
------
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 21st Jan 2009 06:22
I just tried sth on my code...feel weird on it...Hope any of u can help me prove it..

when i try to code as below..what i noticed is the endpoint(1)=0.
But when i delete the "....."(dot) which locate at line "REM GO TO ......." the answer will become normal back..

Is that same on ur computer??



Thanks...
feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 21st Jan 2009 07:09 Edited at: 21st Jan 2009 07:10
try Print STR$( STARTPOINT(1) ) To convert that to a string. Quotes won't be needed if you do that.

I'm unsure what you're printing exactly with that code.

So try:


Or better yet...
since it doesn't look like you're assigning, rather just checking something... you don't need the if statements initially.

ENDPPOINT(1) = STARTPOINT(1)
Y = STARTPOINT(1)

Should take care of all possible assignments for startpoint(1).

Use FOR to assign all 10, just a suggestion.

Signed
------
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 21st Jan 2009 07:33
From the code u given,
i get the result
2
0
2

so..sth wrong on it?
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 21st Jan 2009 08:33
Now i'm facing another problem. I wondering why my entities(sphere) unable goto the place i want. the location is show in the image...the sphere cant reach endpoint=3 and endpoint=4..

I attach my code below


Again Thanks for all the kindly helps

Attachments

Login to view attachments
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 21st Jan 2009 08:41
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 22nd Jan 2009 13:42
Any helps....????
Please...
feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 22nd Jan 2009 14:36
Hmmm, I haven't used DarkAI... but I did go through some of the example programs. I don't see any waypoints, I believe you use those to go around obstacles.

Also check your Print "STARTPOINT(1): " function. PRINT is for the String type, so change the second half to + STR$(Value)



Also, if you "are" having a problem with DarkAI, congratulations! You can ask that question in the DarkAI section and get more help. I'm lost as to what now, but you do have the PRINT function right, that helps you debug many programs... especially 3d

I'm lost otherwise. You'll have to describe what you're trying to do, the comments only tell tiny pieces of what you're trying to do.

Signed
------
Tom0001
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location:
Posted: 23rd Jan 2009 00:27
@feiting shadow,

Yes the $ is necessary on STR$. >_>
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Jan 2009 01:29
Other than the arrays, I see no globals defined anywhere, so I'm a little lost on what you're all talking about. And why is your entire code capitalized? 'Tis a bit hard on the thee old eyes.

Your signature has been erased by a mod because it's larger than 600x120
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 23rd Jan 2009 08:56
Basically the problem is my entities cant reach the location tat i denote on my image.tat's somewhere near the two outlet there.but my entities only able reach the boundary of the main area,they cant go further to reach the two outlet(bus bay)
Sorry to let u feel unconvinent for ur eyes.
I belive is the problem of the boundary not the ai.
Thanks for all your kindly helps.
fumade
15
Years of Service
User Offline
Joined: 28th Oct 2008
Location:
Posted: 23rd Jan 2009 09:05
By the way,the startpoint(1) is a global variable.i state as dim startpoint(entities),dim endpoint(entities).oh ya..endpoint() is a global variable too,but endpointF is a function.
I just wan to print where the entities'll start and where they'll go to.

Login to post a reply

Server time is: 2024-09-28 00:17:38
Your offset time is: 2024-09-28 00:17:38