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 / [SOLVED] Help with controll device name

Author
Message
locecode
User Offline
Joined: 11th Apr 2019
Location:
Posted: 26th Apr 2019 02:30
So I need to check if a controller is connected, if so then controller=1 if not then controller=0

This is my code but it does nothing, all it does is set it to one anyhow with controller in or not.

Is there no other way to check len for control devices name?



Just trying to make a switch from controller to 0 to 1 with a checklist

The author of this post has marked a post as an answer.

Go to answer

Bored of the Rings
14
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 26th Apr 2019 05:52
so did you do a PERFORM CHECKLIST FOR CONTROL DEVICES? see example from the DBPro help:



If you not sure of a command , always highlight command and press F1, it will most likely save you time posting on the forum.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
locecode
User Offline
Joined: 11th Apr 2019
Location:
Posted: 26th Apr 2019 08:07
@Bored of the Rings

Yes sir, I have this at the top of my code, and even have printed the controllers name on screen, so I know my controller has a name.

But there is no way to change a integer with any check.
Bored of the Rings
14
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 26th Apr 2019 10:00
Quote: "$name=$name+len(name)>1"


just saw error in your code $name? don't think that's correct ie. $name??. you can't do a len with name, it needs to be a string e.g. len(name$)
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
locecode
User Offline
Joined: 11th Apr 2019
Location:
Posted: 26th Apr 2019 12:38 Edited at: 26th Apr 2019 12:39
@Bored of the Rings

I try this and it will not even build the game, it has a line on this line like there is a error, but I know it is ok, its telling me len(name$) is wrong some how.

But when I say len(name) it runs.
Bored of the Rings
14
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 26th Apr 2019 13:25
hmmm, I'm wondering if this is a reserved name issue. What happens if you try changing the variable name 'name' to something else less generic like devname$. I will try my end also and see what happens.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
14
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 26th Apr 2019 13:32 Edited at: 26th Apr 2019 13:35
This post has been marked by the post author as the answer.
yes, so I get an error when trying len(name), but my way compiles fine, see attached files:
you should only use "if len(name$)>1 ... then ..."
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
locecode
User Offline
Joined: 11th Apr 2019
Location:
Posted: 27th Apr 2019 01:05
@Bored of the Rings

Yep, that works, thank you so much

Login to post a reply

Server time is: 2019-10-16 09:11:44
Your offset time is: 2019-10-16 09:11:44