Batch file processing
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Batch file processing
I have a program that takes an input file and re-formats it to an output file in the same directory. I would like to be able to run it as part of a batch processing system where i can have a command line step that looks like: Formatter <inputfile> <outputfile>. I assume that must be possible but need some help getting started. Any ideas or examples would be appreciated.
Thanks,
Larry
Thanks,
Larry
Re: Batch file processing
Hi Larry,
hm, does a "simple" repeat loop not work for this?
Best
Klaus
hm, does a "simple" repeat loop not work for this?
Best
Klaus
Re: Batch file processing
Hi Klaus,
What I want to be able to do its to type a command into the DOS console (if the is the correct way to say it) that would look like this:
MyReformatApp <pathofInpotFile>,<pathofOutputFile> and my LiveCode application (MyReformatApp.exe) would translate the file from one format to another and then shut itself down. Does that make sense? This program could then be called multiple times from a batch process. The batch process would have the repeat loop facilities.
Larry
What I want to be able to do its to type a command into the DOS console (if the is the correct way to say it) that would look like this:
MyReformatApp <pathofInpotFile>,<pathofOutputFile> and my LiveCode application (MyReformatApp.exe) would translate the file from one format to another and then shut itself down. Does that make sense? This program could then be called multiple times from a batch process. The batch process would have the repeat loop facilities.
Larry
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Batch file processing
You can run a LiveCode standalone as a faceless process by calling it with -ui in the command line, e.g.:
path/to/my/livecodeapp.exe -ui someotherparams
...where "someotherparams" are any arguments you want to pass to your app, which can be obtained through the $1, $2, $3, etc. global variables. If you need to know the number of arguments passed to it your can check $#.
path/to/my/livecodeapp.exe -ui someotherparams
...where "someotherparams" are any arguments you want to pass to your app, which can be obtained through the $1, $2, $3, etc. global variables. If you need to know the number of arguments passed to it your can check $#.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Batch file processing
AHA!
Sorry, did not understand that you want to control your LC app via SHELL!
Yes, what Richard says
Sorry, did not understand that you want to control your LC app via SHELL!
Yes, what Richard says

Re: Batch file processing
Klaus and Richard,
Here are the guts of what I have so far and it seems to work. I am not sure how it will behave in a batch environment however. Should there be some kind of wait command before quitting to give time for the process to complete? Is a message sent back from the console that I can trap to know when to quit?
Thanks for any ideas,
Larry
Here are the guts of what I have so far and it seems to work. I am not sure how it will behave in a batch environment however. Should there be some kind of wait command before quitting to give time for the process to complete? Is a message sent back from the console that I can trap to know when to quit?
Code: Select all
on startup
hide this stack
put word 1 to -1 of lower($1) into lInput
if lInput is empty or lInput="-h" or lInput="/?" then
put "A path for a valid input file is required. Path for output file is optional." into tHelp
write tHelp to stdOut
quit
end if
put word 1 to -1 of lower($2) into lOutput
if lOutput is empty then
set the itemdelimiter to slash
put the last item of lInput into tFile
put item 1 to -2 of lInput into lOutPut
put slash & "Out_" & tFile after lOutput
end if
put formatFile(lInput) into tResult
put tResult into URL ("File:" & lOutput)
quit
end startup
Larry
Re: Batch file processing
Can my LiveCode program be made to have the ability to stop the batch processing until my program has completed the file conversion and quit?
Larry
Larry
Re: Batch file processing
See http://livecode.wikia.com/wiki/Shell
Then you can use
shell() function stop livecode until the command is executed.The current handler pauses until the shell returns its result. If the command was successful but did not return anything, the shell function returns empty.
Then you can use
Code: Select all
close this stack
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w