<?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>NiceLabel.Blog</title>
	<atom:link href="http://www.primozic.net/nl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.primozic.net/nl</link>
	<description>Everything you wanted to know about NiceLabel</description>
	<lastBuildDate>Fri, 21 Oct 2011 15:48:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Password Protected Forms &#8211; A Warning</title>
		<link>http://www.primozic.net/nl/password-protected-forms-a-warning/</link>
		<comments>http://www.primozic.net/nl/password-protected-forms-a-warning/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 15:44:56 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceForm]]></category>
		<category><![CDATA[actions]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[niceform]]></category>
		<category><![CDATA[properties]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/password-protected-forms-a-warning/</guid>
		<description><![CDATA[As I already mentioned in one of the previous posts, you can protect your forms so nobody can modify them or even view details of actions. You have to be careful though that you do not forget the password, because there is no way you can decrypt the form actions without knowing the password. If [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in one of the previous <a href="http://www.primozic.net/nl/actions-in-niceform-and-nicelabel-portal/">posts</a>, you can protect your forms so nobody can modify them or even view details of actions. You have to be careful though that you do not forget the password, because there is no way you can decrypt the form actions without knowing the password. If you forget the password, you will have to configure form again.</p>
<p>I would suggest using one of the password managers for storing the passwords because these days it is not easy to remember them all. I use <a href="http://keepass.info/">KeePass</a> because it is free and I can also use the password database on the Android phone, but you can use any one you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/password-protected-forms-a-warning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Label Structure 2.9</title>
		<link>http://www.primozic.net/nl/label-structure-2-9/</link>
		<comments>http://www.primozic.net/nl/label-structure-2-9/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 18:01:06 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Utils]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[label structure report]]></category>
		<category><![CDATA[nicelabel]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/label-structure-2-9/</guid>
		<description><![CDATA[New label of Label Structure utility is now available for download. The following has changed from the last release: Support for sorting objects, variables, functions and databases by clicking the column header was added. Information about functions now also includes a list of input variables. ID column was added to the variables information. All VB [...]]]></description>
			<content:encoded><![CDATA[<p>New label of Label Structure utility is now available for <a title="Label Structure" href="http://ftp.nicelabel.com/software/addons/Label%20Structure/LabelStructure.exe">download</a>. The following has changed from the last release:</p>
<ul>
<li>Support for sorting objects, variables, functions and databases by clicking the column header was added. </li>
<li>Information about functions now also includes a list of input variables. </li>
<li>ID column was added to the variables information. </li>
<li>All VB scripts can now be extracted from a .lbl file by using Tools-&gt;Extract VB scripts from label file. </li>
<li>Possibility to add all .lbl files from a selected folder and all subfolders when setting variable length, changing graphics paths, setting printer or extracting VB scripts from .lbl file. </li>
<li>A bug in &quot;Set paths&quot; command where not all selected labels were processed was fixed. </li>
<li>Support for creating DOT graph files for selected label was added. This allows you to visually see the connections between different parts of a label like variables, objects, and functions. You will have to use <a href="http://www.graphviz.org/">GraphViz</a> to view the graphs though. </li>
</ul>
<p>&#160;</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/10/Address.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Label Graph" border="0" alt="Label Graph" src="http://www.primozic.net/nl/wp-content/uploads/2011/10/Address_thumb.png" width="518" height="150" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/label-structure-2-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formatting numbers and date/time using current locale in NiceForm and NiceLabel Portal</title>
		<link>http://www.primozic.net/nl/formatting-numbers-and-datetime-using-current-locale-in-niceform-and-nicelabel-portal/</link>
		<comments>http://www.primozic.net/nl/formatting-numbers-and-datetime-using-current-locale-in-niceform-and-nicelabel-portal/#comments</comments>
		<pubDate>Tue, 17 May 2011 11:41:53 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceForm]]></category>
		<category><![CDATA[NiceLabel Portal]]></category>
		<category><![CDATA[date/time]]></category>
		<category><![CDATA[niceform]]></category>
		<category><![CDATA[nicelabel portal]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/formatting-numbers-and-datetime-using-current-locale-in-niceform-and-nicelabel-portal/</guid>
		<description><![CDATA[Locale is a set of parameters that defines the user's language, country and any special variant preferences that the user wants to see in their user interface. Usually a locale identifier consists of at least a language identifier and a region identifier. General settings usually include the following display format settings: Number format setting Character [...]]]></description>
			<content:encoded><![CDATA[<p>Locale is a set of parameters that defines the user's language, country and any special variant preferences that the user wants to see in their user interface. Usually a locale identifier consists of at least a language identifier and a region identifier. </p>
<p>General settings usually include the following display format settings:</p>
<ul>
<li>Number format setting </li>
<li>Character classification, case conversion settings </li>
<li>Date/Time format setting </li>
<li>String collation setting </li>
<li>Currency format setting </li>
<li>Paper size setting </li>
<li>Other minor settings      </li>
</ul>
<p>The locale settings are about formatting output given a locale. For example you can see some of the settings for the Slovenian locales on my machine in the screenshot below.</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/05/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Region and Language" border="0" alt="Region and Language" src="http://www.primozic.net/nl/wp-content/uploads/2011/05/image_thumb3.png" width="481" height="554" /></a> </p>
<p>Even more options are available if you click the “Additional settings…” button.</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/05/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Customize Number, Currency, Time and Date Format" border="0" alt="Customize Number, Currency, Time and Date Format" src="http://www.primozic.net/nl/wp-content/uploads/2011/05/image_thumb4.png" width="481" height="587" /></a> </p>
<p>To view or modify these changes&#160; in Windows 7 you have to follow these steps:</p>
<ol>
<li>Click <b>Start &gt; Control Panel</b>. </li>
<li>Double-click the <b>Region and Language</b> icon. The <b>Region and Language</b> dialog box appears. </li>
</ol>
<p>Please note that you have to be logged in with an account with Administrative Privileges in order for this to work. </p>
<h3>Working with Locales in Python Scripts</h3>
<p>To work with locales in Python scripts in NiceForm you have to use the <em>locale</em> module. Your script would typically start with something like this:</p>
<pre class="brush: py;">import locale
locale.setlocale(locale.LC_ALL, '')</pre>
<p>This sets the locale for all categories (number format settings, currency format settings, date/time settings, etc.) to the user’s default setting.</p>
<p>You can also set the locale to a specific one. For example to change current locale in your Python script to German, you could use the following code:</p>
<pre class="brush: py;">locale.setlocale(locale.LC_ALL, 'deu_deu')</pre>
<p>or to French</p>
<pre class="brush: py;">locale.setlocale(locale.LC_ALL, 'fra_fra')</pre>
<p>Unfortunately <em>locale</em> module is not supported in IronPython (that is used to implement scripting in NiceLabel Portal) so you have to write a little different code. To obtain information about current locale (or current culture as it is called in Silverlight) you have to use the following code:</p>
<pre class="brush: py;">import System
culture = System.Threading.Thread.CurrentThread.CurrentCulture</pre>
<p>
  <br />And to set the culture you would do this:</p>
<pre class="brush: py;">from System.Globalization import *
culture = CultureInfo(&quot;de-DE&quot;);
System.Threading.Thread.CurrentThread.CurrentCulture = culture</pre>
<h3>Formatting Numbers Using Current Locale</h3>
<p>The following code converts values of two NiceForm (or NiceLabel Portal) variables (that are represented as strings) into floating point numbers using the current locales, calculates the difference between them and assigns this new value to the third variable value (again as a string value). </p>
<pre class="brush: py;">import sys
if sys.platform == 'silverlight':
    import System
    culture = System.Threading.Thread.CurrentThread.CurrentCulture
    number1 = System.Single.Parse(originalSellingPrice.Value, culture.NumberFormat)
    number2 = System.Single.Parse(sellingPrice.Value, culture.NumberFormat)
    diff = number1 - number2
    subtract_price.Value = diff.ToString(&quot;F&quot;)
else:
    import locale
    locale.setlocale(locale.LC_ALL, '')
    number1 = locale.atof(originalSellingPrice.Value)
    number2 = locale.atof(sellingPrice.Value)
    diff = number1 - number2
    subtract_price.Value = locale.format(&quot;%.2f&quot;, diff)</pre>
<p>
  <br />Script should work in both NiceLabel Portal (code block after the <em>if</em> statement) and NiceForm (code block after the <em>else</em> statement).</p>
<h3>Formatting Date/Time Using Current Locale</h3>
<p>Again code for NiceLabel Portal and NiceForm is a little different. It does however in both cases display date and time in different formats using user’s current locale settings.</p>
<pre class="brush: py;">import sys
if sys.platform == 'silverlight':
    import System
    dt = System.DateTime.Now
    d1.Value = &quot;Long time: &quot; + dt.ToLongTimeString()
    d2.Value = &quot;Long date: &quot; + dt.ToLongDateString()
    d3.Value = &quot;Short time: &quot; + dt.ToShortTimeString()
    d4.Value = &quot;Short date: &quot; + dt.ToShortDateString()
    d5.Value = &quot;Day of the week: &quot; + dt.ToString(&quot;ddd&quot;) + &quot; (abbreviated), &quot; + dt.ToString(&quot;dddd&quot;) + &quot; (full)&quot;
    d6.Value = &quot;Month name: &quot; + dt.ToString(&quot;MMM&quot;) + &quot; (abbreviated), &quot; + dt.ToString(&quot;MMMM&quot;) + &quot; (full)&quot;
else:
    from datetime import date
    import time
    import locale
    locale.setlocale(locale.LC_ALL, '')   

    date1 = date.today();
    d1.Value = time.strftime(&quot;Long time: %H:%M:%S&quot;);
    d2.Value = date1.strftime(&quot;Long date: %d.%B %Y&quot;);
    d3.Value = time.strftime(&quot;Short time: %X&quot;);
    d4.Value = date1.strftime(&quot;Short date: %x&quot;);
    d5.Value = date1.strftime(&quot;Day of the week: %a (abbreviated), %A (full)&quot;);
    d6.Value = date1.strftime(&quot;Month name: %b (abbreviated), %B (full)&quot;);</pre>
<p>
  </p>
<p>To use a specific locale (French in this case) you would do this:</p>
<pre class="brush: py;">import sys
if sys.platform == 'silverlight':
    import System
    from System.Globalization import *
    culture = CultureInfo(&quot;fr-FR&quot;);
    System.Threading.Thread.CurrentThread.CurrentCulture = culture
    dt = System.DateTime.Now
    d1.Value = &quot;Long time: &quot; + dt.ToLongTimeString()
    d2.Value = &quot;Long date: &quot; + dt.ToLongDateString()
    d3.Value = &quot;Short time: &quot; + dt.ToShortTimeString()
    d4.Value = &quot;Short date: &quot; + dt.ToShortDateString()
    d5.Value = &quot;Day of the week: &quot; + dt.ToString(&quot;ddd&quot;, culture) + &quot; (abbreviated), &quot; + dt.ToString(&quot;dddd&quot;, culture) + &quot; (full)&quot;
    d6.Value = &quot;Month name: &quot; + dt.ToString(&quot;MMM&quot;, culture) + &quot; (abbreviated), &quot; + dt.ToString(&quot;MMMM&quot;, culture) + &quot; (full)&quot;
else:
    from datetime import date
    import time
    import locale
    locale.setlocale(locale.LC_ALL, 'fra_fra')   

    date1 = date.today();
    d1.Value = time.strftime(&quot;Long time: %H:%M:%S&quot;);
    d2.Value = date1.strftime(&quot;Long date: %d.%B %Y&quot;);
    d3.Value = time.strftime(&quot;Short time: %H:%M&quot;);
    d4.Value = date1.strftime(&quot;Short date: %d.%b.%Y&quot;);
    d5.Value = date1.strftime(&quot;Day of the week: %a (abbreviated), %A (full)&quot;);
    d6.Value = date1.strftime(&quot;Month name: %b (abbreviated), %B (full)&quot;);</pre>
<p>
  <br />Related posts:</p>
<p><a title="http://www.primozic.net/nl/manipulating-date-and-time-using-python-in-niceform-and-nicelabel-portal/" href="http://www.primozic.net/nl/manipulating-date-and-time-using-python-in-niceform-and-nicelabel-portal/">http://www.primozic.net/nl/manipulating-date-and-time-using-python-in-niceform-and-nicelabel-portal/</a> </p>
<p><a title="http://www.primozic.net/nl/working-with-modules-in-python-scripts-in-niceform-and-nicelabel-portal/" href="http://www.primozic.net/nl/working-with-modules-in-python-scripts-in-niceform-and-nicelabel-portal/">http://www.primozic.net/nl/working-with-modules-in-python-scripts-in-niceform-and-nicelabel-portal/</a> </p>
<p><a title="http://www.primozic.net/nl/working-with-strings-in-python-scripts-in-niceform/" href="http://www.primozic.net/nl/working-with-strings-in-python-scripts-in-niceform/">http://www.primozic.net/nl/working-with-strings-in-python-scripts-in-niceform/</a> </p>
<p><a title="http://www.primozic.net/nl/python-scripting-in-niceform-and-nicelabel-portal/" href="http://www.primozic.net/nl/python-scripting-in-niceform-and-nicelabel-portal/">http://www.primozic.net/nl/python-scripting-in-niceform-and-nicelabel-portal/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/formatting-numbers-and-datetime-using-current-locale-in-niceform-and-nicelabel-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How can I work with files in NiceLabel Portal?</title>
		<link>http://www.primozic.net/nl/how-can-i-work-with-files-in-nicelabel-portal/</link>
		<comments>http://www.primozic.net/nl/how-can-i-work-with-files-in-nicelabel-portal/#comments</comments>
		<pubDate>Wed, 11 May 2011 10:27:54 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceLabel Portal]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[nicelabel portal]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/how-can-i-work-with-files-in-nicelabel-portal/</guid>
		<description><![CDATA[NiceLabel Portal uses Microsoft Silverlight as its underlying technology. Because Silverlight is a browser-based plug-in, it has by default the lowest security privileges to ensure a safe browsing experience. This restriction introduces a number of challenges, especially when it comes to working with files. For example you do not have direct access to files on [...]]]></description>
			<content:encoded><![CDATA[<p>NiceLabel Portal uses Microsoft Silverlight as its underlying technology. Because Silverlight is a browser-based plug-in, it has by default the lowest security privileges to ensure a safe browsing experience. This restriction introduces a number of challenges, especially when it comes to working with files. For example you do not have direct access to files on your drive from NiceLabel Portal. There is a solution though that might solve most of the problems.</p>
<p>Isolated storage is a great way to store data on the end user’s local computer. It’s flexible in that it works in all modes of Silverlight operation (in-browser, out-of-browser, elevated out-of-browser) and works as a virtual file system. Isolated storage is tied to individual user and lies outside of the browser cache. This means that even if a user clears browser history, files within isolated storage will remain intact. </p>
<p>To work with Isolated Storage in NiceLabel Portal you will have to use Python scripts. Here are scripts for some of the most common scenarios you might encounter when working with Isolated Storage. </p>
<h3>Basics of Isolated Storage</h3>
<p>The <em>System.IO.IsolatedStorage</em> namespace provides the functionality to work with a user’s isolated storage area. This area can be accessed through the IsolatedStorageFile class, which exposes two methods that retrieve an IsolatedStorageFile. These methods are GetUserStoreForApplication and GetUserStoreForSite. The GetUserStoreForApplication can be used to retrieve a user’s isolated storage for a specific Silverlight application, defined by the full URL to the .xap. The GetUserStoreForSite method gets a user’s isolated storage for the entire domain. </p>
<pre class="brush: py;">from System.IO.IsolatedStorage import *
store = IsolatedStorageFile.GetUserStoreForApplication()</pre>
<p>Once you’ve retrieved an IsolatedStorageFile, you can use it to manage a virtual file system, which gives you the ability to work with files and directories.</p>
<h3>Checking if Isolated Storage is enabled</h3>
<p>Before using Isolated Storage you should check if it is enabled because user can disable it in the “Microsoft Silverlight Configuration” dialog box under the “Application Storage” page). To configure the Silverlight plug-in (not just the Application Storage) a user can right-click the opened solution in the NiceLabel Portal or simply find Microsoft Silverlight in the Windows Start menu.</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/05/image2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.primozic.net/nl/wp-content/uploads/2011/05/image_thumb2.png" width="536" height="373" /></a> </p>
<p>To programmatically check if Isolated Storage is enabled you can use the following code:</p>
<pre class="brush: py;">from System.IO.IsolatedStorage import *

isEnabled = IsolatedStorageFile.IsEnabled
if (isEnabled):
    # do something
else:
    # display error message</pre>
<h1></h1>
<h3>Checking the Available Space</h3>
<p>By default in-browser application gets 1 MB of free space. The <em>IsolatedStorageFile</em> class exposes two read-only properties that inform you of an isolated storage area’s memory situation. The first property, <em>Quota</em>, holds the total number of bytes allocated to the storage area. The other property,&#160; <em>AvailableFreeSpace</em>, represents the number of bytes remaining in the Isolated Storage.</p>
<pre class="brush: py;">from System.IO.IsolatedStorage import *

store = IsolatedStorageFile.GetUserStoreForApplication()
usedSize.Value = &quot;Used size: &quot; + str(store.UsedSize) + &quot; bytes&quot;
quota.Value = &quot;Quota: &quot; + str(store.Quota) + &quot; bytes&quot;
availableFreeSpace.Value = &quot;Available free space: &quot; + str(store.AvailableFreeSpace) + &quot; bytes&quot;</pre>
<h3>Requesting more space</h3>
<p>To increase the Isolated Storage quota, you must call the <em>IncreaseQuotaTo</em> method from a user-initiated event, such as in an event handler for a button-click event. Unfortunately because of the way action execution is implemented in NiceLabel Portal you will not be able to increase the quota by a Python script even if you have the script defined on the “On click” event of the button object. You will have to write your own application that calls the above mentioned method or contact NiceLabel support for help. </p>
<h3>Listing the contents of the virtual file system</h3>
<p>The <em>IsolatedStorageFile</em> class provides two methods that enable you to retrieve the items within a storage area. The first method, <em>GetDirectoryNames</em>,&#160; enables you to get the names of the directories that match a certain pattern; the <em>GetFileNames</em> method allows you to search for files that match a particular filter. To perform the search just provide the path to the file or directory. If the directory or file name is found an array with one element will be returned. Otherwise, an empty set will be returned. Wildcard characters can also be used to match file names (the * character matches any number of characters, and the ? character matcher any single character.</p>
<pre class="brush: py;">from System.IO.IsolatedStorage import *

store = IsolatedStorageFile.GetUserStoreForApplication()
results1 = store.GetFileNames(&quot;*.txt&quot;);
results2 = store.GetFileNames(&quot;Folder/*&quot;);
results3 = store.GetFileNames(&quot;configfile*&quot;); 

results4 = store.GetDirectoryNames(&quot;*&quot;);

# convert array of directory names into a string separated by commas
if len(results4) &gt; 0:
    all = &quot;,&quot;.join(results)</pre>
<h3>Creating directories within Isolated Storage</h3>
<p>The <em>IsolatedStorageFile</em> class has a method called <em>CreateDirectory</em> that enables you to create a directory within the isolated storage space.</p>
<pre class="brush: py;">from System.IO.IsolatedStorage import *

store = IsolatedStorageFile.GetUserStoreForApplication()
store.CreateDirectory(&quot;Folder1&quot;)
store.CreateDirectory(&quot;Folder1/Sub/Leaf&quot;)</pre>
<p>&#160;</p>
<p>The first call to <em>CreateDirectory</em> is pretty simple; it creates a subdirectory under an existing </p>
<p>directory. The second call shows an additional feature. If you provide an absolute path to a subdirectory further down the line, all missing directories along the way will automatically be added. Once a directory exists, you can create files in it. </p>
<h3>Checking if an item exists</h3>
<pre class="brush: py;">from System.IO.IsolatedStorage import *

store = IsolatedStorageFile.GetUserStoreForApplication()

msg2.Value = str(store.FileExists(fileName.Value))
if store.FileExists(fileName.Value):
    msg.Value = &quot;File already exists.&quot;
else:
    msg.Value = &quot;File does not exist!&quot;</pre>
<p>&#160;</p>
<h3>Removing items from Isolated Storage</h3>
<pre class="brush: py;">from System.IO.IsolatedStorage import *

store = IsolatedStorageFile.GetUserStoreForApplication()

if store.FileExists(fileName.Value):
    store.DeleteFile(fileName.Value)

if store.DirectoryExists(directoryName.Value):
    store.DeleteDirectory(directoryName.Value)</pre>
<h3>Possible problems</h3>
<p>There are a few problems that you should be aware of when working with Isolated Storage.</p>
<ol>
<li>Administrators can set disk quota per user and assembly which means there is no guarantee on space available. So it is very important to add exception handling to your code. </li>
<li>Computer can be locked down by administrative security policies preventing applications from writing to the Isolated Storage. </li>
<li>Even though Isolated Storage is placed in a hidden folder it is possible, with a bit of effort, to find the folder. Therefore the data stored is not completely secure as users can change or remove files. </li>
</ol>
<h3>Isolated Storage Best Practices</h3>
<p>When you use isolated storage, following these guidelines will help you avoid problems and make the most of the protection isolated storage provides.</p>
<ul>
<li>Wrap all calls to isolated storage within try/catch blocks to be resilient to potential IsolatedStorageExceptions, which can be thrown if isolated storage is disabled or if the store has been deleted. </li>
<li>Keep isolated storage paths as small as possible to prevent the internal full path from reaching the 260-character limit. </li>
<li>Encrypt sensitive data stored in isolated storage. </li>
<li>Use IsolatedStorageSettings to store objects and simple settings in isolated storage. </li>
</ul>
<pre class="brush: py;">from System.IO.IsolatedStorage import *

# Write to application settings
settings = IsolatedStorageSettings.ApplicationSettings
settings.Add(&quot;FirstName&quot;, FirstName.Value)
settings.Add(&quot;LastName&quot;, LastName.Value)

# Read from application settings
FirstName.Value = settings[&quot;FirstName&quot;]
LastName.Value = settings[&quot;LastName&quot;]

# Remove just first name from application settings
settings.Remove(&quot;FirstName&quot;)

# Clear all settings
settings.Clear()</pre>
<p>Please note that all code samples in this post will only work in NiceLabel Portal. Even though you will write them in NiceForm you will only be able to test them in NiceLabel Portal.</p>
<p>You can find all the samples in one <a href="http://www.primozic.net/nl/wp-content/uploads/2011/05/IsolatedStorage.zip">sample NiceForm file</a> (it is in a .zip file so you will have to uncompress it first).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/how-can-i-work-with-files-in-nicelabel-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How can I fix the &#8220;The &#8216;Microsoft.Jet.OLEDB.4.0&#8242; provider is not registered on the local machine.&#8221; error in NiceLabel Portal?</title>
		<link>http://www.primozic.net/nl/how-can-i-fix-the-the-microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine-error-in-nicelabel-portal/</link>
		<comments>http://www.primozic.net/nl/how-can-i-fix-the-the-microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine-error-in-nicelabel-portal/#comments</comments>
		<pubDate>Tue, 03 May 2011 07:59:26 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceLabel Portal]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[nicelabel portal]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/how-can-i-fix-the-the-microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine-error-in-nicelabel-portal/</guid>
		<description><![CDATA[Usually you get this error when you try to use Microsoft Excel file in NiceLabel Portal solution – in a form or in a label file when NiceLabel Portal is installed on a 64-bit operating system. Although I would not suggest using Excel files as a database for anything else but a demo, you can [...]]]></description>
			<content:encoded><![CDATA[<p>Usually you get this error when you try to use Microsoft Excel file in NiceLabel Portal solution – in a form or in a label file when NiceLabel Portal is installed on a 64-bit operating system. Although I would not suggest using Excel files as a database for anything else but a demo, you can get around this particular problem.</p>
<p>What you have to do is to set “Enable 32-Bit Applications” property of the “EPWebPrintingAppPool” application pool in IIS (Internet Information Services) to “True”.</p>
<p>In IIS 7 you have to open the list of Application Pools, right click the selected application pool and select “Advanced Settings” in the pop up menu.</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/05/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="IIS - List of application pools" border="0" alt="IIS - List of application pools" src="http://www.primozic.net/nl/wp-content/uploads/2011/05/image_thumb.png" width="517" height="282" /></a> </p>
<p>When “Advanced Settings” dialog box is shown change the “Enable 32-Bit Applications” property to “True”.</p>
<p> <a href="http://www.primozic.net/nl/wp-content/uploads/2011/05/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="IIS - Advanced settings for application pool" border="0" alt="IIS - Advanced settings for application pool" src="http://www.primozic.net/nl/wp-content/uploads/2011/05/image_thumb1.png" width="474" height="484" /></a>
<p>Now all you have to do is reload your solution file in the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/how-can-i-fix-the-the-microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine-error-in-nicelabel-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How can I select label print quantity from database in NiceLabel?</title>
		<link>http://www.primozic.net/nl/how-can-i-select-label-print-quantity-from-database-in-nicelabel/</link>
		<comments>http://www.primozic.net/nl/how-can-i-select-label-print-quantity-from-database-in-nicelabel/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 06:42:44 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceLabel]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[nicelabel]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[quantity]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/how-can-i-select-label-print-quantity-from-database-in-nicelabel/</guid>
		<description><![CDATA[Selecting print quantity from database in NiceLabel Pro is quite easy. Run NiceLabel and create new label. Add new database by selecting “Data Access…” option in the “Data” menu to open the “Data Access Functions” dialog box. Once in the “Data Access Functions” dialog box, click the “New” button to open the”Database Access” dialog box. [...]]]></description>
			<content:encoded><![CDATA[<p>Selecting print quantity from database in NiceLabel Pro is quite easy.</p>
<ol>
<li>Run NiceLabel and create new label.</li>
<li>Add new database by selecting “Data Access…” option in the “Data” menu to open the “Data Access Functions” dialog box.</li>
</ol>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/image.png"><img style="display: inline; border-width: 0px;" title="NiceLabel - Database Access Functions" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/image_thumb.png" border="0" alt="NiceLabel - Database Access Functions" width="355" height="427" /></a></p>
<ol start="3">
<li>Once in the “Data Access Functions” dialog box, click the “New” button to open the”Database Access” dialog box.</li>
</ol>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/image1.png"><img style="display: inline; border-width: 0px;" title="NiceLabel - Database Access" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/image_thumb1.png" border="0" alt="NiceLabel - Database Access" width="429" height="489" /></a></p>
<ol start="4">
<li>Define or browse for the database.</li>
<li>Once you have selected the database you would like to use, go to the “Fields” tab and select fields you need.</li>
</ol>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/image2.png"><img style="display: inline; border-width: 0px;" title="NiceLabel - Database Access Field Definition" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/image_thumb2.png" border="0" alt="NiceLabel - Database Access Field Definition" width="429" height="489" /></a></p>
<ol start="6">
<li>Go to “Data Retrieving” page.</li>
<li>In the section “Number of Labels per Record”, select “Number of labels is defined at print time” and then “stored in a database field”.</li>
</ol>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/image3.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/image_thumb3.png" border="0" alt="image" width="429" height="489" /></a></p>
<ol start="8">
<li>Select the database field that contains the quantity.</li>
<li>Click OK to close the “Database Access” window.</li>
<li>Click Close to close the “Database Access” window.</li>
<li>Add objects to the label and save the label.</li>
</ol>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/image4.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/image_thumb4.png" border="0" alt="image" width="549" height="484" /></a></p>
<ol start="12">
<li>When you start printing and the “Print” dialog is shown, you will see that the “Variable quantity (defined from database field)” option is selected.</li>
</ol>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/image5.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/image_thumb5.png" border="0" alt="image" width="492" height="415" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/how-can-i-select-label-print-quantity-from-database-in-nicelabel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chaining comparison operators in Python</title>
		<link>http://www.primozic.net/nl/chaining-comparison-operators-in-python/</link>
		<comments>http://www.primozic.net/nl/chaining-comparison-operators-in-python/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 20:18:30 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/chaining-comparison-operators-in-python/</guid>
		<description><![CDATA[One of the little known facts about Python that can come handy is a possibility to chain comparison operators like this: x = 5; print 3 &#60; x &#60; 10; print x &#60; 10 &#60; x*10; or x == y == z or even x is y is z]]></description>
			<content:encoded><![CDATA[<p>One of the little known facts about Python that can come handy is a possibility to chain comparison operators like this:</p>
<pre class="brush: py;">x = 5;
print 3 &lt; x &lt; 10;
print x &lt; 10 &lt; x*10;</pre>
<p>or</p>
<pre class="brush: py;">x == y == z</pre>
<p>or even</p>
<pre class="brush: py;">x is y is z</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/chaining-comparison-operators-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actions in NiceForm and NiceLabel Portal</title>
		<link>http://www.primozic.net/nl/actions-in-niceform-and-nicelabel-portal/</link>
		<comments>http://www.primozic.net/nl/actions-in-niceform-and-nicelabel-portal/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 19:22:50 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceForm]]></category>
		<category><![CDATA[NiceLabel Portal]]></category>
		<category><![CDATA[actions]]></category>
		<category><![CDATA[niceform]]></category>
		<category><![CDATA[nicelabel portal]]></category>
		<category><![CDATA[nicewatch]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/actions-in-niceform-and-nicelabel-portal/</guid>
		<description><![CDATA[One of the main strengths of NiceForm and NiceLabel Portal are actions that let you build workflows that accomplish manual chores quickly, efficiently and effortlessly. You don’t have to know any scripting languages or write any code (unless you want to). Instead, you create and execute workflows simply by dragging and dropping actions. Currently there [...]]]></description>
			<content:encoded><![CDATA[<p>One of the main strengths of NiceForm and NiceLabel Portal are actions that let you build workflows that accomplish manual chores quickly, efficiently and effortlessly. You don’t have to know any scripting languages or write any code (unless you want to). Instead, you create and execute workflows simply by dragging and dropping actions. Currently there are 29 actions available in NiceForm. They are grouped in 6 groups: <strong>Labeling</strong>, <strong>Variables</strong>, <strong>Batch Printing</strong>, <strong>Database</strong>, <strong>Connectivity</strong> and <strong>Other</strong>.</p>
<p><strong>Labeling actions:</strong> “Open label”, “Print label”, “Set printer”, “Send custom commands”, “Run command file”, “Close label”, “Define printer settings”.</p>
<p><strong>Variables actions:</strong> “Set variable”, “Save variable data”, “Load variable data”.</p>
<p><strong>Batch printing actions:</strong> “For every label”, “For every record in a table”, “For loop”.</p>
<p><strong>Database actions:</strong> “Refresh database”, “Execute SQL statement”, “Import data into database”.</p>
<p><strong>Connectivity actions:</strong> “Read data from serial port”, “Write data to serial port”, “Send data to TCP/IP port”, “Acquire image”.</p>
<p><strong>Other actions:</strong> “Open another form”, “Open document/program”, “Refresh previews”, “Quit”, “Execute script”, “Move focus to object”, “View log file”, “Browse for file or folder”, “Verify license”.</p>
<h3>Where can actions be used in the form?</h3>
<p>Actions are executed on certain events that happen on the form. Form itself has three events - <strong>On Form Load</strong>, <strong>On Form Close</strong> and <strong>On Timer</strong> – that can be used to execute actions when form is loaded, closed or when a specified time interval elapses. Also almost all objects (with the exception of the Frame object) have one or more events that trigger action execution (check the “Events” page of the object properties dialogs). Usually these are: <strong>On Click</strong> (when object like Button is clicked), <strong>On Focus</strong> (when object becomes active), <strong>On Exit</strong> (when input focus shifts away from the object) or <strong>On Change</strong>. Even variable can execute actions when its value changes.</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/NiceFormEditfieldevents.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="NiceForm - Edit field events" border="0" alt="NiceForm - Edit field events" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/NiceFormEditfieldevents_thumb.png" width="278" height="306" /></a> </p>
<h3>Defining actions</h3>
<p>You define actions and their properties in the “Actions Editor” dialog box. This dialog is the same in both NiceForm and NiceWatch so everything that works in NiceForm should also work in NiceWatch (there are some differences in the action types supported).</p>
<p>“Actions Editor” has three sections. On the left you can see a list of all available actions grouped together by functionality (or action type) in several groups. To define action workflows you just have to drag and drop the action to the area on the right or select one and click “Insert” button at the top of the window.</p>
<p>There is a small toolbar at the top of the right section.&#160; “Properties” button opens the properties of the currently selected action in the right pane(you get the same effect by double clicking the action). By clicking the “Delete” you will delete the selected action. Click on the arrow buttons to change the order and hierarchy of the actions in the right pane. Some of the actions like “Open label”, “For every label”, “For every record in a table” and “For loop” work on their “sub” actions – actions that are essentially their child actions. See the picture below for some samples.</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/Actionseditor.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Actions editor" border="0" alt="Actions editor" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/Actionseditor_thumb.png" width="386" height="443" /></a> </p>
<p>The two remaining buttons in the top toolbar are the “Copy” and “Paste” buttons. You can copy/paste actions between different parts of NiceForm, between different instances of NiceForm and even between NiceForm and NiceWatch (if action is available in both applications).</p>
<p>At the bottom of the dialog you can find buttons to close the window, open help file and switch between Basic and Advanced views of the window. You can see the “Actions Editor” in the (default) Basic mode below. The difference between them is that the Basic view shows only the basic, most used actions, while the Advance view shows all available actions.</p>
<p><a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/ActionseditorBasic.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Actions editor - Basic" border="0" alt="Actions editor - Basic" src="http://www.primozic.net/nl/wp-content/uploads/2011/03/ActionseditorBasic_thumb.png" width="389" height="200" /></a> </p>
<h3>Protecting your know-how</h3>
<p>If you do not want the end-user to modify forms you have created or to see how you implemented a very complicated script, you can lock (protect) the form with a password. In this case all the actions will be encrypted. Of course you have to make sure you do not forget the password because in that case you will have to design the forms from the start.</p>
<p>To lock the form, do the following:</p>
<ol>
<li>Open your form. </li>
<li>Select the “Form Properties” option in the “File” menu or double click the form to open “Form Properties” dialog box. </li>
<li>Go to the Advanced tab. </li>
<li>Tick the “Form locked” option. </li>
<li>Tick the “Password protection” and click on the “Set password” button. </li>
<li>Provide the password and click on the “OK” button to close the “Set Password” dialog. </li>
<li>Click on the “OK” button to close the “Form Properties” dialog box. </li>
<li>Select the command Save in the File menu. </li>
<li>Close the form. </li>
</ol>
<h3>Actions that are not supported in NiceLabel Portal</h3>
<p>Some of the actions are currently not yet supported in NiceLabel Portal. These are: “Close label”, “For every label”, “Move focus”, “Refresh previews”, “Read data from serial port”, “Write data to serial port”, “Acquire image”, “Browse for file or folder”, “Define printer settings” and “Verify license”. “Import data into database” action is available only in NiceLabel Portal. We plan to support all actions that make sense in the browser environment in the future releases.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/actions-in-niceform-and-nicelabel-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manipulating date and time using Python in NiceForm and NiceLabel Portal</title>
		<link>http://www.primozic.net/nl/manipulating-date-and-time-using-python-in-niceform-and-nicelabel-portal/</link>
		<comments>http://www.primozic.net/nl/manipulating-date-and-time-using-python-in-niceform-and-nicelabel-portal/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 20:26:00 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceForm]]></category>
		<category><![CDATA[NiceLabel Portal]]></category>
		<category><![CDATA[niceform]]></category>
		<category><![CDATA[nicelabel portal]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/manipulating-date-and-time-using-python-in-niceform-and-nicelabel-portal/</guid>
		<description><![CDATA[Time values are represented with the time class. Times have attributes for hour, minute, second, and microsecond. They can also include time zone information. A time instance only holds values of time, and not a date associated with the time. from datetime import datetime; time1 = datetime.time(datetime.now()); # Get current time h = time1.hour; m [...]]]></description>
			<content:encoded><![CDATA[<p>Time values are represented with the <em>time</em> class. Times have attributes for hour, minute, second, and microsecond. They can also include time zone information. A time instance only holds values of time, and not a date associated with the time.</p>
<pre class="brush: py;">from datetime import datetime;

time1 = datetime.time(datetime.now()); # Get current time
h = time1.hour;
m = time1.minute;
s = time1.second;
ms = time1.microsecond;
tz = time1.tzinfo;
min = time1.min;
max = time1.max;

d1.Value = "Hour: " + str(h);
d2.Value = "Minute: " + str(m);
d3.Value = "Second: " + str(s);
d4.Value = "Microsecond: " + str(ms);
d5.Value = "Time zone: " + str(tz);
d6.Value = "Earliest: " + str(min);
d7.Value = "Latest: " + str(max);</pre>
<p>Calendar date values are represented with the <em>date</em>  class. Instances have attributes for year, month, and day. It is easy to create a date representing current date using the today() class method. As with time, the range of date values supported can be determined using the min and max attributes.</p>
<pre class="brush: py;">from datetime import date;

date1 = date.today(); # Get current date
year = date1.year;
month = date1.month;
day = date1.day;
ordinal = date1.toordinal();
min = date1.min;
max = date1.max;

d1.Value = "Day: " + str(day);
d2.Value = "Month: " + str(month);
d3.Value = "Year: " + str(year);
d4.Value = "Ordinal: " + str(ordinal);
d5.Value = "Earliest: " + str(min);
d6.Value = "Latest: " + str(max);</pre>
<h3>How can I add or subtract from a date?</h3>
<p>To add or subtract from a date use the datetime.timedelta object.</p>
<pre class="brush: py;">from datetime import datetime, timedelta, time;

time1 = datetime.now();
diff = timedelta(weeks=52);  # 1 year
time2 = time1 + diff;
diff = timedelta(days=730);  # 2 years
time3 = time1 + diff;
diff = timedelta(hours=240);  # 10 days
time4 = time1 + diff;
diff = timedelta(weeks=40, days=84, hours=23, minutes=50, seconds=600);  # Adds up to 365 days
time5 = time1 - diff;

d1.Value = "Current date and time: " + str(time1);
d2.Value = "Added 52 weeks (1 year): " + str(time2);
d3.Value = "Added 730 days (2 years): " + str(time3);
d4.Value = "Added 10 days: " + str(time4);
d5.Value = "Subtracted 365 days: " + str(time5);</pre>
<h3>How can I calculate difference of two dates?</h3>
<p>When two dates are subtracted they produce timedeltas.</p>
<pre class="brush: py;">from datetime import date;

date1 = date.today();
date2 = date(1973, 7, 6);
diff = date1 - date2;

d1.Value = "Current date: " + str(date1);
d2.Value = "My birthday: " + str(date2);
d3.Value = "I am : " + str(diff.days) + " days old.";</pre>
<h3>Can I compare date or time values?</h3>
<p>Both time and date values can be compared using standard operators to determine which one is earlier or later.</p>
<pre class="brush: py;">
from datetime import date, time;

date1 = date.today();
date2 = date(1973, 7, 6);
time1 = time(12, 0, 0);
time2 = time(13, 5, 0);

d1.Value = "Date 1: " + str(date1);
d2.Value = "Date 2: " + str(date2);
d3.Value = "Date 1 &lt; Date 2: " + str(date1 &lt; date2);
d4.Value = "Time 1: " + str(time1);
d5.Value = "Time 2: " + str(time2);

d6.Value = "Time 1 &gt; Time 2: " + str(time1 &lt; time2);</pre>
<h3>How can I replace just part of date?</h3>
<pre class="brush: py;">from datetime import datetime;

date1 = datetime.now();            # Use current date and time
date2 = date1.replace(year=2012);  # Change year to 2012
date3 = date1.replace(month=12);   # Change month to December
date4 = date1.replace(day=31);     # Change day to 31
date5 = date1.replace(day=31, month=12, year=2012); # Change day, month and year all at once.

d1.Value = str(date1);
d2.Value = str(date2);
d3.Value = str(date3);
d4.Value = str(date4);
d5.Value = str(date5);</pre>
<h3>Formatting time and date</h3>
<p>Default string representation of a <em>datetime</em> object uses the ISO 8601 format (YYYY-MM-DDHH:MM:SS.mmmmmm). Other formats can be generated using <em>strftime()</em> method. The following directives can be embedded in the format string:</p>
<table border="0" cellspacing="0" cellpadding="2" width="473">
<tbody>
<tr>
<td width="93" valign="top"><strong>Directive</strong></td>
<td width="378" valign="top"><strong>Meaning</strong></td>
</tr>
<tr>
<td width="93" valign="top">%a</td>
<td width="378" valign="top">Locale’s abbreviated weekday name.</td>
</tr>
<tr>
<td width="93" valign="top">%A</td>
<td width="378" valign="top">Locale’s full weekday name.</td>
</tr>
<tr>
<td width="93" valign="top">%b</td>
<td width="378" valign="top">Locale’s abbreviated month name.</td>
</tr>
<tr>
<td width="93" valign="top">%B</td>
<td width="378" valign="top">Locale’s full month name.</td>
</tr>
<tr>
<td width="93" valign="top">%c</td>
<td width="378" valign="top">Locale’s appropriate date and time representation.</td>
</tr>
<tr>
<td width="93" valign="top">%d</td>
<td width="378" valign="top">Day of the month as a decimal number [01,31].</td>
</tr>
<tr>
<td width="93" valign="top">%H</td>
<td width="378" valign="top">Hour (24-hour clock) as a decimal number [00,23].</td>
</tr>
<tr>
<td width="93" valign="top">%I</td>
<td width="378" valign="top">Hour (12-hour clock) as a decimal number [01,12].</td>
</tr>
<tr>
<td width="93" valign="top">%j</td>
<td width="378" valign="top">Day of the year as a decimal number [001,366].</td>
</tr>
<tr>
<td width="93" valign="top">%m</td>
<td width="378" valign="top">Month as a decimal number [01,12].</td>
</tr>
<tr>
<td width="93" valign="top">%M</td>
<td width="378" valign="top">Minute as a decimal number [00,59].</td>
</tr>
<tr>
<td width="93" valign="top">%p</td>
<td width="378" valign="top">Locale’s equivalent of either AM or PM.</td>
</tr>
<tr>
<td width="93" valign="top">%S</td>
<td width="378" valign="top">Second as a decimal number [00,61].</td>
</tr>
<tr>
<td width="93" valign="top">%U</td>
<td width="378" valign="top">Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.</td>
</tr>
<tr>
<td width="93" valign="top">%w</td>
<td width="378" valign="top">Weekday as a decimal number [0(Sunday),6].</td>
</tr>
<tr>
<td width="93" valign="top">%W</td>
<td width="378" valign="top">Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.</td>
</tr>
<tr>
<td width="93" valign="top">%x</td>
<td width="378" valign="top">Locale’s appropriate date representation.</td>
</tr>
<tr>
<td width="93" valign="top">%X</td>
<td width="378" valign="top">Locale’s appropriate time representation.</td>
</tr>
<tr>
<td width="93" valign="top">%y</td>
<td width="378" valign="top">Year without century as a decimal number [00,99].</td>
</tr>
<tr>
<td width="93" valign="top">%Y</td>
<td width="378" valign="top">Year with century as a decimal number.</td>
</tr>
<tr>
<td width="93" valign="top">%Z</td>
<td width="378" valign="top">Time zone name (no characters if no time zone exists).</td>
</tr>
<tr>
<td width="93" valign="top">%%</td>
<td width="378" valign="top">A literal <tt>'%'</tt> character.</td>
</tr>
</tbody>
</table>
<p>Here are some examples of using different directives:</p>
<pre class="brush: py;">from datetime import date;

format1 = "%A,  %B %d, %Y";
format2 = "Today is day %j of the year.";
format3 = "Short month name: %b; Short weekday name: %a";

date1 = date.today();
d1.Value = date1.strftime(format1);
d2.Value = date1.strftime(format2);
d3.Value = date1.strftime(format3);</pre>
<h3>How can I get a week number from a date?</h3>
<pre class="brush: py;">from datetime import date;

format = "Today is day %w of the %W week of the year.";

date1 = date.today();
d1.Value = date1.strftime(format);</pre>
<p>All code samples above should work in NiceForm and NiceLabel Portal. You can find all samples in <a href="http://www.primozic.net/nl/wp-content/uploads/2011/03/PyDateTime.zip">sample form file (PyDateTime.xff)</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/manipulating-date-and-time-using-python-in-niceform-and-nicelabel-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How can I automate NiceLabel from a scripting language like VBScript or Python?</title>
		<link>http://www.primozic.net/nl/how-can-i-automate-nicelabel-from-a-scripting-language-like-vbscript-or-python/</link>
		<comments>http://www.primozic.net/nl/how-can-i-automate-nicelabel-from-a-scripting-language-like-vbscript-or-python/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 14:28:42 +0000</pubDate>
		<dc:creator>alesp</dc:creator>
				<category><![CDATA[NiceLabel]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[nicelabel]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://www.primozic.net/nl/how-can-i-automate-nicelabel-from-a-scripting-language-like-vb-script-or-python/</guid>
		<description><![CDATA[You can find two examples of automating NiceLabel from a scripting language. The first one is in VBScript and the other one in Python. Both samples do the same thing: run NiceLabel, open label file, iterate through a list of variables, set their values and print the label. At the end label is closed and [...]]]></description>
			<content:encoded><![CDATA[<p>You can find two examples of automating NiceLabel from a scripting language. The first one is in VBScript and the other one in Python. Both samples do the same thing: run NiceLabel, open label file, iterate through a list of variables, set their values and print the label. At the end label is closed and NiceLabel shuts down.</p>
<pre class="brush: vb;">Set nice = CreateObject(&quot;NiceLabel5.Application&quot;)
If (nice is Nothing) Then
  MsgBox(&quot;Cannot open NiceLabel!&quot;)
Else
  fileName =  &quot;c:\Labels\Sample.lbl&quot;
  Set lbl = nice.LabelOpenEx(fileName)

  If (lbl is Nothing) Then
      MsgBox(&quot;Cannot open '&quot; &amp; fileName &amp; &quot;'!&quot;)
  Else
     Set variables = lbl.Variables

     For i = 1 to variables.Count
       Set variable = variables.Item(i)
       ' Use only prompt variables that require prompt.
       If (variable.VarType = 1) and (variable.DefType &lt;&gt; 2) Then
         MsgBox(variable.Name)
         variable.SetValue(&quot;Value&quot; &amp; CStr(i))
       End if

       ' Release interface to variable.
       Set variable = Nothing
     Next

     'Set printer
     lbl.PrinterName = &quot;Altec TTP-343 Plus&quot;

     ' Print 1 label
     quantity = &quot;1&quot;
     lbl.Print(quantity)

     ' Release interface to variables list.
     Set variables = Nothing

     ' Release interface to label to close it
     Set lbl = Nothing
  End If

  ' Close NiceLabel
  nice.Quit
  Set nice = Nothing
End if</pre>
<p></p>
<p>And the same thing in Python. </p>
<pre class="brush: py;">import win32com.client
import os.path

# Run NiceLabel
nice = win32com.client.Dispatch(&quot;NiceLabel5.Application&quot;)
if (nice == None):
    error = &quot;Cannot open NiceLabel&quot;;
else:
    fileName = os.path.normpath(&quot;c:/Users/alesp/Documents/My Labels/Labels/Sample.lbl&quot;);
    lbl = nice.LabelOpenEx(fileName);
    if (lbl == None):
        error = &quot;Cannot open '{0}'&quot;.format(fileName);
    else:
        variables = lbl.Variables;
        for i in range (1, variables.Count + 1):
            variable = variables.Item(i);
            if (variable.VarType == 1) and (variable.DefType &lt;&gt; 2):
                variable.SetValue(&quot;Value&quot; + str(i));
            # Release interface to variable.
            variable = None;

        # Set printer
        #lbl.PrinterName = &quot;Altec TTP-343 Plus&quot;;

        # Print 1 label
        quantity = &quot;1&quot;;
        lbl.Print(quantity);

        # Release interface to variables list.
        variables = None;

        # Release interface to variables list and close label.
        lbl = None;

    nice.Quit();
    nice = None;</pre>
<p></p>
<p>Please note that these samples will only work on a desktop and not in NiceLabel Portal in a browser. You will also need to have NiceLabel 5 installed. </p>
<p>For more information about automating NiceLabel see the <a href="http://www.nicelabel.com/resources/files/doc/manuals/pg-NiceLabel_Programming_Guide-eng.pdf">NiceLabel Programming Guide (PDF)</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primozic.net/nl/how-can-i-automate-nicelabel-from-a-scripting-language-like-vbscript-or-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

