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 / DarkBasic reading user input as code...

Author
Message
Okashira
18
Years of Service
User Offline
Joined: 8th Feb 2006
Location: Right here.
Posted: 18th Mar 2006 14:46
I am making a Amiga 1-style computer 'simulator', and I was wondering if there is a way to code it using the INPUT command where what the user types in is read as coding.

So like, if the user types in(using the INPUT command) PRINT "Hello World!", could I have DarkBasic read that as code and then print Hello World on the screen?

Let the games begin!
Halo Man
19
Years of Service
User Offline
Joined: 5th Nov 2005
Location:
Posted: 18th Mar 2006 15:04 Edited at: 18th Mar 2006 15:44


I don't know how to put in a quotation key, because the compiler will give error messages.

Anyway, to create what you are talking about, you have to make IF statements. Really it's just a matter of finding out what the user types.

Halo!!1one
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th Mar 2006 15:24
you cant use input to inject "code" into an already compiled and running exe. you're thinking of a scripting engine.

FREE Automatic file updates for your distributed Games and Apps - see Program Announcements Forum - DBP Demo
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 18th Mar 2006 17:33
Halo man almost got it, aside from a scripting engine, here's what you could do:



Also, I would reccomend that you break that into functions to make it easier to read.

-H4ck1d

There are 10 types of people, those who understand binary and those that don't.
Okashira
18
Years of Service
User Offline
Joined: 8th Feb 2006
Location: Right here.
Posted: 22nd Mar 2006 22:25
Alright, thanks alot guys!

Let the games begin!
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 23rd Mar 2006 07:27
you could possibly write a temporary .dba outside of the main .exe file to use the #include command to call commands. Something like this code:


Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 23rd Mar 2006 08:08
I have had experience in doing this (despite what all my posts say) i am good at this. Although in my code the user has to continuosly input the parameters. Anyways, heres a simpler code...


That may not be the most efficient code, but i like it!

View my website![href] http://www.freewebs.com/directexecute/index.htm [/href]
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 25th Mar 2006 23:43
The problem with that is that it doesn't allow room for expansion.

Say the user typed print "Hello World" : end, which means there are two commands to be used. The program wouldn't allow the codes to be used because all you have are the basic commands. If you use the code I had it will allow it to work because it is using DB to run the code, using the #include command.

You can rewrite my code to allow for multiple commands to be issued as well. As adding more input commands and more code$ strings to be saved to the .dba file.

Okashira
18
Years of Service
User Offline
Joined: 8th Feb 2006
Location: Right here.
Posted: 27th Mar 2006 21:21
Quote: "you could possibly write a temporary .dba outside of the main .exe file to use the #include command to call commands. Something like this code:"


Wow! Thanks alot, I never thought of doing it that way .

Let the games begin!
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 28th Mar 2006 08:47
np, glad I could help

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 28th Mar 2006 11:28
Ive got a small scripting engine here for you (Like reading BATCH files in MSDOS, but with your SIMULATOR. Anyways, it will read outside commands with out the user input.


Some pieces of code were found at the code snippets or code base. But pretty much most of it is mine.

This should be some sort of an add-on to what your making.

Sonic vs Mario [ic:star] Who will win? View [href]WWW.NEWGROUNDS.COM[href] to see the movie!

Login to post a reply

Server time is: 2024-11-27 23:43:47
Your offset time is: 2024-11-27 23:43:47