Enter date in Prime program?
|
10-01-2024, 01:47 PM
Post: #1
|
|||
|
|||
Enter date in Prime program?
The built-in Prime software uses a nifty date selector in its input screens, which allows the user to either type in a date or tap a calendar icon at the end of the input field and choose a date from a calendar. Is this functionality available for a user program? I am aware of the CHOOSEDATE command which displays a calendar, but that’s painfully slow to use if you want to move years because it can only move forward or backward a month at a time. The INPUT command doesn’t seem to offer a date field type.
Obviously it’s easy enough to have day, month, year, numerical input fields on an input screen, but the way the Prime’s own apps do it is nicer-looking. Chris |
|||
10-01-2024, 11:29 PM
Post: #2
|
|||
|
|||
RE: Enter date in Prime program?
I hope I don't get in trouble for this, but since I've been using Chat GPT to help with my Power Query M Code and Power BI DAX (and it's really good), I thought I'd ask it your question. I just pasted in your words. Here is the answer...
Quote:The built-in date selector you mentioned in the HP Prime's software applications isn't directly accessible for use in user programs. As you've observed, the CHOOSEDATE command is available but can be slow when navigating across years because it only allows movement one month at a time. Additionally, the INPUT command doesn't offer a date field type to replicate that functionality. Quote:EXPORT CustomDateSelector() Quote:Explanation: |
|||
10-02-2024, 04:17 AM
Post: #3
|
|||
|
|||
RE: Enter date in Prime program?
I think pasting results from Chat GPT here is like knocking yourself out, but I'll try to save you a bit
A bit of theory: Chat GPT needs a lot of information about a specific programming language to generate something meaningful. In the case of PPL, the amount of information is so limited that it doesn’t meet the required minimum to obtain satisfactory results. When it comes to DAX, you can find hundreds of websites worldwide (in various languages) and forums describing different use cases for this language. For PPL, there are only a few websites with sparse information about this language. The HP Prime user manual also hasn’t been updated for many years. Nevertheless, putting aside the fact that this program isn't the best idea (selecting a date using three drop-down lists displayed one after another is very inconvenient), it is almost correct. The two fundamental errors are the use of the DATE and DAYSINMONTH functions, which don’t exist in PPL. You can add them yourself, and the program will start working: Code: DATE(year,month,day) If you specified more clearly what you want to achieve (thereby limiting the freedom of coming up with a solution), the result could be significantly better. However, assuming that the way this program works meets our expectations, implementing these two functions is still much less work than implementing everything from scratch. Piotr Kowalewski |
|||
10-02-2024, 04:35 AM
Post: #4
|
|||
|
|||
RE: Enter date in Prime program?
(10-01-2024 01:47 PM)CheshireChris Wrote: I am aware of the CHOOSEDATE command which displays a calendar, but that’s painfully slow to use if you want to move years because it can only move forward or backward a month at a time. When you drag your finger quickly across the entire calendar screen to the left or right (accelerating the scrolling so that it continues to move with inertia), you can change months much faster. However, there's a bug because sametimes (not always) after you speed up the scrolling and it continues to move with inertia, you need to wait until it stops. Trying to drag it again while it's still moving can sometimes reset it to the initial month. Nevertheless, with just two drags, you can shift the calendar by up to 5 years, so it's not that bad after all. Piotr Kowalewski |
|||
10-02-2024, 04:38 PM
Post: #5
|
|||
|
|||
RE: Enter date in Prime program?
Do you know, Piotr, if there is any way to find out what date display setting (MM/DD/YYYY, DD/MM/YYYY, YYYY/MM/DD) the user has chosen? There doesn’t seem to be a system variable that returns it. It would be nice to be able to display dates in a format marching the user’s choice.
Chris |
|||
10-02-2024, 08:48 PM
Post: #6
|
|||
|
|||
RE: Enter date in Prime program?
"there are only a few websites with sparse information about this language."
And most of it is right here! |
|||
10-02-2024, 09:27 PM
Post: #7
|
|||
|
|||
RE: Enter date in Prime program?
Thanks... No one beat me up too badly for doing that Chat GPT thing
I will refrain from doing it again. That said, I find it very useful in the work that I do. Thanks again. Jase. |
|||
10-03-2024, 03:37 AM
Post: #8
|
|||
|
|||
RE: Enter date in Prime program?
(10-02-2024 04:38 PM)CheshireChris Wrote: Do you know, Piotr, if there is any way to find out what date display setting (MM/DD/YYYY, DD/MM/YYYY, YYYY/MM/DD) the user has chosen? There doesn’t seem to be a system variable that returns it. It would be nice to be able to display dates in a format marching the user’s choice. It seems that despite the possibility to change the date format in the Home settings, even the HP Prime doesn’t use it anywhere other than in the small window that appears after tapping the clock in the top-right corner (the date then appears in the selected format). I haven't found any other use of this format anywhere else. A PPL function that converts the date to a string in the selected format, as well as the ability to read this format from the settings (a dedicated variable), would definitely be useful. At the moment, no such functionality exists. I think this is a good suggestion for an enhancement in the next firmware release. Piotr Kowalewski |
|||
10-03-2024, 05:01 AM
(This post was last modified: 10-03-2024 05:02 AM by Tyann.)
Post: #9
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 03:37 AM)komame Wrote: I think this is a good suggestion for an enhancement in the next firmware release. +1. Sorry for my english |
|||
10-03-2024, 05:54 AM
Post: #10
|
|||
|
|||
RE: Enter date in Prime program?
(10-02-2024 09:27 PM)Jase Wrote: Thanks... No one beat me up too badly for doing that Chat GPT thing I’m not saying that ChatGPT is inherently bad. I also use it at work and I’m aware of what it can and can’t do. If you ask it to write a simple script in JavaScript or Python, you’ll usually get a flawless result right away (of course, this applies to small scripts). The most important thing is to clearly specify your request and provide all the necessary details (avoid shortcuts or assumptions - something that’s obvious to us (people) may not be for ChatGPT). Moreover, if you’re using the paid version, you can create agents into which you can inject knowledge from any domain. Let’s say you want to create an agent called 'PPL Programmer'. After defining its identity, it will primarily focus on PPL, but it will still make mistakes. As you use it, you can correct these mistakes by adding the relevant information to its knowledge base. For example, if you give the standard ChatGPT the following command: Write a PPL program that declares 10 variables starting from 'a'. You’ll most likely get smoething like that: Code: EXPORT DeclareVariables() This is incorrect because PPL allows the declaration of a maximum of 8 variables for a single LOCAL. However, when I added the following information to the knowledge base: One LOCAL keyword in the program can declare up to 8 variables. If there are more variables to declare, use an additional LOCAL keyword for the remaining variables. Issuing the command again will generate a correct program: Code: EXPORT DeclareVariables() The crucial thing for PPL is to provide a list of built-in commands and forbid the use of others not on that list. This prevents GPT from inventing commands that don’t exist. Creating a good agent is hard work, especially if there are significant knowledge gaps (as is the case with PPL), but it allows you to get much more out of ChatGPT. Currently, ChatGPT cannot replace humans in programming (at least for now), but it can significantly assist and reduce the time needed to develop a project, and even detect potential bugs in the code. However, you need to know how to use it properly. The ability to write effective prompts is a great skill that must be learned. Piotr Kowalewski |
|||
10-03-2024, 06:14 AM
Post: #11
|
|||
|
|||
RE: Enter date in Prime program?
It is a little frustrating that the Prime can do things on its own INPUT forms that a user cannot do on a programmed form. The nice date selector is one example; another is the ability to make an additional field appear in response to a selection. Eg on the "Home Settings" page, if you change the number format to "Fixed", an extra field appears letting you choose the number of digits to display. It doesn't seem possible to hide and show fields programmatically in an INPUT form that you write yourself.
Chris |
|||
10-03-2024, 06:19 AM
Post: #12
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 03:37 AM)komame Wrote: It seems that despite the possibility to change the date format in the Home settings, even the HP Prime doesn’t use it anywhere other than in the small window that appears after tapping the clock in the top-right corner (the date then appears in the selected format). I haven't found any other use of this format anywhere else. A PPL function that converts the date to a string in the selected format, as well as the ability to read this format from the settings (a dedicated variable), would definitely be useful. At the moment, no such functionality exists. I think this is a good suggestion for an enhancement in the next firmware release. Yes, this would be a very useful enhancement. In Windows, for example, not only can you find out the user's chosen date and time formats, but there are also API calls which return the names of the days of the week and the months of the year in the user's selected language, which makes it much easier to write "localised" programs. Chris |
|||
10-03-2024, 07:16 AM
(This post was last modified: 10-03-2024 07:18 AM by komame.)
Post: #13
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 06:19 AM)CheshireChris Wrote: [...] but there are also API calls which return the names of the days of the week and the months of the year in the user's selected language, which makes it much easier to write "localised" programs. In PPL, there is a command called STRINGFROMID, which returns various texts in the currently active language. These texts are divided into groups. For the names of months and days of the week, you should use the "Main" group, which has the identifier -1. Review the list of these identifiers, but be careful as there are typos. When fetching a translation, you must use the exact identifier (with group prefix) as it appears on this list, e.g. Code: STRINGFROMID("Main_CalendarJanruary"); It's terrible that it was done so carelessly Fortunately, the texts obtained this way don't contain any typos. Piotr Kowalewski |
|||
10-03-2024, 02:33 PM
(This post was last modified: 10-03-2024 02:34 PM by Albert Chan.)
Post: #14
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 07:16 AM)komame Wrote: How to you know string equivalent to its ID? Where to you get the list names? Cas> STRINGFROMID(2339) → "January" Cas> STRINGFROMID(2340) → "February" |
|||
10-03-2024, 03:13 PM
(This post was last modified: 10-03-2024 03:18 PM by komame.)
Post: #15
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 02:33 PM)Albert Chan Wrote: How to you know string equivalent to its ID? Using an integer as an argument to read a specific string is a deprecated method. When you read the documentation for the STRINGFROMID command in the HP Prime embedded help, you will find information that the texts are divided into groups. To get a list of identifiers within a specified group, you need to call this command with a negative value ranging from -1 to -40 (actually, it can go down to -41). For example, STRINGFROMID(-1) will return a list where the first element is the name of the group (in this case, "Main"), and the remaining elements are the identifiers of individual texts. To read a specific text, you need to use the group name and the identifier combined with an underscore. Therefore, to access the string CalendarJanruary, you should use "Main_CalendarJanruary." Piotr Kowalewski |
|||
10-03-2024, 03:27 PM
(This post was last modified: 10-03-2024 03:39 PM by Raymond Del Tondo.)
Post: #16
|
|||
|
|||
RE: Enter date in Prime program?
A small code snippet for other people who'd like to follow this:
#pragma mode( separator(., integer(h32) ) EXPORT StrFromID BEGIN L0:=STRINGFROMID(-1); END; Run the above code. Then, open the PC Connectivity Kit, double click on L0, and there you are:-) From there the texts can be copied for later lookup. Easier than expected;-) -- Ray |
|||
10-03-2024, 03:54 PM
Post: #17
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 03:13 PM)komame Wrote: To read a specific text, you need to use the group name and the identifier combined with an underscore. Therefore, to access the string CalendarJanruary, you should use "Main_CalendarJanruary."Where is this info specified? Prime developer kit? The normal Prime user manual and the Prime onboard help state: STRINGFROMID Syntax: STRINGFROMID(Ganzzahl) There is no info that it can take strings (or labels) as parameter, too. -- Ray |
|||
10-03-2024, 04:36 PM
(This post was last modified: 10-03-2024 04:37 PM by komame.)
Post: #18
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 03:54 PM)Raymond Del Tondo Wrote: Where is this info specified? Prime developer kit? Switch the language to English. Then press the Home key, type STRINGFROMID, and press the Help key. Although the syntax at the beginning of the description does not include a string argument, it is explained further down. There's even an example showing how to use the underscore character. Just read it all the way through. Piotr Kowalewski |
|||
10-03-2024, 05:22 PM
(This post was last modified: 10-03-2024 05:27 PM by Raymond Del Tondo.)
Post: #19
|
|||
|
|||
RE: Enter date in Prime program?
Many thanks for the pointer:-)
On my PC-based Prime Emulator, the language was set to German. Too bad the onboard help seems to be incomplete somehow for this (and maybe other) keywords if language set to non-english. -- Ray |
|||
10-03-2024, 11:19 PM
Post: #20
|
|||
|
|||
RE: Enter date in Prime program?
(10-03-2024 05:54 AM)komame Wrote: I’m not saying that ChatGPT is inherently bad. I also use it at work and I’m aware of what it can and can’t do... The most important thing is to clearly specify your request and provide all the necessary details... Moreover, if you’re using the paid version, you can create agents into which you can inject knowledge from any domain. I am using the paid version - use it multiple times, daily. I haven't tailored it so much though, I really need to do that. Thanks for sharing your knowledge. Jase. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 7 Guest(s)