SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Code Snippets macros

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Code Snippets macros
Author Message
michalk



Joined: 29 Aug 2014
Posts: 196

Post Code Snippets macros Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6709

Post Reply with quote
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 View user's profile Send private message
michalk



Joined: 29 Aug 2014
Posts: 196

Post Reply with quote
here is my current version of the snippet:

Code:
/*****************************************************************************
 * |
 *
 ************  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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6709

Post Reply with quote
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 View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 645
Country: United States

Post Reply with quote
michalk wrote:
here is my current version of the snippet:

Code:
/*****************************************************************************
 * |
 *
 ************  CHANGELOG  ****************************************************
 * $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $PROMPT(AAA,BBB,   ,CCC)$ Description; $OSUSER$
 *****************************************************************************/



Shouldn't this really be something like:

Code:

$$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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6709

Post Reply with quote
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

Code:
/*****************************************************************************
 * |
 *
 ************ 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 View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 645
Country: United States

Post Reply with quote
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 View user's profile Send private message
michalk



Joined: 29 Aug 2014
Posts: 196

Post Reply with quote
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:
Code:
$PROMPT(APROMPTVAR,Please enter a short description,,Description)$
/*****************************************************************************
 * |
 *
 ************  CHANGELOG  ****************************************************
 * $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $APROMPTVAR$ ; $OSUSER$
 *****************************************************************************/


This doesn't work
Code:

$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 View user's profile Send private message
Mindflux



Joined: 25 May 2013
Posts: 645
Country: United States

Post Reply with quote
michalk wrote:
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:
Code:
$PROMPT(APROMPTVAR,Please enter a short description,,Description)$
/*****************************************************************************
 * |
 *
 ************  CHANGELOG  ****************************************************
 * $$SELECT to_char(CURRENT_DATE, 'YYYY-MM-DD')$$ $APROMPTVAR$ ; $OSUSER$
 *****************************************************************************/


This doesn't work
Code:

$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 View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.