<HTML ><HEAD ><TITLE >Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.42"><LINK REL="HOME" TITLE="Pyrite Programmers Guide" HREF="book1.html"><LINK REL="UP" TITLE="Blocks" HREF="c47.html"><LINK REL="PREVIOUS" TITLE="Attributes" HREF="x323.html"><LINK REL="NEXT" TITLE="Databases" HREF="c396.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Pyrite Programmers Guide</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="x323.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 1. Blocks</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="c396.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="REF-BLOCKS-FUNCTIONS" >Functions</A ></H1 ><P > The functions in this module are intended for use in application-specific subclasses, as an aid to the packing and unpacking of data formats used on the handheld. </P ><P ></P ><DL ><DT ><TT CLASS="FUNCTION" >palm_date_to_tuple</TT > (<TT CLASS="PARAMETER" ><I >date</I ></TT >, <TT CLASS="PARAMETER" ><I >hour</I ></TT >=0, <TT CLASS="PARAMETER" ><I >minute</I ></TT >=0, <TT CLASS="PARAMETER" ><I >second</I ></TT >=0)</DT ><DD ><P >Convert a date in the format used on the handheld (2-byte packed) into a 9-element time tuple suitable for use with the Python <TT CLASS="CLASSNAME" >time</TT > module. The <TT CLASS="PARAMETER" ><I >hour</I ></TT >, <TT CLASS="PARAMETER" ><I >minute</I ></TT >, and <TT CLASS="PARAMETER" ><I >second</I ></TT > parameters may be used to provide contents for the corresponding elements in the returned tuple; otherwise, the return value represents midnight on the specified date. The return value is presumed to be in the local time zone.</P ></DD ><DT ><TT CLASS="FUNCTION" >tuple_to_palm_date</TT > (<TT CLASS="PARAMETER" ><I >tuple</I ></TT >)</DT ><DD ><P >Convert the date portion of a time tuple to the format used on the handheld (2-byte packed). The time and time zone portions of the tuple are ignored.</P ></DD ><DT ><TT CLASS="FUNCTION" >trim_null</TT > (<TT CLASS="PARAMETER" ><I >string</I ></TT >)</DT ><DD ><P >Trim a null-terminated string, removing the null byte and any extraneous garbage after it.</P ></DD ><DT ><TT CLASS="FUNCTION" >pad_null</TT > (<TT CLASS="PARAMETER" ><I >string</I ></TT >, <TT CLASS="PARAMETER" ><I >length</I ></TT >)</DT ><DD ><P >Convert a string to a fixed-width field of <TT CLASS="PARAMETER" ><I >length</I ></TT > bytes. Within the result, the original string is null-terminated and any unused portion is also filled with nulls. If the string is longer than (<TT CLASS="PARAMETER" ><I >length</I ></TT >-1) bytes, it will be truncated.</P ></DD ><DT ><TT CLASS="FUNCTION" >unpack_category_appinfo</TT > (<TT CLASS="PARAMETER" ><I >dict</I ></TT >, <TT CLASS="PARAMETER" ><I >raw</I ></TT >)</DT ><DD ><P >Unpack the supplied raw string, assuming that it contains the data structure used by the handheld Category Manager. Fills in the supplied dictionary with the results, and returns the number of bytes of the raw string that were "consumed".</P ></DD ><DT ><TT CLASS="FUNCTION" >pack_category_appinfo</TT > (<TT CLASS="PARAMETER" ><I >dict</I ></TT >)</DT ><DD ><P >Pack Category Manager information, supplied in a dictionary, into a raw string representing the data structure used on the handheld.</P ></DD ></DL ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="x323.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="c396.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Attributes</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c47.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Databases</TD ></TR ></TABLE ></DIV ></BODY ></HTML >