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 / How to execute a code (inside a darkbasic code)

Author
Message
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 25th Jan 2013 14:06
I'm doing a kind of engine for to make itens (of inventory), which export, in the memblock, the image (memblock of .jpg file), the name of item (string), the legend of item (string), the initial level (byte),the final level (byte), and the code of action (when the user click on item or other thing). I did tests and i managed to create a file that stores the image and texts. But i don't know to execute the code in darkbasic. IT'S NOT COMPÍLE!
For exemplo:

(project main)

sync on
sync rate 100
do
for i=1 to itens
execute_action_item(i) //----> function
next i

sync
loop

(action made in item engine)

if mouseclick()=1 then print "click here!"


remembering that the activation code will be stored in memblock and by a process which is only obtained the code, how do I run this code in "real time"? or rather run in game loop?

"Better than do is try"
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jan 2013 17:34
I don't get it. What are you trying to do?

TheComet

http://blankflankstudios.tumblr.com/
"Man being a noob sucks! " - OBese87
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 25th Jan 2013 18:21
I would suspect that you are going to need a text parser for what you are wanting. I would suggest checking out this current thread.. It's about HTML and css, but I have a feeling you are wanting something similar for DBP commands.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jan 2013 21:25
You need to look into scripting, function pointers & file parsing.

If you know how to write memblocks, surely you must know that you can simply read them as function parameters or logical conditions.

Check out Matrix1 utilities (search for it), which allows you to call functions using strings or numbers; but that's just the start of it; there is LUA, XML and INI file parsing available.

print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 26th Jan 2013 02:42
Sorry about my english!
What i wanted to do is create a code externally and run in a other darkbasic code!

"Better than do is try"
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Jan 2013 06:08 Edited at: 26th Jan 2013 08:06
I understand you perfectly. What I advised allows you to run instructions created by other programs.

You cannot run DBPRO code using DBPRO syntax from another program; at best you can use LUA, which I advised above. To call DBPRO functions from scripts, you use the DBPro.Call LUA function.

Quote: "DBPro.Call

This command allows you to call any dbpro command from within your scripts (of dlls you registered, or were registered by lua make 1, or user functions you registered).
Remember however to include the dbpro dlls you want to use from your scripts by having a command from that dbpro dll within (or at the end of) your dbpro source code.
The first parameter is the name of the dbpro command you would like to call. The command name is without spaces and the leading characters are upper "


Or if you want to stick to one language, do something similar to the following:

Matrix1 + XML
Call Function Name XML GET ELEMENT NAME(xElement)

How to read / generate XML:


Matrix1 + INI
Call Function Name Lookup$( INI, "Item/Action", "DefaultAction" )

Quote: "MAKE LOOKUP FROM INI

Syntax

MAKE LOOKUP FROM INI Lookup id, Ini filename$

Description

This command can be used to build a lookup table from an Ini file.

The section name will be combined with a slash and the key to generate a key for the lookup.

If there is a blank section name, the loaded key will have a leading slash. If the ini key is blank, the key will have a trailing slash.

The hash ( # ) and semi-colon ( ; ) characters are treated as the start of a comment, unless they are enclosed within a double-quoted value.

When a field starts with a double-quote, everything up to the last double-quote on the line will be retained, but everything after will be discarded as if it were a comment."


Or old school approach, somewhat slower:

Select ACTION$
Case "YourAction" : YourFunction() : EndCase
EndSelect

Or

Select Memblock String$( Memblock, Pos, Length )[/b]
Case "YourAction" : YourFunction() : EndCase[/b]
EndSelect

Or

Select XML GET ELEMENT NAME( Memblock, Pos, Length )
Case "YourAction" : YourFunction() : EndCase
EndSelect

Or use commandlines and mutexes if you want two DBPRO programs to run side by side. If you want to learn commandlines and mutexes, there are examples in the forum.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 26th Jan 2013 12:00
Good call on the XML, that should be very helpful to him.

print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 26th Jan 2013 16:28
Thank you all, and especially to Chris Tate!
I'll make a file called "logic.ini", with the name of my function in PSEUDO-CODES, made in the engine, and it "translation" in darkbasic, and i'll use the "old school approach".
I'm feeling stupid... not recognize the improbability of this idea... and the worse ... i thought that eval performed codes!

"Better than do is try"

Login to post a reply

Server time is: 2026-07-07 08:18:16
Your offset time is: 2026-07-07 08:18:16