HomePortalFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 A better, and simpler Scar tutorial

Go down 
AuthorMessage
The Fellow
Admin
avatar

Posts : 100
Join date : 2010-04-28
Age : 26
Location : In my head, dreaming up how to shake up the world

PostSubject: A better, and simpler Scar tutorial   Sat Oct 23, 2010 4:43 pm

Hello one and all! I am here to talk to you about SCAR, and what technically is SCAR. SCAR is a scripting language that allows for automation, as to make scripts that run and play a game for you for example. It is based on pascal (One of the languages any of us has yet to cover) but is really simple! You can download the SCAR Divi at freddy1990.net. I could go into the history of it, but let us just start scriping in this crazy SCAR way.

In this tutorial I am covering the basics of how to make a hello world, and going to get into some of the functions that allow us to automate.
______________________________________________________________________________________
Hello, SCAR!

To write a hello world that just prints 'hello world' is a pretty easy concept. The code looks something like:
Code:

program HelloScar;
begin
writeln('Hello, world');
end.

The first part is telling the compiler that the program is called HelloScar, and the rest of the stuff after it is either the lines of code that belong to it, or any including for it.

The begin is stating that this is where the program HelloScar starts with its code. You might be thinking "well, would that not be taken care when you stated that the program was called HelloScar?" my answer: not entirely. You can have stuff before the begin, like includes, and functions(or procedures) you write, also variables, and constants.

writeln will write the string you tell it to into the debugger(below the area that displays that the script was compiled and what not.) Strings are known to be strings by the ' '. In scar you can not use "" like in most programming languages, I know, bummer right?


finally there is the end. It states that it is the end of what ever it's beginning was, the period after it tells the compiler that it is the final end, and nothing after it is anything that belongs to the script.

So pretty simple stuff right?

______________________________________________________________________________________
But Mommy, I don't want to do it!

Ok, now let us grind into the more fun part of this whole deal: automation!

But before that, I am going to tell you one of my favorite lines of code in SCAR, the ClearDebug. It does what you might be thinking it does, clears the debug box. When I am scripting in scar I tend to use that atleast once, maybe twice, depending on what I am doing.

Ok, automation, I am just going to run you through a simple automation to open up word and type a friendly message to you.

Let us think of what we want it to do, in the order it needs to do it.

first it needs to start up word.

Then, it needs to print a message.

Simple enough, right? now, let us think of how one could do this, well, we could just double click on the icon, but I think that for re-usability of the code, we could make a procedure that would open up the run
box, then type the .exe name of what ever program we want (in this case, microsoft word.) I already have a procedure from a library I am making for this, so we do not need to worry about that. Now, when word opens, we would want to click on the sheet to tell it that we are typing, then we need to use some funtion to simulate typing. Hmm, ok let us get to work!

first let us name the program.
Code:
program GhostWriter;

Now let us include my library! The syntax may be a bit weird, but you get used it, and is pretty simple just follow the pattern {.include libname.scar} and it will include it.
Code:
{.include TFLib.scar}
Note: If you use the format above, the library you are including MUST be in the same folder as the program you are trying to write, or in the include folder. If in the include folder, you should not need to use that line of code.

Ok, now we got the power of all the functions that I wrote, let us start writing what we want to use!
Code:

StartProg(WINWORD);
First we want to open microsoft word, this function is from my library


Code:

Wait(300);
now, we wait for the program to load, on most computers I work on 300 seems about right to wait, but tweaking will need to happen.

Code:

SwitchWindSize;
function I made to switch the window size from its current state (usually restore) to the other (Maximized).

Code:

ClickMouse(511,388, True);
with this piece o' code from the general library, we tell the mouse to click at 511 (our x value), 388 (y value), and that the click is a left click (the Truth).

Code:

TypeKeys('Hello, I am your friendly neighborhood Ghost Writer!');
This is the end of all this pain! the typing of the message! TypeKeys is a function that will type the keys in a human like way. there is other functions that will do this for you, but TypeKeys is the simplest.

Code:

end.

w00t! congratulations! You got your first automation script in scar done! You even made a hello world! don't you feel so proud?


The library for my functions is at: http://compilecrazy.forumotion.net/scar-f30/the-tflib-now-t69.htm


Last edited by The Fellow on Tue Oct 26, 2010 8:05 pm; edited 1 time in total
Back to top Go down
View user profile http://compilecrazy.forumotion.net
 
A better, and simpler Scar tutorial
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Compile Crazy :: Scripting :: Computer-based Scripting :: SCAR :: For Beginners-
Jump to: