Jump to content
xisto Community
Sign in to follow this  
yungblood

How To Add A Scripting Language To A Program ?

Recommended Posts

Notice from vujsa:

Edited Post!

Please do not post email address here or request that help be sent via email. Replies should be made in the form of posts so everyone may learn from your question.


Does anyone have any experience adding a scripting language to a program they are writing? I have one project I'm working on that needs a scripting language, and I would like to simply add an existing language to my program. I know how to use Perl, Tcl/Tk, Python, and others... but I don't know how to tie one of them into my program. I know it's possible, but I need help in doing it. If anyone knows how to do what I'm looking for, please reply!

 

EMAIL ADDRESS REMOVED

 

--YungBlood

Edited by vujsa (see edit history)

Share this post


Link to post
Share on other sites

I think that most of us will need more information about what you want to do.

 

What program?

 

We need to know what program or language you want to "tie" a script to.

 

If you want to add scripting to a server generated web page, then many of us can help out.

 

Here is what we'll need to help:

What language is the program written in?

What scripting language are you trying to add to the program?

Brief description of what you are trying to accomplish or at least an example of the idea.

We understand that you may wish to conceal some informatin to protect your work and we'll try to work around that to help out but we do need some information.

 

If you want to add something like PHP to a Perl based program, we may have a little trouble but there are ways to do anything.

 

vujsa

Share this post


Link to post
Share on other sites

I'm writing in C++ using Borland C++ 5.0.I'd like a common scripting language tied in (ie. TCL, PERL, Python). It doesn't matter to me which one is used, I can work with any of them, and I have those 3 on my computer I'm using to develop this program.I'm making a program to work interactively with MIDI. So I will need the scripting language to handle MIDI & timer events. Here's an example of what I want to do:- Keyboard player plays a note- the core of my program sends out a message like: ----- note-on channel key# velocity timethen a users script does something like this:on note-on: {if (channel == 1) & (key == 35) { delay 100 midi-out note-on channel-2 key-37 velocity-127}I hope you get what I'm trying to do. The actual program I'm writing should be very simple, it will just listen to the MIDI keyboard, and send messages both to user scripts & user programmed DLL's, and have them manipulate the MIDI info, and send it back whatever MIDI out is defined in the core program. I have already started on the DLL's, for faster code. But I want to have the option of a scripting language, to make it quick and easy to experiment with ideas, and for people that don't want to actually learn how to make a DLL.Once everything is in place, the user will be able to open the core program, load a config file that contains all the setup info for the DLL's and scripts, and then start playing.I hope that clears up what I'm trying to do :D--YB

Share this post


Link to post
Share on other sites

I'm writing in C++ using Borland C++ 5.0.

 

I'd like a common scripting language tied in (ie. TCL, PERL, Python). It doesn't matter to me which one is used, I can work with any of them, and I have those 3 on my computer I'm using to develop this program.

 

I'm making a program to work interactively with MIDI.  So I will need the scripting language to handle MIDI & timer events.  Here's an example of what I want to do:

 

- Keyboard player plays a note

- the core of my program sends out a message like:

----- note-on channel key# velocity time

 

then a users script does something like this:

 

on note-on: {

if (channel == 1) & (key == 35) {

  delay 100

  midi-out note-on channel-2 key-37 velocity-127

}

 

I hope you get what I'm trying to do.  The actual program I'm writing should be very simple, it will just listen to the MIDI keyboard, and send messages both to user scripts & user programmed DLL's, and have them manipulate the MIDI info, and send it back whatever MIDI out is defined in the core program.  I have already started on the DLL's, for faster code.  But I want to have the option of a scripting language, to make it quick and easy to experiment with ideas, and for people that don't want to actually learn how to make a DLL.

 

Once everything is in place, the user will be able to open the core program, load a config file that contains all the setup info for the DLL's and scripts, and then start playing.

 

I hope that clears up what I'm trying to do :D

 

--YB

<{POST_SNAPBACK}>


I get what you are trying to do now. Unfortunately, I'm beyond the realm of bad with C++. :P

 

I see a couple of drawbacks to using the scripting languages in this way. The first is that keeping all of the coding compiled in C++ will provide much better results for you. Trying to swap between the executable and the scriptreader will slow things down and add work to the system. Additionally, the user will need to have the script engine installed on their system for the program to work.

 

Well, I hope you find your answer and I'm sorry I can not be of more help.

 

vujsa

Share this post


Link to post
Share on other sites

I get what you are trying to do now.  Unfortunately, I'm beyond the realm of bad with C++. :P

 

I see a couple of drawbacks to using the scripting languages in this way.  The first is that keeping all of the coding compiled in C++ will provide much better results for you.  Trying to swap between the executable and the scriptreader will slow things down and add work to the system.  Additionally, the user will need to have the script engine installed on their system for the program to work.

 

Well, I hope you find your answer and I'm sorry I can not be of more help.

 

vujsa

<{POST_SNAPBACK}>


First, I agree with what you're saying about the drawbacks. However, I'm looking for this option not to be the norm. I only want to load the script handling if a config file calls a script. I want all the main calls to be to dll's. But I know from experience that people want easy flexibility. I know I can't think of every possibility that people want. And not everyone will want to write a dll just to handle something small. That's why I see adding a scripting language to be the best compromise.

 

And of course, I would put the scripting language engine in the installation package. :D It wouldn't do to have an install be incomplete. :P

Share this post


Link to post
Share on other sites

Well, as I said, I can't really help you with your issue but I'm sure you'll get some help here.Perhapes your next program will be a DLL writer for your users. As you said, you can't anticipate every need of your users but such a program could be used to create a basic DLL for them. Just a thought. Personally, I've never written a DLL and wouldn't know where to begin so I can't invision all of the pitfalls involved in creating such a program. My thought was that if your users can't or won't write their own DLL, then they may not wish to or be able to use a scripting language to obtain the same results.You might do some searches for classes that are already written that could handle your scripting events for you. Maybe someone else has already come accross the same situation as you and has written such a class in C++. It may need to be adapted for you needs but if it was well written, it should be generic enough for you to build around. At the very least, it could give you a roadmap to follow.vujsa

Share this post


Link to post
Share on other sites

If you look at the program mIRC, it has both options, but most people don't want to learn the DLL programming, because it is so much more involved. With scripting, you can usually get more done with less lines of code, and more readable. That's simply because of all the coding you have to do just to setup the DLL, without even adding the coding to add the features you want. Plus with a script, you can just open the script editor, change what you need, save, and test. With DLL's, it add's the extra step of compiling/linking which for something simple, can take alot of time for a beginner. :D I just want my program to be accessable to everyone that wants to use it regardless of their technical experience. :D-YB

Share this post


Link to post
Share on other sites

I am not familiar with Borland C++, but it should not be very different from standard C language programming.when I needed scripting out from my c programs, i simply had to add a "system" in my C program and compile it.Read again your documentation about the "system" syntax, but as far as I remember it was something likesystem( dir) ;and this gave you the directory.Or system(c:/tmp/mytest.bat);Maybe it could be with quotes :system("c:\tmp\mytest.bat"); and don't forget the \ in ms-dos and / in Unix, but you are probably familiar with that.

Share this post


Link to post
Share on other sites

I am not familiar with Borland C++, but it should not be very different from standard C language programming.

when I needed scripting out from my c programs, i simply had to add a "system" in my C program and compile it.

Read again your documentation about the "system" syntax, but as far as I remember it was something like

system( dir) ;

and this gave you the directory.

Or

system(c:/tmp/mytest.bat);

Maybe it could be with quotes :

system("c:\tmp\mytest.bat");

and don't forget the \ in ms-dos and / in Unix, but you are probably familiar with that.

<{POST_SNAPBACK}>


I don't think you get what I'm saying... I'm not trying to run .bat files, or any OS commands. I need a scripting language such as TCL, Perl, Python, etc. that will interact with my program. You can see what I'm trying to do if you read my other posts. Simply put, I want a scripting language tied into my program, so that when a user opens up a script within my program, it will run within my program, executeing functions that I wrote in my program... :D

 

--YB

Share this post


Link to post
Share on other sites

I think you should read up some articles on creating an interpreter. That should help you crack the nut. First of all - unlike compiler, you have no need to write lexical & syntactical analyzers i.e. parsers - you can address the code line-by-line .. and then act accordingly. All scripting languages use some sort of an interpreter running in the background. So I'd say interpreter is the way to go..

 

Check out some basic articles on it - they might help:

1. http://www.javaworld.com/

2. http://memphis.compilertools.net/interpreter.html

3.http://www.tldp.org/HOWTO/Linux-Gamers-HOWTO/interpreters.html

4. Also check out this book: https://www.amazon.com/168-0033276-9924877?ie=UTF8&v=glance

Share this post


Link to post
Share on other sites

I think you should read up some articles on creating an interpreter. That should help you crack the nut. First of all - unlike compiler, you have no need to write lexical & syntactical analyzers i.e. parsers - you can address the code line-by-line .. and then act accordingly. All scripting languages use some sort of an interpreter running in the background. So I'd say interpreter is the way to go..
Check out some basic articles on it - they might help:
1. http://www.javaworld.com/
2. http://memphis.compilertools.net/interpreter.html
3.http://www.tldp.org/HOWTO/Linux-Gamers-HOWTO/interpreters.html
4. Also check out this book: https://www.amazon.com/154-0128710-3210656?ie=UTF8&v=glance



I thought the whole point of his question was to avoid writing an interpreter himself. I added a scripting feature to my program (relspace), but I certainly did not try to imitate any previous scripting language but tailored it to the scripting needs of my program (and frankly to my own preferences). But I guess that if you want to make your program more friendly to the user, making it use a something more like a standard scripting language would be better. However, is it possible that you might run into copyright problems if you choose one that is not in the public domain?
Edited by mitchellmckain (see edit history)

Share this post


Link to post
Share on other sites
Language script programHow To Add A Scripting Language To A Program ?

Replying to vujsaI have Medical records holder program created in English DLL, I need to add and language script for user to see it in the 4 languages : Original English and Spanish, Portuguese and French

-reply by Tony

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.