Need help in Commands

I want to declare a global variable and put today's date into that variable and then enter the variable in a Date field (in application).

Can anyone help me here by writing the commands for above ?
And also let me know how I can change the Date format permanently to 09/29/2014 i.e. MM/DD/YYYY ?



  • Bhabani,

    Here is a simple example page that shows a few different ways to declare global variables:
    You can either formally declare them at the beginning of a handler, or you can declare them in-line.

    To change the date format to MM/DD/YYYY, you will need to set the date property of the timeformat global property to "%m/%d/%Y", like this:
    put the -- puts "%m/%d/%y"
    put the date -- puts "09/30/14"
    set the to "%m/%d/%Y"
    put the date -- puts "09/30/2014"

    You can also use the pre-defined variable "Today" to reference today's date, but it uses the international date format "%Y-%m-%d", and that would have to be formatted separately. For instance, if I execute
    Put Today
    The result displayed is "2014-09-30". In case you are interested, you can see a list of all the constants and pre-defined variables here:

    For more information on how to customize time and date formats, please see The TimeFormat global property under "Working with Dates and Times" here:


  • Thank you Elizabeth for your reply.

    But I am unable to access the variable in a Script of one Suite which I have expressed as global in another Script of same Suite.

    global variable_name

    Isn't it the syntax for making a variable global or am I missing something here ?
    Do I need to declare that variable in the Script where I am using it ? If so then please let me know how to do this ?
  • Yes, it is necessary to declare global variables in each handler. You must either declare it at the beginning of the handler, or in line as you use it. While it requires slightly more code (one word!), it can help to declare in-line just to help you keep track of which variables are global and which aren't.

    This page talks about declaring global and universal variables:

    This page talks about the different kinds of variables and how they work (their scope, etc) including global variables:

    Here is a simple example:
    put "happy" into global myvar
    to handle myhandler
    	global myvar -- declared at the beginning of hte handler
    	log myvar
    end myhandler

    Contents of Called.Myfunction:
    to handle myfunction
    	log global myvar -- declared in line
    end myfunction
  • Thank you Elizabeth.
Sign In or Register to comment.