<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eTechTips &#187; Programming</title>
	<atom:link href="http://www.etechtips.com/articles/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.etechtips.com</link>
	<description>Your Technical resource</description>
	<lastBuildDate>Thu, 29 Jul 2010 04:01:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python: AttributeError: &#8216;getopt&#8217; module has no attribute &#8216;GetoptError&#8217;</title>
		<link>http://www.etechtips.com/2010/07/28/python-attributeerror-getopt-module-has-no-attribute-getopterror/</link>
		<comments>http://www.etechtips.com/2010/07/28/python-attributeerror-getopt-module-has-no-attribute-getopterror/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 16:31:22 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/2010/07/28/python-attributeerror-getopt-module-has-no-attribute-getopterror/</guid>
		<description><![CDATA[So I was figuring out how to parse command line arguments with python and using the getopt module with the following code

#!/usr/bin/env python
import sys
import getopt

def main(argv):
   grammar = "some.xml"
   try:
      opts,args = getopt.getopt(argv,"hg:d",["help","grammar="]
   except getopt.GetoptError:
      usage()
    [...]]]></description>
			<content:encoded><![CDATA[<p>So I was figuring out how to parse command line arguments with python and using the getopt module with the following code</p>
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>
#!/usr/bin/env python
import sys
import getopt

def main(argv):
   grammar = "some.xml"
   try:
      opts,args = getopt.getopt(argv,"hg:d",["help","grammar="]
   except getopt.GetoptError:
      usage()
      sys.exit(2)

if __name__ == "__main__":
    main(sys.argv[1:]
</code></pre>
<p>And I was getting the following error:</p>
<p>AttributeError: &#8216;getopt&#8217; module has no attribute &#8216;GetoptError&#8217;</p>
<p>So my first problem was that I had named my script getopts.py and after renaming the script, I got the same error.  Well you now need to remove the getopts.pyc file that was generated from your earlier running of the poorly named script. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2010/07/28/python-attributeerror-getopt-module-has-no-attribute-getopterror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to address perl arguments</title>
		<link>http://www.etechtips.com/2010/07/28/how-to-address-perl-arguments/</link>
		<comments>http://www.etechtips.com/2010/07/28/how-to-address-perl-arguments/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 05:04:19 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=124</guid>
		<description><![CDATA[If you are using perl, you may find it necessary to take some command line arguments to your scripts.  When that time comes, there is a very handy variable ARGV that contains the passed in arguments.
To get the total number of arguments passed into the script you will need to use the following:
$totcommandargs = #$ARGV [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using perl, you may find it necessary to take some command line arguments to your scripts.  When that time comes, there is a very handy variable ARGV that contains the passed in arguments.</p>
<p>To get the total number of arguments passed into the script you will need to use the following:</p>
<p>$totcommandargs = #$ARGV + 1</p>
<p>is equal to the number of arguments passed in to the Perl script.</p>
<p>Note: you need to add one to the count to get the correct number of variables.</p>
<p>To address the variables you use the following to address the first argument: $ARGV[0]</p>
<p>will address the first argument</p>
<p>Since arrays are addressed by n-1, to get the first element you use 0 {zero}, for the second 1, for the third {2}, and so on.</p>
<p>$0 will give the name of the currently executing script.</p>
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>
#!/usr/bin/perl

$argcount =  $#ARGV +1;
print "The script $0 has $argcount arguments\n";

for( $i = 0; $i &lt; $argcount;$i++)
{
print $ARGV[$i] . "\n";
}

</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2010/07/28/how-to-address-perl-arguments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing JVM options to Maven</title>
		<link>http://www.etechtips.com/2010/06/30/passing-jvm-options-to-maven/</link>
		<comments>http://www.etechtips.com/2010/06/30/passing-jvm-options-to-maven/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 15:55:05 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=120</guid>
		<description><![CDATA[If you are using maven to build your projects , then you might have found an out of memory condition in your tests.  Well, setting the MAVEN_OPTS variable with JVM specific options will help with this.
Example:
MAVEN_OPTS=-Xmx1024
Depending on what environment you are in, you will need to set this variable.
This will give the JVM more 1024 [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using maven to build your projects , then you might have found an out of memory condition in your tests.  Well, setting the MAVEN_OPTS variable with JVM specific options will help with this.</p>
<p>Example:</p>
<p>MAVEN_OPTS=-Xmx1024</p>
<p>Depending on what environment you are in, you will need to set this variable.</p>
<p>This will give the JVM more 1024 megs to work with and you can customize the number to fit your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2010/06/30/passing-jvm-options-to-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java formatting a number with leading zeroes</title>
		<link>http://www.etechtips.com/2009/07/17/java-formatting-a-number-with-leading-zeroes/</link>
		<comments>http://www.etechtips.com/2009/07/17/java-formatting-a-number-with-leading-zeroes/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 05:10:56 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[formatting]]></category>

		<guid isPermaLink="false">http://www.etechtips.com/?p=53</guid>
		<description><![CDATA[Recently, I had a Java project that needed to encode a set of numbers and I needed a fixed number of digits used for each number.  I found the DecimalFormat class a good solution for my needs.
Here is a snippet of code to show a simple way to format a number with a fixed [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I had a Java project that needed to encode a set of numbers and I needed a fixed number of digits used for each number.  I found the DecimalFormat class a good solution for my needs.</p>
<p>Here is a snippet of code to show a simple way to format a number with a fixed number of digits.</p>
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>import java.text.DecimalFormat;

class TestEncoder
{
        public static void main(String[] args)
        {
                // This program expects one integer
                // argument and places it in the num1
                // variable. This program is not very
                // robust as to watch for no arguments
                // or to check if the argument is not
                // an integer.
                String num1 = args[0];
                String output;

                // This creates the Decimal Format instance
                // and assigns the formatting that we want
                // to use, in this case three characters .
                DecimalFormat dfmt =
                             new DecimalFormat(&quot;000&quot;);

                // This does the work of formatting the number
                // passed in on the command line to be at least
                // three digits.
                output = dfmt.format(new Integer(num1));

                // This just displays the results of the
                // dfmt.format(new Integer(num1)) command.
                System.out.println(&quot;Output: &quot; + output);
}
}
</code></pre>
<p>The Decimal format allows for many more formatting options for numbers.</p>
<p>Make sure to look a the API docs for the version of Java that you are using:</p>
<p>http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2009/07/17/java-formatting-a-number-with-leading-zeroes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Variable Argument lists in functions for C and C++</title>
		<link>http://www.etechtips.com/2009/05/26/using-variable-argument-lists-in-functions-for-c/</link>
		<comments>http://www.etechtips.com/2009/05/26/using-variable-argument-lists-in-functions-for-c/#comments</comments>
		<pubDate>Wed, 27 May 2009 03:18:37 +0000</pubDate>
		<dc:creator>ecdown</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://etechtips.com/?p=7</guid>
		<description><![CDATA[Using Variable Argument lists in functions for C\C++
In C there are times when you may want to have a variable amount of arguments passed into a function.  This can be accomplished when you pass the ellipses(&#8230;)  in as the last argument on your function.  The ellipses ,(&#8230;),  stands for zero  or more arguments.
There are a [...]]]></description>
			<content:encoded><![CDATA[<p>Using Variable Argument lists in functions for C\C++</p>
<p>In C there are times when you may want to have a variable amount of arguments passed into a function.  This can be accomplished when you pass the ellipses(&#8230;)  in as the last argument on your function.  The ellipses ,(&#8230;),  stands for zero  or more arguments.<br />
There are a set of functions available to handle accessing this data and making it available to your function.</p>
<p>The source code example displays a version of the code for a printf like function and how to handle the optional arguments.</p>
<p>One note is that the arguments passed in to this function are not typed.  The handling of the argument depends on either a specific type passed in(ints only) or as is the case of the example, a formatted string to define the types of the arguments. What this means is that if you pass random sets of arguments, (such as ints, strings,chars, floats) there is no data type that is directly associated to the variable being passed in.</p>
<p>Required include file<br />
#include &lt;stdarg.h&gt;<br />
/* Old include &lt;varargs.h&gt; From before ISO C standard, GNU C compilers still support this */</p>
<p>Available functions:<br />
Macro: va_start(va_list , last-required argument)<br />
This sets up the pointer for va_list with the avaiable argument list.</p>
<p>Macro: va_arg(va_list, type)</p>
<p>This returns the value of the next argument and modifies the va_list argument<br />
to point to the subsequent(next) argument.  The type of the value returned by<br />
va_arg is type as specified in the call. type must be a self promoting type<br />
not char or short int) that matches the type of the actual argument.</p>
<p>Macro: va_end(va_list)</p>
<p>This ends the processing of the va_list element and subsequent va_arg calls<br />
may no longer work.  Note: In the GNU C library implementation this does nothing<br />
and is used for portability.</p>
<p>Sample Function Call:</p>
<pre style="border: 1px dashed #999999; padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: #000000; background-color: #eeeeee; font-size: 12px; line-height: 14px; width: 100%;"><code>  int int1 = 1;

    char char1 = "s";

    char *str1 = "test";

    /* Sample function call. */
    ecdprintf("Int=%d Char=%c String=%s\n",int1,char1,str1);

Sample Code follows:

int ecdprintf(const char *pstr, ...)

{
    const char *lstr;
    va_list argp;
    int lint;
    char *lchar;
    char strarr[255];

    /* This is the start of vararg processing. The first argument is the
         container argument of the vararg list and the second argument
         is the last fixed parameter passed into the function. */

    va_start(argp, fmt);
    for(lstr = pstr; *lstr = '\0'; lstr++)
    {
        if (*lstr != '%')
        {
            putchar(*lstr);
            continue;
        }

        switch(*++lstr)
        {
            case 'd':
                i = va_arg(argp,int);
                s = itoa(i,strarr, 10);
                putchar(i);
                break;
            case 'c':
                i = va_arg(argp, int);
                putchar(i);
                break;
             case 's':
                 lchar = va_arg(argp,char *);
                 fputs(lchar,stdout);
                 break;
              case 'x':
                 i = va_arg(argp,int);
                 s = itoa(i, fmtbuf, 16);
                 fputs(lchar, stdout);
                 break;
               case '%':
                  putchar('%');
                  break;

               default:
                    break;

             }

    }

    va_end(argp);

    }

}
</code></pre>
<p>This example created the a simple printf like function using characters within the string to let the function know how to deal with the extra variables used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.etechtips.com/2009/05/26/using-variable-argument-lists-in-functions-for-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
