Include Problem

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 514
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Include Problem

Post by PepsiHog » Sun Jan 08, 2012 8:00 pm

MS v12, WinXP Sp3

Hello,
I know normally you'd like to see my script, but in this case my script is approaching 3000 lines long. My dialog is extensive taking up nearly 2000 lines. I tried placing the dialog in a sep file and then including it in my main macro. But it causes it to freeze up. If all in one macro, it doesn't freeze at all.

Is there some way to be able to do the include without it freezing? I tried a delay, that didn't help.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
JRL
Automation Wizard
Posts: 3506
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 09, 2012 4:55 pm

The following creates a 7000 line dialog and includes the scp file into the running script. It takes a few seconds to start but nothing I would call freezing up. On the other hand, if you run this in the editor it will take a very long time. Might actually appear to freeze.

Code: Select all

DeleteFile>%temp_dir%BigDialog.scp

LabelToVar>DialogStart,data1
WriteLn>%temp_dir%BigDialog.scp,wres,data1

Let>kk=0
Repeat>kk
  Add>kk,1
  Let>Ypos={(%kk%*20)-20}
  WriteLn>%temp_dir%BigDialog.scp,wres,object Edit%kk%: TEdit
  WriteLn>%temp_dir%BigDialog.scp,wres,  Left = 0
  WriteLn>%temp_dir%BigDialog.scp,wres,  Top = %Ypos%
  WriteLn>%temp_dir%BigDialog.scp,wres,  Width = 500
  WriteLn>%temp_dir%BigDialog.scp,wres,  Height = 20
  WriteLn>%temp_dir%BigDialog.scp,wres,  Text = 'This is line %kk%'
  WriteLn>%temp_dir%BigDialog.scp,wres,end
Until>kk=1000

LabelToVar>DialogEnd,data2
WriteLn>%temp_dir%BigDialog.scp,wres,data2

Include>%temp_dir%BigDialog.scp

Show>dialog1,

/*
DialogStart:
Dialog>Dialog1
object Dialog1: TForm
  Left = 504
  Top = 143
  HelpContext = 5000
  AutoScroll = True
  BorderIcons = [biSystemMenu]
  Caption = 'AutoGenerated'
  ClientHeight = 223
  ClientWidth = 500
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
*/

/*
DialogEnd:
end
EndDialog>Dialog1
*/

User avatar
PepsiHog
Automation Wizard
Posts: 514
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

hello

Post by PepsiHog » Sat Jan 14, 2012 9:25 pm

Thanks JRL!

I think you're right. It just appears to be frozen. I didn't think of this because it loads so quickly when all in one, but now that you said that, the process of importing the macro probably does take a lot of time.

I'm just sticking with one script. No real benefits (in this case) to having an included script.

(dot dot dot) That starts me thinking. When would it be beneficial to have an included macro? I mean are there times when it's better to have a script included?
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

elbabbo
Newbie
Posts: 2
Joined: Fri Feb 10, 2012 10:52 am

Post by elbabbo » Fri Feb 10, 2012 10:56 am

I Have a Scipt File i use to just store a bunch of varibles that I use for multiple other scripts, about 100 of them, in that way when i change these varibles i only have to go and change them once in one file

Also made a bunch of Scripts that are called by a main script, in this way functions of this script are Modular and i can just Modify each individual script, include or not include them Dependant on what i want the main script to do

I Love the Include Command =)

User avatar
JRL
Automation Wizard
Posts: 3506
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Feb 10, 2012 5:00 pm

PepsiHog wrote:When would it be beneficial to have an included macro? I mean are there times when it's better to have a script included?
elbabbo,
Great uses for the Include> function.

Another use for the Include> function is to "include" dynamically created scripts. You can also run dynamically created script using the Macro> function but the script pauses until the Macro> run script has completed. Using Include>, the dynamic script becomes a working part of the original script.

The following example creates a dynamic script that contains a dialog with all the icons from your desktop in a menu

Code: Select all

DeleteFile>%temp_dir%temp_menu_script.scp
GetFileList>%desktop_dir%\*.*,list,;
Separate>List,;,item

LabelToVar>DialogStart,DS_data
WriteLn>%temp_dir%temp_menu_script.scp,wres,DS_data
Let>kk=0
Repeat>kk
  add>kk,1
  Let>value=item_%kk%
  ExtractFileName>value,fName
  Let>Ypos=%kk%*25
  WriteLn>%temp_dir%temp_menu_script.scp,wres,object MSButton%kk%: tMSButton
  WriteLn>%temp_dir%temp_menu_script.scp,wres,  Left = 8
  WriteLn>%temp_dir%temp_menu_script.scp,wres,  Top = %Ypos%
  WriteLn>%temp_dir%temp_menu_script.scp,wres,  Width = 500
  WriteLn>%temp_dir%temp_menu_script.scp,wres,  Height = 25
  WriteLn>%temp_dir%temp_menu_script.scp,wres,  Caption = '%fName%'
  WriteLn>%temp_dir%temp_menu_script.scp,wres,end
Until>kk=item_count

LabelToVar>DialogEnd,DE_data
WriteLn>%temp_dir%temp_menu_script.scp,wres,DE_data

Let>kkk=0
Repeat>kkk
  Add>kkk,1
  Let>value=item_%kkk%
  WriteLn>%temp_dir%temp_menu_script.scp,wres,AddDialogHandler>Dialog1,MSButton%kkk%,OnClick,Process(%value%)
Until>kkk=item_count

Include>%temp_dir%temp_menu_script.scp
Wait>0.5
DeleteFile>%temp_dir%temp_menu_script.scp

Show>dialog1,

/*
DialogStart:
Dialog>Dialog1
object Dialog1: TForm
  ClientHeight = 500
  ClientWidth = 520
  Autoscroll = True
  Caption = 'Menu'
*/

/*
DialogEnd:
end
EndDialog>Dialog1
*/

SRT>Process
  ExecuteFile>%Process_var_1%
END>Process

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts