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 Discussion / Is there a DLL for running the code in the compiler?

Author
Message
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 3rd Jul 2008 22:41
Some of you may have seen an old project I was working on: Dark Creator. I kind of stopped working on it, but now I want to continue it.

In the program right now, it has to manually open up editor, automatically press F5, and the user would have to close the compiler when it's done.

So basically, what I'm trying to do is get some kind of DLL (or whatever is used to run the compiler) that can do what I'm trying to do. TDK, I'm that you know specifically because you made your own IDE.

Great thanks to anyone that helps.


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2008 02:35
You'll need some kind of shell execution or commandline interface to run the DB compiler. Here is a page out of the help files:

Quote: "If you prefer to use an external editor to edit your programs, you can use the command line compiler. The command line compiler allows you to compile, run and build executables without entering DarkBASIC.

1. Compiling Externally
DB.EXE -c test.dba

2. Running Externally
DB.EXE -x test.dba

3. Building An Executable Externally (no media)
DB.EXE -b "small.exe" test.dba

4. Building An Executable Externally (with media)
DB.EXE -f "large.exe" test.dba

5. Using Relative and Absolute Paths
C:\Program Files\Dark Basic Software\Dark Basic\DB.EXE -f "d:\mywork\large.exe" test.dba

When using relative paths, ensure your current directory is the project directory containing the DBA program. Your current directory will be used to write the final executable and DBCompile.LOG file. You can override this behaviour by using Absolute paths when asked for a filename in the command line. The DBCompile.LOG file contains any error messages, or completion strings returned by the compiler. The file will also include the line number at which the syntax/runtime error occurred."


What this means is, you have to be able send a shell command. If there isn't a provision built into your app, you could create an MS DOS batch file that has the commands you need and then run the batch file.

Enjoy your day.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 4th Jul 2008 03:00 Edited at: 4th Jul 2008 03:02
I don't get it. How do I put a provision in an app? (I'm using C#)
And where is the command line compiler located? That looks important.


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2008 03:16 Edited at: 4th Jul 2008 03:26
The user has to have darkbasic installed on their machine. In a directory where ever darkbasic is installed, there should be a file that reads DB.EXE

Not only is this file the default editor, but when used with the command line options, it acts as the compiler for an external editor (like Sinani's Dark Creator).

So you're using C#, huh? Let me see if I can dig up the command...

[EDIT]
Ok, check out this link:
Command line from C#

In the examples, there's a line that looks like:

System.Diagnostics.Process.Start(@"C:\listfiles.bat");

You could replace "C:\listfiles.bat" either with the batch program you create or

"DB.EXE -c test.dba" which would be to compile (F4 in darkedit)
"DB.EXE -x test.dba" which would be to run the code (F5)
etc.

You might have to include the full path to DB.EXE and the full path to the DBC script test.dba.

Oh, test.dba is just a generic name. This would be the name of the DBC program you are trying to run or compile. If you were working on a program call Pod_Racers.dba, then you would use that name in place of test.dba.

Enjoy your day.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 4th Jul 2008 21:57
So... if I created a .bat file with the shell commands (-x, -c, etc.) how would I call them, with the .dba file in the program?


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2008 22:33 Edited at: 4th Jul 2008 22:40
Let's see...

Some preliminary considerations before actually getting into runnung the compiler:
If you've ever used DarkEDIT, you know how under the menu options EDIT > Edit Options > DarkBASIC Options, the user can input the location of the DarkBASIC main program : DB.exe? Well, somewhere in the setup of your IDE, you should have something similar where the user can setup the location of this file. You want your IDE to know where this file is located, so maybe this information is stored in an .ini file or some custom file that you create.

Anyway, once the IDE has the location of the DB.exe file, you can program the IDE to make the necessary batch files or run the compiler when a key pressed.

Let's say you want to check the syntax of the DBC code that's being worked on (compile using F4). The sequence of events should go something like this:

The user presses F4 and
1. Automatically save a copy of code being worked on with some kind of temporary extension. This is so the code can be tested without saving the REAL code yet. So let's say your temporary extension is .tmp , you could save the name of this file as darkcreator.tmp (everytime you save a temporary file you would use this name)

2. Instead of using a batch file, let's invoke the compiler directly using the full path to DB.exe , the command switch, and the input file (the temporary file). Let's say Db.exe is in C:\DarkBASIC . The code in C# might look like this:

System.Diagnostics.Process.Start(@"C:\DarkBASIC\DB.exe -c darkcreator.tmp");

I'm assuming darkcreator.tmp is being saved in the current directory - if you want, you can include the full path wherever that may be:

System.Diagnostics.Process.Start(@"C:\DarkBASIC\DB.exe -c C:\DarkCREATOR\darkcreator.tmp");


If you want to create a batch file, then create a text file with the top line reading:
"C:\DarkBASIC\DB.exe -c darkcreator.tmp"

and save it as DC.bat

Then run the C# code:
System.Diagnostics.Process.Start(@"C:\DC.bat");

Of course you'll want to include the proper directory of where ever you saved DC.bat

Enjoy your day.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 4th Jul 2008 23:23 Edited at: 4th Jul 2008 23:26
It... doesn't work

I tried doing the batch file. When I execute the .dba file, a command prompt comes up for about one second, then disappears.

I tried researching commands to run it (like START and CALL), but none of them worked.
Note that I'm using the second thing you said, with the batch file. The first one returned an error, no matter what I tried to do to fix it.

Sorry if I'm sounding like an idiot. I'm not very expeirienced with C#, although I do have a book about it.


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2008 23:25 Edited at: 4th Jul 2008 23:36
what happens if you just double click on the batch file? Not running it from Dark Creator? Oh and if you are compiling (F4) you aren't going to see any results. Try changing the command switch
-c to -x (execute the program).

Enjoy your day.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 4th Jul 2008 23:27 Edited at: 4th Jul 2008 23:27
Same thing as when I do it in Dark Creator, it comes up for a split second, then disappears.


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2008 23:37
Try using the execute switch -x in stead of -c . Compile only check syntax.

Enjoy your day.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 4th Jul 2008 23:39
The same thing happens. Were you completely sure that the batch file would work, anyways?


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2008 23:45 Edited at: 5th Jul 2008 00:04
I just created a batch file. I've tested it several times and it will run the .dba file every time. I might not have told you how to set it up the batch file correctly. In fact I see that I included the whole command in quotes. Each file name should be in it's own set of quotes. This one will execute the file object_ramp_collision.dba on my machine. Change the locations and file names in this example to an existing file on your machine. You'll probably have to change the path to darkbasic too.

I've attached the new batch file as an example

Enjoy your day.

Attachments

Login to view attachments
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 5th Jul 2008 00:55 Edited at: 5th Jul 2008 01:02
We're getting closer and closer to the problem... but, unfortunately, still doesn't work.

I tried changing the batchfile to run a dba file that the program creates. The screen turns black, as if it were running a Dark Basic program, but then I hear the "ding" sound, as if a dialogue box comes up, then the dba file closes, and the dialogue box disappears before I can see it.

However, when I run the batch file on it's own, it works perfectly! I'll try to look into the problem. Thank you so much for helping!

[EDIT] Nevermind, I fixed it. IT WORKS!!!!!!!!! WOOHOO!!!
Now I need to figure out how to recieve errors (if there are any)


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Jul 2008 02:16
Quote: "The DBCompile.LOG file contains any error messages, or completion strings returned by the compiler. The file will also include the line number at which the syntax/runtime error occurred.""


This file will be created in your working directory - whatever directory you compile or run your .dba file in.

What you can do is load the file directly into a string and display the info. Not sure exactly how to do it in C# but in C it would look something like:



Enjoy your day.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 5th Jul 2008 03:31
Two problems:
-It's not a LOG file, it's actually just a normal text file
-When I try to put an error in the dark basic file, it runs a blank screen (even if there's a bunch of display), and the DBCompile.txt says "Compilation Successful"

WHAT HAS HAPPENED???


Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 5th Jul 2008 03:31
Two problems:
-It's not a LOG file, it's actually just a normal text file
-When I try to put an error in the dark basic file, it runs a blank screen (even if there's a bunch of display), and the DBCompile.txt says "Compilation Successful"

I'm terribly confused...


Login to post a reply

Server time is: 2025-06-06 00:18:35
Your offset time is: 2025-06-06 00:18:35