Talk:Wizard scripts

From Code::Blocks
Revision as of 22:32, 11 February 2013 by LETARTARE (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

=> 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;
}