Difference between revisions of "Talk:Wizard scripts"

From CodeBlocks
Jump to: navigation, search
(script primitive functions)
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
=> '''add into 'How do I create a new wizard?''''  
 
=> '''add into 'How do I create a new wizard?''''  
  
 +
The first thing to know is that each wizard script contains
  
When creating a script wizard, it may contain basic primitive functions
+
- global variables :
 +
:example
  
*'''void BeginWizard ()'''  
+
<code>ObjectName <- _T("name")</code>
 +
  <code>ObjectIndex <- 0</code>
  
mandatory for all wizards and which contains different entry pages
 
  
 +
- and basic primitive functions :
  
for a project :
 
  
*'''bool SetupProject (project)'''
+
*'''Common and mandatory for all types of project :'''
  
*'''bool SetupTarget (target, IsDebug)'''
+
which contains different entry pages, see [[Wizard Scripting Commands#Adding wizard pages|Adding wizard pages ]]
  
 +
<code>void BeginWizard ()</code>
  
  
for a single target (within a project)
+
* '''For a project :'''
  
*'''bool SetupTarget (target, IsDebug)'''
+
**to get the template files in a project
  
 +
<code>wxString GetFilesDir ()</code>
  
for an item to be defined by the user
+
**to get generated files in a project
  
*'''bool SetupCustom ()'''
+
<code>wxString GetGeneratedFile(index)</code>'''
  
 +
**to create project
 +
<code>bool SetupProject (project)</code>
  
for file creation
 
  
*'''wxString Createfiles ()'''
+
*'''For a single target (within a project)'''
  
 +
<code>bool SetupTarget (target, IsDebug)</code>
  
to get the template files in a project
 
  
*'''wxString GetFilesDir ()'''
+
*'''For file creation'''
  
 +
<code>wxString CreateFiles ()</code>
  
toget generated files in a project
 
  
*'''wxString GetGeneratedFile(index)'''
+
*'''For an item to be defined by the user'''
  
 +
<code>bool SetupCustom ()</code>
  
  
These functions will be performed by the manager wizard.
+
:These functions will be performed by the manager wizard.
 +
 
 +
 
 +
Then you should do is read about [[Wizard Scripting Commands|Wizard Scripting Commands ]] and use it as a reference on what commands are accepted and what their syntax is.
 +
 
 +
 
 +
Here is a simple example taken from the distribution wizard.script 12.11
 +
 
 +
////////////////////////////////////////////////////////////////////////////////
 +
//
 +
// Code::Blocks new file wizard script
 +
//
 +
// Project: Empty file
 +
// Author:  Yiannis Mandravellos
 +
//
 +
////////////////////////////////////////////////////////////////////////////////
 +
function BeginWizard()
 +
{
 +
    local info_msg = _T("Welcome to the new empty file wizard!\n" +
 +
                        "This wizard will guide you to create a new empty file.\n\n" +
 +
                        "When you 're ready to proceed, please click \"Next\"...");
 +
    // add builtin pages
 +
    Wizard.AddInfoPage(_T("EmptyFileIntro"), info_msg); // intro
 +
    Wizard.AddFilePathPage(false); // select filename (no header guard for source files)
 +
}
 +
function CreateFiles()
 +
{
 +
    local fname = Wizard.GetFileName();
 +
    local ed    = GetEditorManager();
 +
    if (IsNull(ed))
 +
    {
 +
        ShowError(_T("The wizard could not locate the editor manager."));
 +
    }
 +
    local ed_new = ed.New(fname);
 +
    if (IsNull(ed_new))
 +
    {
 +
        ShowError(_T("The wizard could not create a new file.\n" +
 +
                    "Maybe the target folder is write-protected?"));
 +
    }
 +
    else
 +
    {
 +
        // succeeded -> add file to project if needed
 +
        if (Wizard.GetFileAddToProject())
 +
        {
 +
            AddFileToTargets(Wizard, fname);
 +
        }
 +
    }
 +
    return fname;
 +
}

Latest revision as of 00:32, 12 February 2013

=> add into 'How do I create a new wizard?'

The first thing to know is that each wizard script contains

- global variables :

example
ObjectName <- _T("name") 
ObjectIndex <- 0 


- and basic primitive functions :


  • Common and mandatory for all types of project :

which contains different entry pages, see Adding wizard pages

void BeginWizard () 


  • For a project :
    • to get the template files in a project
wxString GetFilesDir ()
    • to get generated files in a project
wxString GetGeneratedFile(index)
    • to create project
bool SetupProject (project)


  • For a single target (within a project)
bool SetupTarget (target, IsDebug)


  • For file creation
wxString CreateFiles ()


  • For an item to be defined by the user
bool SetupCustom ()


These functions will be performed by the manager wizard.


Then you should do is read about Wizard Scripting Commands and use it as a reference on what commands are accepted and what their syntax is.


Here is a simple example taken from the distribution wizard.script 12.11

////////////////////////////////////////////////////////////////////////////////
//
// Code::Blocks new file wizard script
//
// Project: Empty file
// Author:  Yiannis Mandravellos
//
////////////////////////////////////////////////////////////////////////////////
function BeginWizard()
{
   local info_msg = _T("Welcome to the new empty file wizard!\n" +
                       "This wizard will guide you to create a new empty file.\n\n" +
                       "When you 're ready to proceed, please click \"Next\"...");
   // add builtin pages
   Wizard.AddInfoPage(_T("EmptyFileIntro"), info_msg); // intro
   Wizard.AddFilePathPage(false); // select filename (no header guard for source files)
}
function CreateFiles()
{
   local fname = Wizard.GetFileName();
   local ed    = GetEditorManager();
   if (IsNull(ed))
   {
       ShowError(_T("The wizard could not locate the editor manager."));
   }
   local ed_new = ed.New(fname);
   if (IsNull(ed_new))
   {
       ShowError(_T("The wizard could not create a new file.\n" +
                    "Maybe the target folder is write-protected?"));
   }
   else
   {
       // succeeded -> add file to project if needed
       if (Wizard.GetFileAddToProject())
       {
           AddFileToTargets(Wizard, fname);
       }
   }
   return fname;
}