Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Why does -TYPE not work when a variable is created?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Why does -TYPE not work when a variable is created?
 Login/Join
 
Member
posted
I'm hoping someone can help me out with this. I started playing around with some sample code and ran into something I didn't understand. I am guessing that this is me missing some basics in regards to FOCUS and if so, any explanation would be helpful.

I cut down the code to just a simple case, but the idea is that I'd loop though some values and place them into variables. The intention is to reduce the number of lines in the code by creating those variables through a loop instead of explicitly defining them all.

Anyway, this code works. If I put a value in for the -SET &VAR1 value, it will be emptied. If I put a value in for -SET &VAR&i.EVAL, that will show up as output.

   
-SET &VAR1 = ' ';

-SET &i = 1;
-SET &VAR&i.EVAL     = ' ';

-TYPE &VAR1
-EXIT


When I comment out the first line & run the code, I get prompted to enter a value for &VAR1. And this is the part that confuses me, as shown in the next code block.

-*SET &VAR1 = ' ';

-SET &i = 1;
-SET &VAR&i.EVAL     = ' ';

-TYPE &VAR1
-EXIT


When I replace -TYPE &VAR1 with -? &V, I see that one of the variables is &VAR1, which is set to a blank value.

-*SET &VAR1 = ' ';

-SET &i = 1;
-SET &VAR&i.EVAL     = ' ';

-? &V
-EXIT


So why does -TYPE &VAR1 only work when I explicitly set it to a blank space at the beginning, even though that step isn't necessary to create it?

This message has been edited. Last edited by: bsullivan,


WebFOCUS 8.0.0.2
Windows, All Outputs
 
Posts: 27 | Location: Philadelphia, PA | Registered: January 21, 2013Report This Post
Guru
posted Hide Post
Basically your syntax is wrong. Search for "variable array". Try this syntax.
  
-SET &VAR.&i     = ' ';


Some sample code
  
-SET LP_CNT = 5;

-REPEAT LP_VAR FOR &N FROM 1 TO &LP_CNT STEP 1;

-SET &VAR.&N = DECODE &N (1 'A' 2 'B' 3 'C' 4 'D' 5 'E');
-TYPE &VAR.&N

-LP_VAR


-TYPE Variable 1 = &VAR1
-TYPE Variable 2 = &VAR2
-TYPE Variable 3 = &VAR3
-TYPE Variable 4 = &VAR4
-TYPE Variable 5 = &VAR5


WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
 
Posts: 320 | Location: Memphis, TN | Registered: February 12, 2008Report This Post
Member
posted Hide Post
quote:
Originally posted by Mighty Max:
Basically your syntax is wrong. Search for "variable array". Try this syntax.
  
-SET &VAR.&i     = ' ';


Some sample code
  
-SET LP_CNT = 5;

-REPEAT LP_VAR FOR &N FROM 1 TO &LP_CNT STEP 1;

-SET &VAR.&N = DECODE &N (1 'A' 2 'B' 3 'C' 4 'D' 5 'E');
-TYPE &VAR.&N

-LP_VAR


-TYPE Variable 1 = &VAR1
-TYPE Variable 2 = &VAR2
-TYPE Variable 3 = &VAR3
-TYPE Variable 4 = &VAR4
-TYPE Variable 5 = &VAR5


Max,

Thanks for the reply. I gave this a try & I still got the same result, where running the code prompted me to enter values for VAR1 through VAR5.

(Note: I also changed -SET LP_CNT = 5; to -SET &LP_CNT = 5; before running.)

I am looking into the variable array information to see if that helps, though.

This message has been edited. Last edited by: bsullivan,


WebFOCUS 8.0.0.2
Windows, All Outputs
 
Posts: 27 | Location: Philadelphia, PA | Registered: January 21, 2013Report This Post
Expert
posted Hide Post
You will be prompted if you have this code in a MRE fex with "Prompt for Parameters" checkbox checked.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Member
posted Hide Post
quote:
Originally posted by Francis Mariani:
You will be prompted if you have this code in a MRE fex with "Prompt for Parameters" checkbox checked.


Francis,

Thanks - That looks like it took care of it & it would explain my problems. It also seems like leaving the 'Prompt for Parameters' option unchecked gets ignored when you run from the code itself, which is interesting. But either way, that seems like it worked. Thanks again!


WebFOCUS 8.0.0.2
Windows, All Outputs
 
Posts: 27 | Location: Philadelphia, PA | Registered: January 21, 2013Report This Post
Platinum Member
posted Hide Post
The reason you are getting prompted is because of the .EVAL

.EVAL forces an immediate evaluation of an &var before the statement is even fully parsed or executed. Since you have not yet set a value for &VAR1, you are prompted.

The .EVAL is not needed in this situation.
 
Posts: 164 | Registered: March 26, 2003Report This Post
Virtuoso
posted Hide Post
quote:
Originally posted by Mighty Max:
  
-SET LP_CNT = 5;


You're missing an ampersand there.

But:
-TYPE Variable 1 = &VAR1
-TYPE Variable 2 = &VAR2
-TYPE Variable 3 = &VAR3
-TYPE Variable 4 = &VAR4
-TYPE Variable 5 = &VAR5


The above will cause autoprompter to prompt for those values, because it's too retarded to see that those values are already set at that point. As I understand it, the autoprompting facility doesn't actually parse (or understand) the dialog manager code, it just looks for variables in the entire procedure and checks that there are -SET or -DEFAULT statements that provide a value for an exact match of those variables it found.

For extra fun, put in a -EXIT before the above block and auto-prompt will still attempt to find values for those variables even though that code is never reached!

-EXIT

-* Never reached
-TYPE Variable 1 = &VAR1
-TYPE Variable 2 = &VAR2
...


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Why does -TYPE not work when a variable is created?

Copyright © 1996-2020 Information Builders