I the previous post “Dealing with Internal and Display format data in your MV database with Python” I showed how it is possible to convert the python date to the MV internal format. We will not show how we can get the python time date representation. In the time.time() function returns the number of seconds since the Epoch. The Epoch is a system defined date.
By having the number of seconds from a specified point in time, we are able to generate a display value that has both the time and the date. This is different then what MV provides, which is q date value and a separate time value.
What we now need to show is how to get the python time values into a MV BASIC program.
The first thing we need is a module that contains the functions we want to expose to the MV BASIC programmer.
Note that if we run the functions from python, you see we can get the time is seconds, convert it to a display format, and get the time in seconds from the display format:
To access the python module from MV BASIC we will need to import the module into the current session.
Note that the U2 python API provides several @ variables to access any python exception information of the last executed python method/function.
To call the python function, we need to set a variable with the function name, and pass it into the U2 Basic pyCallFunction:
In the above example once we verified there were no raised exceptions, we display the results:
The following is the complete listing of the MV BASIC code ( note this example was written in UniData ):
Compile and run the previous program will produce out like the following:
While this example only deals with specific display formats of the python time/date, it is a good starting point for learning how to write and use your own python modules.
Now that we can get the python time/date from MV BASIC our next step is to make it easier for the MV developer. In the next post, I will show how to access the python time/date module from a user defined function in U2 BASIC.
77 4th AvenueWaltham, MA 02451 USA
Rocket Support Community
All Support Offerings
About Rocket Software
Training and Services
Forum Terms and Conditions
Contact Forum Moderator