|
|
|
|
![]() ![]() |
Aug 1 2005, 10:39 PM
Post
#1
|
|
|
Member - Active Contributor Group: Members Posts: 84 Joined: 7-June 05 From: Antioch, California Member No.: 5,943 |
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 This post has been edited by vujsa: Aug 3 2005, 02:57 AM |
|
|
|
Aug 3 2005, 02:54 AM
Post
#2
|
|
|
Absolute Newbie Group: Admin Posts: 888 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 |
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:
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 |
|
|
|
Aug 4 2005, 12:09 AM
Post
#3
|
|
|
Member - Active Contributor Group: Members Posts: 84 Joined: 7-June 05 From: Antioch, California Member No.: 5,943 |
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 --YB |
|
|
|
Aug 4 2005, 01:11 AM
Post
#4
|
|
|
Absolute Newbie Group: Admin Posts: 888 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 |
QUOTE(yungblood @ Aug 3 2005, 08:09 PM) 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 --YB I get what you are trying to do now. Unfortunately, I'm beyond the realm of bad with C++. 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 |
|
|
|
Aug 4 2005, 11:15 PM
Post
#5
|
|
|
Member - Active Contributor Group: Members Posts: 84 Joined: 7-June 05 From: Antioch, California Member No.: 5,943 |
QUOTE(vujsa @ Aug 3 2005, 06:11 PM) I get what you are trying to do now. Unfortunately, I'm beyond the realm of bad with C++. 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 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. |
|
|
|
Aug 5 2005, 02:55 AM
Post
#6
|
|
|
Absolute Newbie Group: Admin Posts: 888 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 |
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 |
|
|
|
Aug 22 2005, 06:47 PM
Post
#7
|
|
|
Member - Active Contributor Group: Members Posts: 84 Joined: 7-June 05 From: Antioch, California Member No.: 5,943 |
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.
-YB |
|
|
|
Aug 22 2005, 07:29 PM
Post
#8
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 2,043 Joined: 16-August 05 Member No.: 7,896 |
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. |
|
|
|
Aug 22 2005, 10:25 PM
Post
#9
|
|
|
Member - Active Contributor Group: Members Posts: 84 Joined: 7-June 05 From: Antioch, California Member No.: 5,943 |
QUOTE(yordan @ Aug 22 2005, 12:29 PM) 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. 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... --YB |
|
|
|
Aug 23 2005, 02:25 AM
Post
#10
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
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/javaworld/jw-05-1...05-indepth.html 2. http://memphis.compilertools.net/interpreter.html 3.http://www.tldp.org/HOWTO/Linux-Gamers-HOWTO/interpreters.html 4. Also check out this book: http://www.amazon.com/exec/obidos/tg/detai...488159?v=glance |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 13th October 2008 - 01:18 AM |