473,231 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

* Need help Implementing a script (or macro)

ern
My command-line application must be able to run text scripts (macros).
The scripts have commands, comments, and flags. Comments are ignored
(maybe they are any line beginning with " ; ") Commands are executed
as if the user *manually* typed them in the console. Flags are special
commands that tell the program where to BREAK, LOOP, START. A typical
script may look like this:

; This is my script. It will test my mp3 player...
START:

set battery voltage 1.5
begin thread

LOOP: ; here I will test individual tracks
play
skip track

BREAK: ; at this point, I go back up to find "LOOP"

To launch the script, the user will type:

"script <pathname>"

where pathname is where the script lives. So far, I have the entire
text file in a char * buffer.

Now I need to do several things....

1. After the script begins, the USER needs a way to halt execution of
the script. I was thinking any key press would do. Pseudocode looks
like this:

while("user hasn't pressed any key"){ //continue executing script...

I want the script to stop immediately after the user presses a key, so
I 'm not sure a while loop is the best way... perhaps some kind of
thread...

Need help implementing that logic....

2. I need a way to seperate each line in the text file. I was
thinking of putting each line in an element of an array. I could have
two arrays:

char * start[SIZE];
char * loop[SIZE];

The first holds the commands to execute once, and the second holds the
commands to repeat (not sure if the syntax is correct there... ? I
need an array of strings...). Once I have the commands, I can just
execute them one at a time until I get the flag to stop (#1). But how
would I parse the commands into the arrays from the "buffer" ?

Jan 17 '06 #1
2 1967
On 17 Jan 2006 06:42:51 -0800, in comp.lang.c , "ern"
<er*******@gmail.com> wrote:
My command-line application must be able to run text scripts (macros). 1. After the script begins, the USER needs a way to halt execution of
the script.
Suspend or terminate? The latter is easy...
I was thinking any key press would do.
you can't do this in standard C, as there's no way to do a continuous
background check for something else happening in parallel to your main
thread. Ask in a newsgroup specific to your platform for information
on threading.
2. I need a way to seperate each line in the text file.


read up on strtok and sscanf.

Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jan 17 '06 #2
ern wrote:

My command-line application must be able to run text scripts
(macros). The scripts have commands, comments, and flags.
Comments are ignored (maybe they are any line beginning with
";") Commands are executed as if the user *manually* typed them
in the console. Flags are special commands that tell the
program where to BREAK, LOOP, START. A typical script may look
like this:


Just use the innate script ability of your shell. In on Linux you
probably need to read up on bash. If on Windoze read up on batch
language, or better install 4dos for a better system.

This is all OT on c.l.c.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Jan 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Murphy | last post by:
<?php /* I need your help. I'd be very thankfull if write me this script.I need a script that displays a list of categories and subcategories like this: <select name="category"> <option...
6
kestrel
by: kestrel | last post by:
Hey, I need a script that will disable all scripts after a certain point. Is that possible? See, the problem is, my friend has a site, hosted free by a website where he bought the domain...
1
by: Sebastian Spandauer | last post by:
Hey, i am searching for a php script that features sending a lets say 20 lesson online course. it should: subscription on website opt-in after subsriciption send one lesson per day to every...
6
by: zaheer031 | last post by:
Hi All, I need to define a macro as follows #define VERSION "1.0" #ifdef (VERSION == "1.0") #endif main() { }
4
by: karthiknd | last post by:
hi everyone , i need a script which copy folder from one system and has to be replaced in server folder which is in another system. This java script has to be called in asp.net...
0
by: alcan-rally | last post by:
Please need Classified script with payment option I am looking for MojoScripts or delata script or 68classifieds or GeoClassifieds Thanks
0
by: arunbalait | last post by:
Hi Sorry I dont know where to post this question. Apologize if this is a wrong section I need a macro for finding duplicate entries in Excel. There are lost of Duplicate entries in various...
1
by: Phydeux | last post by:
I've got a folder area on our file server (Win 2003) where our copiers deposit scans so users can pick them up. The structure is ..\Scanned Files\Username\ where the username is that user's name. ...
1
by: traceable1 | last post by:
I created a new database instance, but I forgot to script out the scheduled jobs before I wiped out the original database instance. I have attached the original msdb database as msdb_old onto the...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.