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 / Let dbpro read an file and let it read every word to match another word

Author
Message
crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 8th Jul 2011 14:43
Hi,

i wan't to make my own very simple programming language in dbpro.

here's i how i wan't to do it;

i make an seperate codeeditor.

i let the codeeditor save the textfile in my own extension(.dat or something)

i let dbpro read the file.

but then i'ts complicated ,how do i let dbpro read every line in the file and make dbpro to recognize a command i made in dbpro

and if that command is in the file dbpro would go to the function for that command en executes the dbpro command.

but how do i do that ?

BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 8th Jul 2011 15:47
Sounds like you're trying to make an interpreted language, right?

You can use the following commands



to read the lines of the file. However as you'll need to have jump commands, you may want to read all the lines in at the start of the program in to a string array. That way you will be able to easily jump back to earlier lines.

As for identifying commands, string comparison in DBP is easy. You can even use it with the select case structure. Thus to simply look for commands, you could use something like this:



Things may get a bit more complex as you'll need to handle multiple things per line. To deal with this, you will want to look in to the string manipulation functions such as:

left$ ( string, value )
right$ ( string, value )
mid$ ( string, value )

You will also want to find some kind of in string command to find spaces and so on. I think IanM's plugin has some good functions in this area but unfortunately, that's the one part of his plugin I can't use because it clashes with another plugin I have.

Anyhow I hope this helps and good luck with this.

crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 8th Jul 2011 15:57
@lucas

yes thats what i'm after.

And i will trying to use your suggestion.

Thanks !

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 8th Jul 2011 19:13
The most useful command that Lucas Tiridath mentioned in IanMs Matrix 1 Utilities Plugin is SPLIT STRING. It'll allow you to split a string by separators in the string.

If you don't have IanMs Matrix 1 Utilities Plugin yet don't skip this next link... it'll change your programming life forever!

https://forumfiles.thegamecreators.com/download/2192430

On a side note: Why do you want to program this way? It's far easier to program directly in Darkbasic Pro.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 8th Jul 2011 19:29
Or use LUA which is designed for this?

My signature is NOT a moderator plaything! Stop changing it!
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 8th Jul 2011 20:33
When I responded, I was assuming that you were making this for the challenge and the fun of it. Grog and Mobiius are right to ask why you are making it though because however well you code this language, it's probably going to be pretty slow. That's just a result of the fact that you're using such as high level language to make another language and the fact the language you're aiming to make is interpreted which makes it relatively slow anyway.

So as a project, I think this sounds great, but do think a bit more about it if you were planning on using the new language for any major project.

crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 8th Jul 2011 22:15
1.It's just for the fun that i wan't to this.

2.I'm not going to make any major project with this

But anyway thanks for the Replies !

I inhabit a nice forum
[href]uh what ?[/href]
crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 8th Jul 2011 22:21
Going further on the post of grog;

do you mean by programming in Dbpro that i make an editor in dbpro
so that is mustn't read the file,and is goes faster than the way i wan't to do ?

I inhabit a nice forum
[href]uh what ?[/href]
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 8th Jul 2011 23:19
I think when Grog said about programming in DBP, he meant actually writing programs in DBP. As in, you already have access to a programming language, why make another on top? But I'm sure he'll correct me if I've misinterpreted.

However if you're just making the language for the fun of it, then go for it. On the topic of the editor, you presumably mean the IDE that you'll write the code for your new language in. If you're set on doing everything in DBP, may I point you towards the BBB GUI plugin. It is a windows API plugin that allows you to quickly and easily integrate standard windows features such as textboxes, checkboxes, labels and suchlike into your programs. This will save you having to make all these things from scratch. And again Grog is right, you will really want to get IanM's Matrix1 plugin.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Jul 2011 00:14 Edited at: 9th Jul 2011 00:15
@ Lucas Tiridath:

Yeah, that's exactly what I was thinking.

crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 9th Jul 2011 11:18
Ok, i downloaded the BBB gui plugin ,so maybe it is better that i do everything in dbpro.

Also i was looking for a free gui plugin ,thanks!

@lucas

yes i mean the IDE with editor

I inhabit a nice forum
[href]uh what ?[/href]
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 9th Jul 2011 12:36
Glad the link was useful. You have Brendy boy to thank for that amazing plugin. Remember to download Matrix1 as well! Yes everyone on this forum is going to keep saying that until you confirm you've got it

Anyhow good luck with this. It sounds a really interesting kind of thing to try and do so do post about how you're getting on.

crazy kitty
16
Years of Service
User Offline
Joined: 1st Nov 2009
Location: MARS , eos
Posted: 9th Jul 2011 12:44
yes maybe i will post a entry in the Work in Progress board.

and i've also downloaded the matrix plugin.

So overall thanks for the support !

I inhabit a nice forum
[href]uh what ?[/href]

Login to post a reply

Server time is: 2026-07-11 04:24:18
Your offset time is: 2026-07-11 04:24:18