Page 1 of 1 1
Topic Options
#213137 - 2018-01-12 03:58 PM Convert Dell service tag to Dell express service code
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hi guys,

Looking to convert the Dell service tag to the Dell express service code. Some Googling taught me that this is a BASE-36 to BASE-10 conversion. I so absolutely suck at (more advanced) math so all examples look like hieroglyphs to me. I can almost not imagine that this has never been done before. Did anyone do this before? Any ideas or examples are very much appreciated.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#213138 - 2018-01-12 04:33 PM Re: Convert Dell service tag to Dell express service code [Re: Mart]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4560
Loc: USA
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=158301#Post158301
is a start...

Seems to me it was converted to a function too, but haven't found it yet.

Top
#213139 - 2018-01-12 10:46 PM Re: Convert Dell service tag to Dell express service code [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Probably this one?

BaseConverter
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=82692&site_id=1#import

 Quote:
$ESC=BaseConverter("5RFDP01",36,10)

Top
#213140 - 2018-01-13 12:37 AM Re: Convert Dell service tag to Dell express service code [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4560
Loc: USA
Yeah that's what I was linking to, but I was thinking someone did a clean conversion UDF, but I never found it.
Top
#213141 - 2018-01-15 11:16 AM Re: Convert Dell service tag to Dell express service code [Re: Allen]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hmmmmm.... not sure how I missed those. I'll play around a bit and update when needed.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#213142 - 2018-01-15 01:37 PM Re: Convert Dell service tag to Dell express service code [Re: Mart]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hmmm..... does not seem to work ok. It's an older UDF but the conversions should be the same. With the example below I get incorrect results. When I use the example DOC posted in the link above and take out the WMI check part because it fails on Win 10 v1703 (see second code section below) I also get incorrect results. The info it takes from the BIOS is ok but the conversion gives me incorrect data.

I removed the actual service tag and expr. service code to prevent any issues with them in the future. If you want/need them for testing, let me know and I'll PM them to you.

 Code:
Break on

$rc = SetOption("WrapAtEOL", "On")

$stag = "xxxxxxx"
$expscode = "12345678901"

$conv = BaseConverter($stag, 36, 10)
?$conv

$conv = BaseConverter($expscode, 10, 36)
? $conv

Sleep 15

;Function BaseConverter()
;
;Authors
;	Howard Bullock
;	BrianTX
;	Shawn Tassie
;	Jooel Nieminen
;
;Version 1.0.1
;
;Version history
;	1.0.1 (5.6.2004) - fixed annoying variable scope problem
;	1.0 (7.7.2002) - initial kixgolf code
;
;Action Converts bases 2-36 from any to any
;
;Syntax BaseConverter($Value, $From, $To)
;
;Parameters
;	$Value - String or Integer, Value to be converted
;	$From - Integer, Base where convert from
;	$To - Integer, Base to convert to
;
;Remarks
;	Code was produces as kixgolf-competition.
;	For More info see topics:
;		http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=003447
;		http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=003458
;		http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=003470
;	Thanks to:
;		Sealeopard - our host on the competition
;		Kholm - for participating
;
;Returns
;	on success: Value converted to specified base
;	on error: nothing. sets error to 1
;
;Dependencies
;	None
;
;Example
;	"Value 44680832201 is in base10" ?
;	"when converted to base36 it's '"
;	BaseConverter('44680832201', 10, 36)
;	"'"
;
;Source

Function BaseConverter($v, $f, $t)
	Dim $, $e, $y, $n, $x, $z

	$ = 0
	$t = $ + $t
	$f = $ + $f
	$e = ($f > 36) | ( $t > 36 ) | ( $f < 2 ) | ( $t < 2 )   
	$y = 1.

	For $n = Len($v) to 1 step - 1
		$x = Asc(UCase(SubStr($v, $n, 1)))
		$z = ($x - 48 - ($x > 64) * 7)
		If ($z < 0) | ( ($x > 57) & ( $x < 65 ) ) | $e | ( $z > ( $f - 1 ) )
			Exit 1
		EndIf

		$ = $y * $z + $
		$y = $y * $f	
	Next

	$n = ""

	While $
		$x = Int($ - (Int($ / $t) * $t))
		$ = ($ - $x) / $t
		$n = Chr($x + 48 + ($x > 9) * 7) + $n
	Loop

	$BaseConverter = $n
EndFunction


Example based on code DOC posted.
 Code:
Break On
Dim $SO
$SO = SetOption('Explicit', 'On')
$SO = SetOption('NoVarsInStrings', 'On')
$SO = SetOption('NoMacrosInStrings', 'On')
 
Dim $Chk, $MyBIOSInfo
Dim $Mfg, $Model, $Ser, $Esc
;$Chk = WMIConfirm('computer name')
;If $Chk
	$MyBIOSInfo = GetBIOSInfo()
	If VarType($MyBIOSInfo) > 8
		$Mfg = $MyBIOSInfo[0]
		'Mfg: ' + $Mfg ?
		$Model = $MyBIOSInfo[1]
		'Model: ' + $Model ?
		$Ser = $MyBIOSInfo[2]
		'Serial / Tag number: ' + $Ser ?
		$Esc = BaseConverter($Ser, 36, 10)
		'Express Service Code: ' + $Esc ?
	Else
		'Error getting BIOS information. ' + @ERROR + ' - ' + @SERROR ?
	EndIf
;Else
;	'Error accessing WMI. ' + @ERROR + ' - ' + @SERROR ?
;EndIf

Sleep 20
 
Function WMIConfirm(optional $sComputer) 
	Dim $objWMIService, $objWMISetting, $colWMISettings 
	$sComputer = IIf(Not $sComputer, '', '\\' + Join(Split($sComputer, '\'), '', 3) + '\') 
	$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!" + $sComputer + 'root\cimv2') 
	; Failed - return 0 and exit with error value  
	If @ERROR 
		$WMIConfirm = 0 
		Exit Val('&' + Right(DecToHex(@ERROR), 4)) 
	EndIf 
	$colWMISettings = $objWMIService.ExecQuery("Select * from Win32_WMISetting") 
	For Each $objWMISetting in $colWMISettings 
		$WMIConfirm = $objWMISetting.BuildVersion 
	Next 
	Exit 0 
EndFunction
 
Function GetBIOSInfo(optional $sComputer)
	Dim $objWMIService, $Mfg, $Model, $Ser
	Dim $M, $S, $SerialNumber, $Manufacturer
	$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!" + $sComputer + 'root\cimv2')
	If @ERROR 
		$GetBIOSInfo = 0 
		Exit Val('&' + Right(DecToHex(@ERROR), 4)) 
	EndIf 
	$Mfg = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem",, 48)
	$Ser = $objWMIService.ExecQuery("Select * from Win32_BIOS",, 48)
	For Each $M in $Mfg
		If $M
			$Manufacturer = Trim($M.Manufacturer)
			$Model = Trim($M.Model)
		EndIf
	Next
	For Each $S in $Ser
		If $S
			$SerialNumber = Trim($S.SerialNumber)
		EndIf
	Next
	$GetBIOSInfo = $Manufacturer, $Model, $SerialNumber
	Exit 0
EndFunction
 
Function BaseConverter($v, $f, $t)
	Dim $, $e, $y, $n, $x, $z
	$ = 0
	$t = $ + $t
	$f = $ + $f
	$e = ($f > 36) | ( $t > 36 ) | ( $f < 2 ) | ( $t < 2 )   
	$y = 1.
	For $n = Len($v) to 1 step - 1
		$x = Asc(UCase(SubStr($v, $n, 1)))
		$z = ($x - 48 - ($x > 64) * 7)
		If ($z < 0) | ( ($x > 57) & ( $x < 65 ) ) | $e | ( $z > ( $f - 1 ) )
			Exit 1
		EndIf
		$ = $y * $z + $
		$y = $y * $f
	Next
	$n = ""
	While $
		$x = Int($ - (Int($ / $t) * $t))
		$ = ($ - $x) / $t
		$n = Chr($x + 48 + ($x > 9) * 7) + $n
	Loop
	$BaseConverter = $n
EndFunction


Edited by Mart (2018-01-15 01:42 PM)
Edit Reason: Removed actual service tag and expr. service code.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#213144 - 2018-01-16 02:08 AM Re: Convert Dell service tag to Dell express service code [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
The base URL has changed at Dell which broke my code a while back. One might be able to play with their URL some and see if it will still take it or not. But a lot of things on the computer nowadays are a lot more strict and don't allow as much give/take/send/grab as they used to which also might influence it working or not automatically.
Top
#213145 - 2018-01-16 10:53 AM Re: Convert Dell service tag to Dell express service code [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
This was interesting and took some hours figuring out, stoke and me had some fun with it and whipped up a UDF.
 Code:
Function baseN2dec($value, $inBase)
  Dim $strValue, $i, $c, $y
  $strValue = CStr(UCase($value))
  For $i=1 To Len($strValue)
    $c = Asc(SubStr($strValue, $i, 1))
    If ($i > 1) 
      $y = CDBL($y) * $inBase
    EndIf
    If ($c < 65)
      $c = $c - 48
    Else
      $c = $c - 55
    EndIf
    $y = $y + $c
  Next
  $baseN2dec = $y
EndFunction

Dim $strServiceTag, $strExpresCode
$strServiceTag = "G51JIC1" ;modified this to a non-existant service tag
$strExpresCode = baseN2dec($strServiceTag,36)

? "Serial Number: " + $strServiceTag
? "Express Code: " + $strExpresCode

Top
#213150 - 2018-01-17 09:16 AM Re: Convert Dell service tag to Dell express service code [Re: Arend_]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Great! Thanks.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#213151 - 2018-01-19 08:13 PM Re: Convert Dell service tag to Dell express service code [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Why do you need the Express Tag Mart?
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1005 anonymous users online.
Newest Members
min_seow, Audio, Hoschi, Comet, rrosell
17881 Registered Users

Generated in 0.062 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org