Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

retreiving the server name from a path


2 replies to this topic

Donzer

Donzer
  • Full Members
  • 29 posts

Posted 19 February 2004 - 12:37

Hi

I have a path in my installation \\Servername\Calm Software\Templates which is collected by my client installation by browsing back to the server to collect this path.

For another shortcut on my client machine I need only the \\Servername bit of the path and have tried parsing the string and even tried using the StrGetTokens function. The parsing manages to give me \\Servername\Calm Software which is still more info than required. The StrGetTokens function returns nothing! I tried with this code StrGetTokens (ListPath, svServerName, "\\"); cause I thought that the \ in the path would be the delimiter but that returns empty values.

Has anyone got any ideas how I can do this? I am sure it will be dead easy but it is starting to annoy me now mad.gif

wernerf

wernerf
  • Members
  • 22 posts

Posted 19 February 2004 - 16:33

You have to be aware of the fact, that "\\" stands for a string with ONE character, since InstallScript uses Unix conventions (and I'm glad it does!).
Thus, StrGetTokens(ListPath, svServerName, "\\") returns the following list (when svServerName="\\\\Servername\\Calm Software\\Templates" (!)):

{"", "", "ServerName", "Calm Software", "Templates"}.

So, you are on the right way, but you'll have to refer to the THIRD list element to get the server name. In fact, you have a UNC path name, exactly when StrGetTokens(ListPath, svServerName, "\\") returns at least 3 tokens, and the first two list elements are empty strings ("").

HTH.


Donzer

Donzer
  • Full Members
  • 29 posts

Posted 20 February 2004 - 13:16

Thanks for that : I changed the code and added "\\\\" which returned me One blank entry at the beginning of the list, then simply removed that entry to provide me with the correct server name!

I forgot about the \\ only meaning \ !!!!

thanks heaps biggrin.gif

GetDisk ( svTemplatesDir, svServerName );
//create a list to hold the servername then the leftover folder name
ListPath = ListCreate(STRINGLIST);
StrGetTokens (ListPath, svServerName, "\\\\");
ListSetIndex (ListPath, 0);

//delete the first entry as this is a blank, then retrieve the new
//first item which will be the server name
nvResult = ListFindItem(ListPath,0);
ListDeleteString ( ListPath );
ListGetFirstString (ListPath, svServerName);