Nov 8, 2009
Pages: 1, 2

How To Add A Scripting Language To A Program ?

free web hosting

Read Latest Entries..: (Post #12) by ryantommo on Dec 17 2008, 03:53 PM.
can u use more than like 8 diff types of code in 1 game ..
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > Miscellaneous Scripting Languages & Ideas

How To Add A Scripting Language To A Program ?

yungblood
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

 

 

 


Comment/Reply (w/o sign-up)

vujsa
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

Comment/Reply (w/o sign-up)

yungblood
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

 

 

 


Comment/Reply (w/o sign-up)

vujsa
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

Comment/Reply (w/o sign-up)

yungblood
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

Comment/Reply (w/o sign-up)

vujsa
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

Comment/Reply (w/o sign-up)

yungblood
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

Comment/Reply (w/o sign-up)

yordan
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.

Comment/Reply (w/o sign-up)

yungblood
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

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
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

Comment/Reply (w/o sign-up)

Latest Entries

ryantommo
can u use more than like 8 diff types of code in 1 game ..

Comment/Reply (w/o sign-up)

mitchellmckain
QUOTE(miCRoSCoPiC^eaRthLinG @ Aug 22 2005, 07:25 PM) *
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



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?

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2
Similar Topics

Keywords : add, scripting, language, program

  1. Bash Shell Scripting: Comparing Directories
    (11)
  2. Best Way Of Learning A Scripting Language?
    (7)
    I was going to wonder what is the best way to learn a scripting language. I mean there are tons of
    different ways including buying Books on internet of that langauge. You can also take tech
    classes,or even internet classes, or best way to just learn by yourlself? Ive been messing alot
    lately with Macromedia MX director. Ive been learning its scripting language called Lingo, but ive
    just been learning from messing with source codes and server scripts. Is the best way trial and
    error and repeat?....
  3. mIRC Scripting
    mIRC (0)
    What script is mIRC written in as i would like to know here's an example of a peace of its
    script: #capsprot on on ^*:TEXT:*:#:{ if ($nick == $chan) halt if ($$ial($nick $+ *,1).addr
    == $read(protect.txt, w,* $+ $$ial($nick $+ *,1).addr $+ * )) return if ($nick isowner #) halt
    if ($nick isop #) halt if ($len($1-) var %caps.letters = $calc($len($1-) + 1 -
    $len($removecs(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z))) var %caps = $calc($len($1-)
    - $len($removecs($1-,($1-),A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z))) var %caps.perc....
  4. Formmail Without Scripting
    Same as above (5)
    Hi Once opon the time I did use an simple formail witout any script. I can't exactly remember
    how I did done. But something with post and then my email adress. Does any remember this poor
    solution??? Thanks Cheers! Jens....
  5. mIRC Scripting
    Is there any scripters in here? (6)
    I am wondering if there is more than me who script mIRC.. If there is please share your scripts and
    screens. Here you can find a screenshot of my newest creation "flipIRC". Tell me what you
    like/dislike /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
    /flippys --------moved this from What Is... to here, as this place is more appropriate and should
    get you more responses /wink.gif" style="vertical-align:middle" emoid=";)" border="0"
    alt="wink.gif" /> --------szupie....

    1. Looking for add, scripting, language, program

See Also,

*SIMILAR VIDEOS*
Searching Video's for add, scripting, language, program
advertisement



How To Add A Scripting Language To A Program ?

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com