Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> How To Add A Scripting Language To A Program ?
yungblood
post Aug 1 2005, 10:39 PM
Post #1


Member - Active Contributor
Group Icon

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
Go to the top of the page
 
+Quote Post
vujsa
post Aug 3 2005, 02:54 AM
Post #2


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
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:
  1. What language is the program written in?
  2. What scripting language are you trying to add to the program?
  3. 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
Go to the top of the page
 
+Quote Post
yungblood
post Aug 4 2005, 12:09 AM
Post #3


Member - Active Contributor
Group Icon

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 smile.gif

--YB
Go to the top of the page
 
+Quote Post
vujsa
post Aug 4 2005, 01:11 AM
Post #4


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
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 smile.gif

--YB
*



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

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
Go to the top of the page
 
+Quote Post
yungblood
post Aug 4 2005, 11:15 PM
Post #5


Member - Active Contributor
Group Icon

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++. sad.gif

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. smile.gif It wouldn't do to have an install be incomplete. smile.gif
Go to the top of the page
 
+Quote Post
vujsa
post Aug 5 2005, 02:55 AM
Post #6


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
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
Go to the top of the page
 
+Quote Post
yungblood
post Aug 22 2005, 06:47 PM
Post #7


Member - Active Contributor
Group Icon

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. smile.gif I just want my program to be accessable to everyone that wants to use it regardless of their technical experience. smile.gif

-YB
Go to the top of the page
 
+Quote Post
yordan
post Aug 22 2005, 07:29 PM
Post #8


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 1,980
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.
Go to the top of the page
 
+Quote Post
yungblood
post Aug 22 2005, 10:25 PM
Post #9


Member - Active Contributor
Group Icon

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... smile.gif

--YB
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Aug 23 2005, 02:25 AM
Post #10


PsYcheDeLiC dR3aMeR
Group Icon

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

Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Your Most Favourite Computer Language(84)
  2. Basic C++ Language(19)
  3. Google Adsense(24)
  4. Clicksor(7)
  5. Do You Program/code Your Own Games(11)
  6. Online Multiplayer Game(16)
  7. True Free Design Program?(16)
  8. Wuts A Good Game Maker Program?(12)
  9. VB.NET: Switch Regional Language Automatically(1)
  10. Does Anyone Code Using Turing(2)
  11. Favorite Graphics Program?(64)
  12. What Language Is Linux Written In ?(15)
  13. Ideas For Using VB To Program Nokia S60 Phones(8)
  14. Which Virus-protection Program Is The Best?(18)
  15. A Free Graphic Design Program That Could Equal Photoshop?(35)
  1. Gba Game Program(5)
  2. Ahh! Big Mistake! How Do I Get This Program Back?(17)
  3. Good Program To Use(8)
  4. Best Free Anti-virus Program(16)
  5. Graphic Design Program(7)
  6. Unity 3d(0)
  7. Best Program To Tune Up An Old Computer?(9)
  8. Increase Your Knowledge Of Html Language(11)
  9. In Your Opinion, The Best P2p Program.(1)
  10. Who Is No. 1 Actor In India (all Language Including Bollywood)?(1)
  11. Designing A Summer Running Program(1)
  12. C++ Meters To Feet And Feet To Meters Program(0)
  13. Tuning Car Studio(2)


 



- Lo-Fi Version Time is now: 6th September 2008 - 06:35 PM