Assigning %DataSetAccessHost% to the string won't work because this variable cannot be resolved at runtime. This has to be done by the CpStudio export. One possibility is to add a string variable to an object definition (e.g. an add-on) and initialize it with the DataSetAccess host in an export template:
@ownerObject.ResolvePathVariables("%DataSetAccessHost%") or a bit simpler in case DataSetAccess runs on the PLC controller: @configurationRoot.PlcHostname
I know there are some project-specific basestation objects doing something like this, but BCI doesn't provide this functionality. So, sometimes it is the easiest way to hard-code the host name.
By the way, in CpStudio 5.8, it will be possible to use such environment variables as initial value of string variables, and they will be resolved automatically when exporting. But currently, this does not work.
... View more