473,768 Members | 8,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

* 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 2029
On 17 Jan 2006 06:42:51 -0800, in comp.lang.c , "ern"
<er*******@gmai l.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.c om, 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
2252
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 value="1">Main</option> <option value="2">Main > Computers</option> <option value="4">Main > Computers > Hardware </option>
6
1579
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 name. but they put their own script at the bottom of everypage, that places their banner at the top, im looking for a way to stop that script, Let me know. --
1
1348
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 subscriber first lesson on the day of subscription
6
10719
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
4801
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 page. Each time when asp.net page refresh the script function is to be called and has to be replaced all files in server folder.
0
1332
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
906
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 field in the excel files. I need to find the Duplicate entries in excel. Plz somebody provide me a macro to find Duplicate entries. Thanx
1
1480
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. Unfortunately not everyone cleans up after themselves, so I need a script that can prune out all the files older than 30 days but leave the folders. I plan to set this up as a scheduled task to be run each morning after backups run. I know...
1
2085
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 new instance, but I need a script to pull out the require information from sysjobs, etc. to recreate the jobs. Please help! Thanks, trace
0
9407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10175
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9961
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9843
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5283
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.