Source language: Translate to:

Create GUID

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Create GUID

Postby dpayer » Mon Aug 27, 2012 9:40 am

Globally Unique Identifier - GUID
also known as a CLSID
http://en.wikipedia.org/wiki/Guid
A GUID is a unique alphanumeric string used to identify items on a computer or in an application or class within an application. Most often used in the Windows Registry to identify a software class. The total number of unique such GUIDs is 2122 or 5.3×10^36. This number is so large that the probability of the same number being generated randomly twice is negligible. So if you create a GUID, it is amost impossible that a duplicate exists.

As it turns out, there is a simple way to make one using VB script. The NB function below is derived from the example at: http://blogs.technet.com/b/heyscripting ... cript.aspx
Image
Copy the code below and save it as a file in your FUNCTIONS sub-folder in the NB install folder.

This function has one parameter that is requested when you call it: the name of the variable that contains the created GUID.

If you would like a simple GUID creator that copies a new GUID to the clipboard for you to use in another app: Here is a compiled executable you can use.

Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|name of variable to contain new GUID
{End}
Set TypeLib = CreateObject("Scriptlet.TypeLib")
newGuid = TypeLib.Guid
publication.nbSetVar "[%1]", newGuid
Set typeLib = Nothing
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby smokinbanger » Mon Aug 27, 2012 3:52 pm

Kinda cool! 8)
smokinbanger
 
Posts: 198
Joined: Mon Jan 16, 2012 9:53 am
Location: United States

Postby Alex » Tue Aug 28, 2012 1:57 am

Thanks DPayer
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Ussing JavaScript...

Postby virger » Tue Aug 28, 2012 9:38 am

May you can use this

function Hexa4()
{return (((1+Math.random())*0x10000)|0).toString(16).substring(1);}

function GUID()
{return ((Hexa4()+Hexa4()+"-"+Hexa4()+"-"+Hexa4()+"-"+Hexa4()+"-"+Hexa4()+Hexa4()+Hexa4()).toUpperCase());}

DESDE COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 509
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests