#Service - Are we allowed to use it?

In C11 and earlier versions, SVFnGrp.tpw there are examples of using #Service with ClaTPLS.dll to make a directory, remove a directory and perform a shell execute command. Other examples of #Service exist in other templates.

It seems to have some mechanism which returns a value to a locally declared template symbol called %ServiceResponse which is where it differs from #RunDll.

#Rundll can pass a single parameter by address (or value) which means a single template symbol can be used to pass data in and out, for further processing by the template code.

Now whilst I can popup windows and interact with them using #Rundll from within the appgen, extra measures have to be taken like forcing the #rundll window to be top of the z order.

I just wondered if A) we can use #Service and B) does it bring any extra advantages for extending the appgen over and above using #Rundll?



So what I’m doing with C6 #Rundll is passing a single csv string into the #Rundll and then parsing the returned csv string back out. I’m also toying with the idea to extend it to handle Query Strings as these seem quite flexible and well tested in the online world.
#Service appears to take a parameter by value rather than by address, but does return a value to this %ServiceResponse symbol, which could be useful in some situations.

Likewise in C11 SVFnGrp.tpw there is the line of code

which now explains why @also replied when I posted this
Why does an ANY data type in API call StringFromGuid2() not give me a fixed GUID? - questions - ClarionHub

So at the moment it looks like #Service does integrate with the IDE in some ways, like #Service GenReadABCFiles in the ABoop.tpw which is also seen in C6 and probably earlier, and I’ve probably answered my own question, ie its integrating with the IDE which would mean no additional benefits to be gained over using #Rundll. Would that be correct? :grinning:

As you note it’s been there forever, but it’s also undocumented. In that sense I prefer not to use it (and don’t). I would be very surprised if it changed, but it’s certainly possible. And if it did, I wouldn’t be able to complain.

Other than existing I don’t think it really adds anything I’ve missed, #run and #rundll are both adequate and can handle multiple parameters in both directions as you point out.
So I guess you can use it, but ultimately, why would you?

It can be used for a number of things"

Fat-fingered that last response: I have used it to select or create directories by passing an action, parameter pair. Mr. Goldberg has used it in a DLL to run a program by passing its location. You can pass a file name as a parameter or with a set of parameters and execute a set of commands. Which might explain some of the callable commands that can be used from the template language. There is a string that gets passed as input/output to a DLL, and that is the documentation. What you do inside the DLL when called is your choice. #SERVICE is a similar mechanism, the commands do interface with the IDE, but it is as it has been put, the services are undocumented.

I didnt know if it might be possible to extend windows inside the appgen for example and other functionality inside the IDE, ie to fill content, maybe add additional screen controls for final exe programs and things like that.

I guess it boils down to how much we can extend the IDE and if its something we are allowed to do.

At the moment, I’m popping up my own windows to display stuff and provide additional functionality, which isnt bad but its one of the reasons why I’ve had to write my own template to write templates, some of this stuff I’ve written is getting too big to manage quickly and easily from a text editor. Likewise the passing of long comma separated strings containing values from template controls into the called dll for processing or functionality before processing the resultant output in the template is not the easiest or quickest, but it still works for me.

Either way just being curious to know if #Service can bring more to the table over the standard #Rundll command.

You should not use things that are undocumented. Bad JU JU! But you can create items that can be #RUN or #RUNDLL to execute items from inside the template language. And since you created them, you can document them for your use or others folks use. You got an interpreter running executables. Fairly useful mechanism depending on your requirements. Horses for courses. Have fun.

#SERVICE is a special variant of #RUNDLL. It is passing an additional parameter to the function referenced by parameters of #SERVICE. This additional parameter allows the function to get access to symbols/variables visible in the scope where #SERVICE has been invoked from, Also, it allows to execute AppGen’s functions implementing #FIND, #FIX and other clauses working with templates symbols/variables.


This is surely something many people might like to use. The HELP says it internal.

Does anyone have any documentation on using this?

SV really needs publish more information.

" can handle multiple parameters in both directions as you point out."

help says it can only pass one as a cstring ref parameter?

not sure how you pass multiple parameter back and forward with out parsing when it gets there.