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 / 2 easy questions (text, Includes)

Author
Message
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 8th Jul 2007 23:09
1. i am having trouble getting the following to work,


2. How do i include files that are not dark basic files (like a TXT)

thanks,
wicked

102
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 8th Jul 2007 23:13 Edited at: 8th Jul 2007 23:17
1. That's not a question silly
But text is for strings, not floats, :/
Try this:


2. I'm not sure :/...

Ling creckt tsi nocreckto havela? NASA chetallnar mo lu'ul nasding!
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 8th Jul 2007 23:18
Look up the file commands.


wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 8th Jul 2007 23:26
ok thanks, but i want to place the text in a specific area, how would i do that with print?

102
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 8th Jul 2007 23:27
oops sorry, just noticed the formatting thanks alot!

102
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 8th Jul 2007 23:27
Ur welcome

Ling creckt tsi nocreckto havela? NASA chetallnar mo lu'ul nasding!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Jul 2007 23:42 Edited at: 8th Jul 2007 23:43
n008:

You really crack me up sometimes!!

You answer a question you don't know the answer to with the wrong answer then when the poster says thanks, you acknowledge it as if you solved the problem. Priceless!

Quote: "text is for strings, not floats,"


What rubbish! Look up Str$() in the help files...


wickedly kick it:

When setting the content of float variables you should use:

john#=100.0

When you want to print numeric variables with Text, you should use:

text 1,23,Str$(john#)

Quote: "How do i include files that are not dark basic files (like a TXT) "


You don't - just make sure they are in the same directory as your DBA file and use them as normal. The compiler does the including - not you.

Quote: "but i want to place the text in a specific area, how would i do that with print?"


If you've done as Ruccus says and have checked the help files you will already have discovered Set Cursor X,Y!

TDK_Man

wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 8th Jul 2007 23:56
lol noo8 helped quite a bit, also i mean how do i include a .txt file that has a function in it that i want (or better yet a file extension i made for my game) so people wont know to see my code. Is there anyway to do that, so i can call it and have minimal code in the main dbp file.

102
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 9th Jul 2007 01:00 Edited at: 9th Jul 2007 01:01
You're talking about source files (.dba files). To do this, open up the IDE, put whatever functions you want in there, and click the "save source" option from the file menu. Now open your main project, and use the include button in the program manager to browse to the source file. I recommend getting the Code Surge IDE, as the default IDE's include features can get a bit buggy, along with everything else with the default IDE for that matter.

Another point: People wont see your code, because when you compile your program, all of your code get's turned into machine code, and then into an executable. You never give out your actual code files (.dbpro, .dba), just the executable, and any media that the executable needs to run.

You can not make your own file type and have dbp read / compile it.

Please, read some beginner's tutorials on these topics (TDK has tonnes of them, click his signature link) and start learning this stuff on your own.

<edit>

And n00B, please, stop helping people. You dont know what the correct answer is, so when you "help", you're only making the user think they've figured it out, causing them to run into even more problems and ask even more questions, and then they may pass the wrong information on again.


Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 9th Jul 2007 01:23
Hmm.. can you not just do #include "myfile.txt" ? If not, look into a scripting language, like lua.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 9th Jul 2007 02:35
IIRC the #include feature doesnt work properly. I dont think you can include other source files other than .dbas... But then I've never tried.


Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 9th Jul 2007 04:11
If you include a text file with the #include command, it will just append it to the end of your code, and it won't work. You can add it as a media file to the EXE though, and access it as though it were in the same folder.


Come see the WIP!
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 9th Jul 2007 07:00
what i mean is make a text file, with some functions in it... then it will just open it and read it (as db code) but i dont think this will work so ill just wait.

102
Don Malone
21
Years of Service
User Offline
Joined: 27th Apr 2003
Location: Birmingham, Alabama
Posted: 10th Jul 2007 21:51 Edited at: 10th Jul 2007 21:53
If nothing has changed, I seem to remember the answer is not in a text file. The only way to include (functions) code is to write it in a (separate) dba file as specified above and include that.

Cash stated
Quote: "If you include a text file with the #include command, it will just append it to the end of your code, and it won't work."


That sounds right to me. You are not the first to ask about this. Many people have wondered the same thing. What you have to remember is that all the code is compiled before distribution, and not at run time. This makes the text approach; you asked about; difficult.

Not everything is impossible, but many things are not worth the effort required to make it work.

I am not an expert by any stretch, but I do like to read what the experts say. With that in mind....

Making nothing for the forth straight year.

Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 13th Jul 2007 05:09
cant you just like put your code in a function(in a text file) and then initiate the function at the start of the program without going through the hassle of including a dba file?


Lessen The List! (see the forum on my site)
Roborb = [00------------] - first models
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 13th Jul 2007 07:51
Quote: "what i mean is make a text file, with some functions in it... then it will just open it and read it (as db code) but i dont think this will work so ill just wait."

You can only include Dark Basic Pro code in this manner. A DBA file is a text file, just a different extension. Just add another source file in your DBP code editor.


Come see the WIP!

Login to post a reply

Server time is: 2024-11-25 15:42:37
Your offset time is: 2024-11-25 15:42:37