HTML Kit site requirements.

HTML editor / Support Document
HomeHTML-Kit downloadsAdd-ins that update and extend HTML-Kit's capabilitiesSoftware and authoring support channelsRegister -- download add-ons and support HTML-KitOnline tools for HTML-Kit users
 

Support Document

 Home > Support > Support Documents > Plugins > How to: Create a text in...
 
 
How to: Create a text input box in hkScript
The information in this document applies to:
 Summary

This document describes how to create a text input box in hkScript.
 
 Details

How to create a text input box using the UI_GetFileName function

As the name suggests, the UI_GetFileName function was designed to prompt the user to type in or browse for a file name. Although it is not a general purpose input function, since it is available in hkScript distributed with build 290 and hkScript 290.1, it can be used to prompt the user for a single line of text.

--- cut here ---
function __UI_GetFileName(sTitle, sPrompt, sFilter, sDefExt, sDefFileName)
{
  var sResult = "", pIN = 0, pOUT = 0;

  sResult = NULL;
  pIN  = hkp_DataNew();
  pOUT = hkp_DataNew();
  hkp_DataAdd(pIN, "FUNC_NAME", "UI_GetFileName");
  hkp_DataAddInt(pIN, "FUNC_PARAM1", 0);
  hkp_DataAdd(pIN, "FUNC_PARAM2", sDefFileName);
  hkp_DataAdd(pIN, "FUNC_PARAM3", sTitle);
  hkp_DataAdd(pIN, "FUNC_PARAM4", sPrompt);
  hkp_DataAdd(pIN, "FUNC_PARAM5", sFilter);
  hkp_DataAdd(pIN, "FUNC_PARAM6", sDefExt);
  if(hkp_Func(pIN, pOUT))
  {
    if(hkp_DataGetInt(pOUT, "FUNC_PARAM1", 0))
    {
      var sFileName = "";
      if(hkp_DataGet(pOUT, "FUNC_PARAM2", &sFileName))
      {
        sResult = sFileName;
      }
    }
  }
  hkp_DataFree(pOUT);
  hkp_DataFree(pIN);

  return sResult;
}

{
  var sInput = "", sFileFilter = "All Files (*.*)|*.*";
  // get some input
  sInput = __UI_GetFileName( "Caption", "Prompt:", sFileFilter, "", "" );
  // show input
  Alert( sInput, "You Entered:" );
}
--- cut here ---

How to implement a text input box using an external hks module

This solution requires the use of an external hkScript module. Since support for external modules was added in hkScript 290.1, this method is not backward compatible with hkScript distributed with build 290.

First download and install the hksGUI module using the "Tools | Install | Plugin" main menu option (do not unzip, install the *.zip file to preserve the directory structure). The Delphi source code used to create the hksGUI module is available here.

Use the following code to invoke the InputBox function implemented in the hksGUI module:

--- cut here ---
{
  // load the hksGUI module and refer to it as "gui"
  if( use( "hksGUI", "gui" ) )
  {
    var sInput = "";
    // get input
    sInput = gui.InputBox( "InputBox", "Your name:" );
    // show input
    Alert( sInput, "You entered:" );
  }
}
--- cut here ---
 
 
 
Document ID: H000129
Reviewed On: 18-Aug-2001
THE INFORMATION IN THIS DOCUMENT IS PROVIDED ON AN AS-IS BASIS WITHOUT WARRANTY OF ANY KIND. PROVIDER SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL PROVIDER BE LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, SPECIAL OR INCIDENTAL DAMAGES, EVEN IF PROVIDER HAS BEEN ADVISED BY "USER" OF THE POSSIBILITY OF SUCH POTENTIAL LOSS OR DAMAGE. "USER" AGREES TO HOLD PROVIDER HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES, LIABILITIES AND EXPENSES.