 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
michalk
Joined: 29 Aug 2014 Posts: 211
|
|
Code Snippets macros |
|
Hello
I have an issue and a question:
1. It seems to me that Prompt macro doesn't work. After feeling configuration form, it feels my snippet with macro: $PROMPT(AAA,BBB, ,CCC)$. When entering snippet I'm requested to enter value, but nothing is being entered.
2. Is it possible to get ISO formatted date? I found $date$ macro enters a date in format defined by operation system locales. I found I can write a macro to get date from database but.. you know. It's like using sledgehammer to crack a nut ;)
SA v.9.5.369
with regards
|
|
Wed May 02, 2018 9:42 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Hello,
1. Could you please post the complete snippet so that I can try it locally and reproduce your issue?
2. Unfortunately, you would need a sledgehammer in this case, as you say. But it's not very heavy actually, executing $$..$$ to get a custom formatted system date normally should be lighting fast, no complex data access or any heavy lifting there. I wouldn't think of that as a sledgehammer, rather as great flexibility allowing me to program things and return dates or whatever else I need in whatever format I want :-)
|
|
Wed May 02, 2018 12:32 pm |
|
 |
michalk
Joined: 29 Aug 2014 Posts: 211
|
|
|
|
here is my current version of the snippet:
 |
 |
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $PROMPT(AAA,BBB, ,CCC)$ Description; $OSUSER$
*****************************************************************************/ |
ad2.
The point is it requires connection to database. I know you can say "but the active connection is required for SA to work" but adding comment to existing code or creating empty function from template is a moment while a user don't expect popup to connect to database (if disconnected).
Another 'issue' which might came from locally formatted date, is using the $date$ macro with as a part od SQL macros. Even SA documentation does mention about such possibility. But it might leads to problems if date is not ISO formatted, and database connection locale are not aligned with OS locale.
Anyway not a big deal.
with regards
|
|
Thu May 03, 2018 5:44 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
thank you for the snippet. I can reproduce it too. I will need to open a ticket for that one and see what they say.
|
|
Thu May 03, 2018 10:04 am |
|
 |
Mindflux
Joined: 25 May 2013 Posts: 846 Country: United States |
|
|
|
 |
 |
here is my current version of the snippet:
 |
 |
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $PROMPT(AAA,BBB, ,CCC)$ Description; $OSUSER$
*****************************************************************************/ |
|
Shouldn't this really be something like:
 |
 |
$$PROMPT(AAA,BBB,,CCC)$
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $AAA$ Description; $OSUSER$
*****************************************************************************/ |
That way the variable AAA get's stuffed where $AAA$ is placed? I tested this, and it does indeed work as you'd expect.
|
|
Thu May 03, 2018 10:39 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Correct, $PROMPT$ macro doesn't insert anything. It defines a variable whose value can be entered using graphical dialog. The variable can be used in other places where the actual value is required, like
 |
 |
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* DATE USER DESCRIPTION
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $OSUSER$ $NOTE$
* $PROMPT(NOTE,Please briefly describe the changes,Fixed issue with ...,Change Log)$
*****************************************************************************/ |
|
|
Thu May 03, 2018 10:58 am |
|
 |
Mindflux
Joined: 25 May 2013 Posts: 846 Country: United States |
|
|
|
Right. That was his first question in the original post.
To me it seems he just wasn’t using the variable.
|
|
Thu May 03, 2018 11:10 am |
|
 |
michalk
Joined: 29 Aug 2014 Posts: 211
|
|
|
|
Thanks guys. I didn't managed it's being used different way. I was trying blindly (without reading documentation) a macros from Macro drop down, so was expecting those are working the same way.
Thank you again for clarification.
I wanted to put final version for reference (suggested syntax by MindFlux has slight typo) , but I found another issue:
This works:
 |
 |
$PROMPT(APROMPTVAR,Please enter a short description,,Description)$
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $APROMPTVAR$ ; $OSUSER$
*****************************************************************************/ |
This doesn't work
 |
 |
$PROMPT(PROMPTVAR,Please enter a short description,,Description)$
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $PROMPTVAR$ ; $OSUSER$
*****************************************************************************/ |
Don't know exactly the reason, but looks like variable started with PROMPT word brakes the routine. It asks for the entry, but the inserted template ends on date - next characters till the of the template are missing
with regards
|
|
Thu May 03, 2018 12:21 pm |
|
 |
Mindflux
Joined: 25 May 2013 Posts: 846 Country: United States |
|
|
|
 |
 |
Thanks guys. I didn't managed it's being used different way. I was trying blindly (without reading documentation) a macros from Macro drop down, so was expecting those are working the same way.
Thank you again for clarification.
I wanted to put final version for reference (suggested syntax by MindFlux has slight typo) , but I found another issue:
This works:
 |
 |
$PROMPT(APROMPTVAR,Please enter a short description,,Description)$
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $APROMPTVAR$ ; $OSUSER$
*****************************************************************************/ |
This doesn't work
 |
 |
$PROMPT(PROMPTVAR,Please enter a short description,,Description)$
/*****************************************************************************
* |
*
************ CHANGELOG ****************************************************
* $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $PROMPTVAR$ ; $OSUSER$
*****************************************************************************/ |
Don't know exactly the reason, but looks like variable started with PROMPT word brakes the routine. It asks for the entry, but the inserted template ends on date - next characters till the of the template are missing
with regards |
Yes sorry I had two $$'s before PROMPT that I caught after I could no longer edit the post.
Glad you found a way to get the prompt to work.
|
|
Thu May 03, 2018 12:23 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|