Jump to content
AC Tool Forums

Recommended Posts

Hi Wabbit, thank you so much for lots and lots of helps!

I was trying to start doing some macros in divide, but I can´t make even a mousepos. I read the help pages and downloaded some of your codes, imported some "uses" that I think may behave as librarys but I can´t write a line! Even searched youtube, but I guess divide is in beta.

Am I missing something trivial? If I learn the basics I think I may be able to apply a lot of things I learned in AC tool! Any help is welcomed and if you can't I totally get it. You guys helped me a lot already!

TY!

 

Share this post


Link to post
Share on other sites

Okay, the above post was sent to me by PM. I thought that it would be best that this conversation took place here. So that others may see what is happening, and hopefully learn from it.

@minimxI will gladly help you with your script. So please post here a script for Divide using just the MousePos command that you have tried.

 

 

Share this post


Link to post
Share on other sites

Now, as for the Uses clause. The Uses clause is like the Include that AC Tool, and other scripting languages, have.

  • It allows you to include other files, usually script files, that has additional script code to be used in the script.
  • It allows you to include libraries that has various code/methods/functions/features/etc. that you plan to use in your script.

In Divide, if you have a script unit file that has certain procedures/functions/global variables/etc that you have created. And you save the script unit with the name MyRoutines. Then when you create a script that has a procedure/function that uses a any of the code from the MyRoutines unit file. You would add MyRoutines to the Uses clause.

Now, if your script uses multiple script unit files. Then for each unit file that uses code from the MyRoutines unit file. You must add the MyRoutines to the Uses clause to each of the unit files that uses its code.

 

Now for the most part. The only thing that you will be adding to the Uses clause is Divide, for Divide's library, or the name of a unit file. And for the most part the only exception to this. Is when you are creating a Form for use in your script. Or when you are using DataSets in your script.

But, there will be times when you are creating a script. That you will have need to use a routine from anyone of the Pascal libraries. And when that happens, you just need to add the library's name to the Uses clause. Pascal has many premade libraries that has various routines to perform most anything.

Out of all of these libraries that Pascal has available for use. Not all of them have been implemented in Divide's script engine. And of those that has been, many of them have not been fully implemented. For the most part it is because of how the script engine was created.  And for the rest, it is because those libraries, or portions of the libraries, just has not been implemented yet.

 

So, an empty main script unit file should look like:

uses
  Divide;



begin


end;

And a empty script unit file should look like this:

Uses
  Divide;
  
  
  

 

Share this post


Link to post
Share on other sites

This one doens't work:

uses
  Divide;

var
  MainForm: TForm2;


procedure mp
begin
  MousePos(610, 370);
end

 

This one works:

uses
  Divide, Classes, Graphics, Controls, Forms, Dialogs, Unit2, SysUtils;
  //tried to paste here all uses I could thind in orther to make the mouse pos work
var
  MainForm: TForm2;


procedure mp
begin
MousePos(610, 370);


I did it! Woooow I feel like a god! Thank you soooo much!

 

 

EDITED by The WABBIT: to make it easier to read in the darker themes.

Share this post


Link to post
Share on other sites

When Divide first opens up. It will have a new project already created, think of this script as nothing more than a sample. A sample to show you how to create a script that will display a empty form.

Now, the project has to Unit files. The first unit file, Unit1, is the Main Unit file. The second unit file, Unit2, is a Form Unit.

 

So for your basic learning of using Divide. What you can do, is you do the following:

  1. Option 1:
    1. Select the Unit2 tab.
    2. On the Menu Left click on File > Close File. The Unit2 will close and Unit1 will remain.
    3. In Unit1, Replace everything listed in the Uses clause with Divide. Make sure to terminate the line with a ';'  (semicolon).
    4. Delete lines 4 and 5, see below
      var
        MainForm: TForm2;
    5. Now, Delete everything between the begin and end;.

 

Once you have done that you should now have a empty Main Script Unit. That looks like this:

uses
  Divide;

begin

end;

 

Share this post


Link to post
Share on other sites

Now that you have a empty Main Unit. I need to explain to you a few things. That you may not have learn from the various tutorials you've looked at.

 

Main Unit:

uses
  Divide;

begin

end;

 

First, The section between the begin and end keywords. Is what is called the main block. For those that may have done any programming in Java. This is the same as the Main Procedure in Java.

When your script starts running, as is the same in Pascal and Java. If the script has more than one unit, also called a script project. The script engine goes to the Main Unit of the project and looks for the Main block. If the script only consists of one unit file. Then the script engine looks for the Main block within the unit. In either case, once the script engine starts to execute the code between within the Main block.

Second, them empty space between the Uses clause and the keyword begin. I where you will define various Global variables, Global constants, procedures, functions, etc. To include forward statements for procedures and functions. (I'll explain this latter when you have need of them.)

 

Now, you can like many people have done in AC Tool. You can create your whole script to be performed in the Main block. But, that would mean your script would have to be very small.

So, it would be best to create various procedures and functions to perform certain actions. And then use, or call, those procedures/functions from the Main block, or even from within other procedure and/or functions.

Now, you can also go and do as the vast majority of the people that use AC Tool. And place all the code (the procedures, functions, etc.) in the Main unit. Just so that they have a script that is in a single file. And this is fine with a script that is only has no more than a 150 lines of code. After that it become a major chore to read the code and to attempt to debug the script, even in AC Tool.

So, think about your script as you create it. If the script is ending up to be a very long script, or a somewhat complicated script. Then seriously think about putting code into  other units. Try to group such code based on their function and when you save the unit. Give it a name based on the general function of the code in it.

Share this post


Link to post
Share on other sites

Now, lets get to doing some coding. So, now start with your empty Main unit. And add the following lines to the Main block:

Delay(2, 'sec');
MousePos(610, 370);


Your script should look like the following:

uses
  Divide;

begin
  Delay(2, 'sec');
  MousePos(610, 370);
end;

Now, if you click on the Run button. You will see that the cursor will stay above the Run button for 2 seconds and then move the coords in the MousePos.

 

Now, lets try this with a procedure. Before the Main block add the following lines:

procedure MoveMouse
begin

end;

Once you have done that, add the same two lines as before. But, change the coords in the MousePos to 125, 560.

Now we have a procedure and in order to use it. We need to call the procedure from the Main block. So, in the Main block on a line right below the MousePos command add the following line:

MoveMouse;

Your script should now look like the following:

uses
  Divide;

  procedure MoveMouse
  begin
    Delay(2, 'sec');
    MousePos(125, 560);
  end;
begin
  Delay(2, 'sec');
  MousePos(610, 370);
  MoveMouse;
end;

Now if you were to run the script. The mouse with stay above the Run button for 2 seconds. Then it would move to the coordinates 610, 370. And then 2 seconds later it will move to the coordinates 125, 560.

 

Now, lets try one more thing. Let's add another unit to the script. So, click on the New Unit button. (The one that looks like a scroll.) At this point I want you to copy Lines 1 through 8 from Unit1. And paste them into the new unit Unit2. And then change the coordinates in the MousePos to 630, 156. And you need to rename the procedure to MoveMouse2.

And then in Unit1 you need to add Unit2 to the Uses clause. And then add MoveMouse2; right below MoveMouse; in the Main block.

Your script should now have two units and both units should look like the following:

Unit1

uses
  Divide, Unit2;

  procedure MoveMouse
  begin
    Delay(2, 'sec');
    MousePos(125, 560);
  end;
begin
  Delay(2, 'sec');
  MousePos(610, 370);
  MoveMouse;
  MoveMouse2;
end;

 

Unit2

uses
  Divide;

  procedure MoveMouse
  begin
    Delay(2, 'sec');
    MousePos(630, 156);
  end;
  

 

Now, if you were to run the script. You will see that the cursor will move to three different locations. With a delay of 2 seconds prior to each move.

 

Share this post


Link to post
Share on other sites

I have some codes in ac tool with thousands of lines, they are hellish, but they work. Divide works faster with a small main block? Or is it just for organization? I will make procedures outside the main unit that will be called, but for now I like to keep the core codes together while I am developing, if possible and efficient

 

Edited by minimx

Share this post


Link to post
Share on other sites

uses
 Divide, unit2;
     procedure movemouse
begin
  Delay(2, 'sec');
  MousePos(610, 370);
end;

begin
   movemouse;
   movemouse2;
   delay (3000)
   MousePos(585, 414




unit2 
:1655 The HTML Clipboard  

    procedure movemouse2
begin
  Delay(2, 'sec');
  MousePos(690, 370);



Everything works!!! Wooooow, nice!

Share this post


Link to post
Share on other sites
8 hours ago, minimx said:


uses
 Divide, unit2;
     procedure movemouse
begin
  Delay(2, 'sec');
  MousePos(610, 370);
end;

begin
   movemouse;
   movemouse2;
   delay (3000)
   MousePos(585, 414




unit2 
:1655 The HTML Clipboard  


    procedure movemouse2
begin
  Delay(2, 'sec');
  MousePos(690, 370);



Everything works!!! Wooooow, nice!

you need to make sure to have a ending end statement. all your posted code code does not have any.

Share this post


Link to post
Share on other sites

OK!

When I control +c I must have missed them! Sorry. I will post the same code but with a variable, so it won't be redundant
 

uses
  Divide, unit2;

var
  x

procedure movemouse
begin
  Delay(2, 'sec');
  MousePos(610, 370);
end;

begin
  x := 2050
  movemouse;
  movemouse2;
  delay(x);
  MousePos(585, 414);
end;

 

unit2

procedure movemouse2
begin
  Delay(2, 'sec');
  MousePos(690, 370)
end;



 

Share this post


Link to post
Share on other sites

Ok, three things.

  1. Try Ctrl+A and then Ctrl+C to copy and paste.
  2. When you post your code. Plz use the Code block to post them.
    1. In the post editor, the code block looks like the <> or </> on the menu bar. (depending on the Theme you are using.)
    2. Once you have placed your code in then code editor.
    3. On the lower right hand side of the Code editor, you will see ComboBox with HTML selected.
    4. Click on the ComboBox and select 'No Syntax Highlighting'.
    5. Then Click on Insert Into Post button.
  3. Your unit2 is missing some code. Specifically the Uses clause. Now if you are not using Unit2.
    1. Select the Unit2 tab.
    2. Click on File > Close File.
    3. And then remove Unit2 from the Uses clause in your Main script file.
    4. And then remove the line with MouseMove2 from the Main Block.
    5. And while you are at it. Go ahead and remove the MouseMove procedure and the line with MouseMove in the Main Block.

 

Share this post


Link to post
Share on other sites
Ok:


uses
 Divide, unit2;
    var
    x


     procedure movemouse
begin
  Delay(2, 'sec');
  MousePos(610, 370);
end;

begin
x := 2000
   movemouse;
   movemouse2;
   delay (x)  ;
   MousePos(585, 414 );
   
end;




Unit2

uses
  divide, Classes, Graphics, Controls, Forms, Dialogs;


    procedure movemouse2
begin
  Delay(2, 'sec');
  MousePos(690, 370);
  end

 

Share this post


Link to post
Share on other sites

Alright then. In Unit2 remove the addition libraries from the Uses clause.

And other then formatting, in both units, I don't see anything problems with what you got.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and to our Privacy Policy.