Is it possible to store template symbols in a template so they can write out their value in the clw?

Tags: #<Tag:0x00007f22565cc770>

Can a template with a
store symbols like
%Application, %Module, %Key
so that it writes out the value stored in %Application, %module in the clw?

I’ve tried
#Set(%var,’’’’%Application’’’) to populate the #Prompt but it doesnt write out
‘MyAppName’ in the clw, it writes out ‘%Application’ in the clw which is not what I want.

#Set(%var,’’’’<37>Application’’’) is ‘%Application’ in the clw, again not what I want

#Set(%var,’%‘Application’) throws template errors and no combination seems to get that to work because it sounded promising in the docs.

So any ideas?


what you want I think is

%Application is a var so you don’t want to quote it.

The %var is being used to make a string so I do need to quote it otherwise I get compiler errors.

I’m probably going to have to do something slightly out of the box to get it work, %StripPling looks interesting in the shipping templates.

This works

Loc:String = '%(Evaluate(%var))'

I did wonder if the template symbols would work inside Evaluate and they do, so its possible to store template %symbols inside a #Prompt('blah',text),%var and pass it to evaluate() to get the value out for use in a string in a clw source file.
Loc:String = '%(Evaluate(%var))'

Havent tried using #Template functions inside a prompt and then passed to evaluate(), but symbols certainly work.

#GROUP(%StripPling using evaluate() was the heads up and the 3rd parameter of Sub is optional contrary to the help docs which can be seen in #GROUP(%StripPling !

I’m not sure I understand your question. I think maybe you’re over-thinking this.
To get any symbol to write their value out on the CLW, just use them. Like
! Application = %Application
! Module = %Module
and so on

To assign the variable to a prompt, or local variable, just use #SET. As in

I’m not seeing any need for Evaluate - but maybe I’m missing what you are trying to do?

In that case

#SET(%var,’’’’ & %application & ‘’’’)

Or of course, just use it inside a string. Like;
! Application = ‘%Application’

This doesnt work because the prompt translates the %Application to MyAppName so in the screen shot below it would show MyAppName and not %Application.

Now whilst technically its the same for the whole app so its not a deal breaker to use this technique of using 4 single quotes to wrap a global template symbol, it means it doesnt work for %module or %procedure or other template symbols that are not global template symbols. What I mean by Global template symbols is its the one that dont change throughout the whole of the app, like %ProjectTarget.

I also have clarion code going into the same template prompt which you can see in the screen shot so I can mix clarion code or template symbols and the only thing that works with the template symbols is the evaluate as I posted above.

The screen shot is a global #application #Button multi list with a prompt template where I can type clarion code and template symbols into it, in order to populate module and procedure source code ie clw files properly.


Edit. One other advantage of this approach is by being in the list box, the order can be altered where as before it was hard coded in the template.

So you want to store and be able to use the template symbol itself?

I’m a little confused. What do you actually want to acheive at the end of this? Whats the ultimate goal?
It just seems a little like an xy problem.

Yep, thats what I’ve put in a more detailed way in the title.

To produce source code, like Clarion clw’s, or template’s (tpl & tpw) or any other source for any other language.

Yes, I understand that, that’s what the templates do now. I’ve produced SQL using templates. I don’t understand why you need to store a high level template symbol (which I’m uncertain is possible)

Its not stored in a procedure template, its stored in the application extension template otherwise the problem wouldnt exist, but as its stored in an application extension template, it needs this special handling.

The application extension template injects code into all the procedures that way I can switch functionality on and off at the click of a button instead of going through every procedure one by one.

Until you try it I dont think you’ll see the problem in the source code.

I don’t remember the exact name of the template, but the version resource template uses text files to store data. Maybe you could borrow from that.

For my previous gig, I modified that template so that the version was shared across all apps. All I did was modify a small text file that had the version number in it. When I gen’d/compiled all apps, they had the new version number on them.

I’ve already got a template which writes out settings to a text file so other templates can read the data back, but I needed a different way and the above works for what I need in this instance.