Jump to content

quickest way to format a mac address?


jefhal
 Share

Recommended Posts

What is the fastest (least code) method for turning a "raw" mac id into a "formatted" one?

i.e. turn 001122334455 into 00-11-22-33-44-55

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

how about this

Dim $Final = "", $xt = 1

$String =  "001122334455"

$Result = StringSplit($String, "")

For $x = 1 To $Result[0]
    
    If $x = $xt + 2 Then
        $xt = $x
        $Final = $Final & "-"
    EndIf
    
    $Final = $Final & $Result[$x]
    
    
Next

MsgBox(0,"Final Result", $Final )

8)

NEWHeader1.png

Link to comment
Share on other sites

$Result = StringSplit($String, "")
If $x = $xt + 2 Then

I like the stringsplit using "empty" and the use of $xt. Thank you! For some reason I thought you could use RegExp or StringFormat, as I really don't understand what those are for... ;)

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Heres my contribution:

Dim $mac_addy
$mac = "112233445566"
For $x = 1 To StringLen($mac) Step 2
    If $mac_addy = "" Then
        $mac_addy = StringMid($mac, $x, 2)
    Else
        $mac_addy = $mac_addy & "-" & StringMid($mac, $x, 2)
    EndIf
Next
Msgbox(0, "", $mac_addy)
Edited by sykes

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

Here's what I came up with...

Dim $strMAC = "001122334455"
Dim $strTemp
For $x = 0 to (StringLen($strMAC) / 2) - 1
    $strTemp = $strTemp & StringMid($strMAC, 1 + ($x * 2), 2) & "-"
Next
$strMAC = StringLeft($strTemp, StringLen($strTemp) - 1)

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

For $x = 1 To StringLen($mac) Step 2

$mac_addy = $mac_addy & "-" & StringMid($mac, $x, 2)

Sherman, get me another cigar! What's great about coding is that there are always 5 ways to accomplish the same thing! StringMid and Step 2...

(StringLen($strMAC) / 2) - 1

StringMid($strMAC, 1 + ($x * 2), 2) & "-"

I'm running out of cigars, people! StringLen divided by 2 and $x times 2... who woulda thunk? Another superb offering! Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

$formatted = StringLeft($raw, 2)

for $i = 3 to StringLen($raw) - 1 Step 2

Wow! Give the loop a headstart by setting $formatted to the first two chars. Sweet. Panatella or Churchill?

Here's my own attempt at the cigar!

dim $var = "001a2b3c4d5e", $ans = ""
for $i = 1 to 11 step 2
    $ans = stringleft($ans & StringMid($var,$i,2) & "-",17)
Next
MsgBox(4096,"answer is: ",$ans)

Of course, this was AFTER seeing all of your fine attempts!

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

The Test... 1 to 21 numbers picked at random

the script

#include <File.au3>

Dim $Number="", $Load=""

For $tetster = 1 to 21

    $Number = Random( 1, 9, 1)
    $Load = $Load & $Number

Dim $Final = "", $xt = 1
$String =  $Load
$Result = StringSplit($String, "")
For $x = 1 To $Result[0]
    If $x = $xt + 2 Then
        $xt = $x
        $Final = $Final & "-"
    EndIf
    $Final = $Final & $Result[$x]
Next

_FileWriteLog("C:\test.txt", "Valuater " & $Final )

Next

_FileWriteLog("C:\test.txt", "*************************************************************")

Dim $Number="", $Load=""

For $tetster = 1 to 21

    $Number = Random( 1, 9, 1)
    $Load = $Load & $Number

Dim $mac_addy
$mac = $Load
For $x = 1 To StringLen($mac) Step 2
If $mac_addy = "" Then
$mac_addy = StringMid($mac, $x, 2)
Else
$mac_addy = $mac_addy & "-" & StringMid($mac, $x, 2)
EndIf
Next
;Msgbox(0, "", $mac_addy)

_FileWriteLog("C:\test.txt", "sykes " & $mac_addy )

Next

_FileWriteLog("C:\test.txt", "*************************************************************")

Dim $Number="", $Load=""

For $tetster = 1 to 21

    $Number = Random( 1, 9, 1)
    $Load = $Load & $Number

Dim $strMAC = $Load
Dim $strTemp
For $x = 0 to (StringLen($strMAC) / 2) - 1
$strTemp = $strTemp & StringMid($strMAC, 1 + ($x * 2), 2) & "-"
Next
$strMAC = StringLeft($strTemp, StringLen($strTemp) - 1)

_FileWriteLog("C:\test.txt", "Skrug " & $strMAC )

Next

_FileWriteLog("C:\test.txt", "*************************************************************")

Dim $Number="", $Load=""

For $tetster = 1 to 21

    $Number = Random( 1, 9, 1)
    $Load = $Load & $Number

$raw = $Load
$formatted = StringLeft($raw, 2)
for $i = 3 to StringLen($raw) - 1 Step 2
$formatted = $formatted & "-" & StringMid($raw, $i, 2)
Next

_FileWriteLog("C:\test.txt", "bluebearr " & $formatted )

Next

_FileWriteLog("C:\test.txt", "*************************************************************")

and the results

2005-10-10 18:06:08 : Valuater 7
2005-10-10 18:06:08 : Valuater 71
2005-10-10 18:06:08 : Valuater 71-5
2005-10-10 18:06:08 : Valuater 71-59
2005-10-10 18:06:08 : Valuater 71-59-4
2005-10-10 18:06:08 : Valuater 71-59-43
2005-10-10 18:06:08 : Valuater 71-59-43-6
2005-10-10 18:06:08 : Valuater 71-59-43-69
2005-10-10 18:06:08 : Valuater 71-59-43-69-9
2005-10-10 18:06:08 : Valuater 71-59-43-69-91
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-1
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-9
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99-2
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99-27
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99-27-8
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99-27-89
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99-27-89-5
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99-27-89-52
2005-10-10 18:06:08 : Valuater 71-59-43-69-91-12-99-27-89-52-4
2005-10-10 18:06:08 : *************************************************************
2005-10-10 18:06:08 : sykes 9
2005-10-10 18:06:08 : sykes 9-92
2005-10-10 18:06:08 : sykes 9-92-92-5
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51-92-56-87-59-52-82-51-6
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51-92-56-87-59-52-82-51-6-92-56-87-59-52-82-51-65
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51-92-56-87-59-52-82-51-6-92-56-87-59-52-82-51-65-92-56-87-59-52-82-51-65-9
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51-92-56-87-59-52-82-51-6-92-56-87-59-52-82-51-65-92-56-87-59-52-82-51-65-9-92-56-87-59-52-82-51-65-99
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51-92-56-87-59-52-82-51-6-92-56-87-59-52-82-51-65-92-56-87-59-52-82-51-65-9-92-56-87-59-52-82-51-65-99-92-56-87-59-52-82-51-65-99-8
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51-92-56-87-59-52-82-51-6-92-56-87-59-52-82-51-65-92-56-87-59-52-82-51-65-9-92-56-87-59-52-82-51-65-99-92-56-87-59-52-82-51-65-99-8-92-56-87-59-52-82-51-65-99-83
2005-10-10 18:06:08 : sykes 9-92-92-5-92-56-92-56-8-92-56-87-92-56-87-5-92-56-87-59-92-56-87-59-5-92-56-87-59-52-92-56-87-59-52-8-92-56-87-59-52-82-92-56-87-59-52-82-5-92-56-87-59-52-82-51-92-56-87-59-52-82-51-6-92-56-87-59-52-82-51-65-92-56-87-59-52-82-51-65-9-92-56-87-59-52-82-51-65-99-92-56-87-59-52-82-51-65-99-8-92-56-87-59-52-82-51-65-99-83-92-56-87-59-52-82-51-65-99-83-6
2005-10-10 18:06:08 : *************************************************************
2005-10-10 18:06:08 : Skrug 
2005-10-10 18:06:08 : Skrug 48
2005-10-10 18:06:08 : Skrug 48-48
2005-10-10 18:06:08 : Skrug 48-48-48-32
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38-48-32-22-27-58-61-38
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38-48-32-22-27-58-61-38-48-32-22-27-58-61-38-73
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38-48-32-22-27-58-61-38-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38-48-32-22-27-58-61-38-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-41
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38-48-32-22-27-58-61-38-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-41-48-32-22-27-58-61-38-73-41
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38-48-32-22-27-58-61-38-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-41-48-32-22-27-58-61-38-73-41-48-32-22-27-58-61-38-73-41-74
2005-10-10 18:06:08 : Skrug 48-48-48-32-48-32-48-32-22-48-32-22-48-32-22-27-48-32-22-27-48-32-22-27-58-48-32-22-27-58-48-32-22-27-58-61-48-32-22-27-58-61-48-32-22-27-58-61-38-48-32-22-27-58-61-38-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-48-32-22-27-58-61-38-73-41-48-32-22-27-58-61-38-73-41-48-32-22-27-58-61-38-73-41-74-48-32-22-27-58-61-38-73-41-74
2005-10-10 18:06:08 : *************************************************************
2005-10-10 18:06:08 : bluebearr 6
2005-10-10 18:06:08 : bluebearr 69
2005-10-10 18:06:08 : bluebearr 69
2005-10-10 18:06:08 : bluebearr 69-62
2005-10-10 18:06:08 : bluebearr 69-62
2005-10-10 18:06:08 : bluebearr 69-62-95
2005-10-10 18:06:08 : bluebearr 69-62-95
2005-10-10 18:06:08 : bluebearr 69-62-95-66
2005-10-10 18:06:08 : bluebearr 69-62-95-66
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63-58
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63-58
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63-58-74
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63-58-74
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63-58-74-73
2005-10-10 18:06:08 : bluebearr 69-62-95-66-37-21-63-58-74-73
2005-10-10 18:06:08 : *************************************************************

and the winner is

YAAAAAAAA!!!!!!!!! the hobbyist..... Valuater.. ;) ..... :P ...... :mad2: ......

NEWHeader1.png

Link to comment
Share on other sites

The Test... 1 to 21 numbers picked at random

and the winner is

YAAAAAAAA!!!!!!!!! the hobbyist..... Valuater.. ;) ..... :P ...... :mad2: ......

Valuater- I hate to burst such a BIG bubble, but MAC-ID's always come in six pairs. You do win First Prize for being "First" with a solution! That is often better than "Perfect"!

By the way, how did my code fare?

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Nobody could do it without a loop, eh?

Local $sOriginal = "112233445566"
Local $sFormatted = StringRegExpReplace($sOriginal, "(.{2}){6}", "\1-\2-\3-\4-\5-\6")
MsgBox(0, "", $sFormatted)
YES! THAT's WHAT I WAS LOOKING FOR! I could feel that RegExp had SOMETHING to do with formatting, but could NOT figure it out from the Vulcan writing in the help file on StringRegExpReplace. (Fine if you're a Vulcan --- or a Valik!) :dance:

Thanks to everyone for a very entertaining evening and a lot of first class solutions to this infuriatingly simple problem. I really do need it for work... Sleep well! :P:mad2::oops:

Amazing stuff! ;)

Simon says: Quick, pick a color from 1 to 10.

jefhal says: "Q" Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Amazing stuff! ;)

Simon says: Quick, pick a color from 1 to 10.

While such a comment may suffice to confuse an art student you forget that you are dealing with a bunch of people writing software (more or less). I see nothing wrong with asking to pick a color between two numbers although your choice of numbers relegates to selecting only black.
Link to comment
Share on other sites

Valuater- I hate to burst such a BIG bubble, but MAC-ID's always come in six pairs. You do win First Prize for being "First" with a solution! That is often better than "Perfect"!

By the way, how did my code fare?

I did this test thinking in Future value... doesn't matter if its a mac-id or what ever... 8)

Because you asked

2005-10-10 19:10:41 : jefhal4-----------
2005-10-10 19:10:41 : jefhal47-----------
2005-10-10 19:10:41 : jefhal47-9----------
2005-10-10 19:10:41 : jefhal47-94----------
2005-10-10 19:10:41 : jefhal47-94-9---------
2005-10-10 19:10:41 : jefhal47-94-98---------
2005-10-10 19:10:41 : jefhal47-94-98-9-------
2005-10-10 19:10:41 : jefhal47-94-98-98------
2005-10-10 19:10:41 : jefhal47-94-98-98-7----
2005-10-10 19:10:41 : jefhal47-94-98-98-71---
2005-10-10 19:10:41 : jefhal47-94-98-98-71-1-
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : jefhal47-94-98-98-71-17
2005-10-10 19:10:41 : *************************************************************
2005-10-10 21:22:17 : Valik 9
2005-10-10 21:22:17 : Valik 95
2005-10-10 21:22:17 : Valik 959
2005-10-10 21:22:17 : Valik 9593
2005-10-10 21:22:17 : Valik 95935
2005-10-10 21:22:17 : Valik 959354
2005-10-10 21:22:17 : Valik 9593545
2005-10-10 21:22:17 : Valik 95935454
2005-10-10 21:22:17 : Valik 959354546
2005-10-10 21:22:17 : Valik 9593545467
2005-10-10 21:22:17 : Valik 95935454672
2005-10-10 21:22:17 : Valik 95-93-54-54-67-27
2005-10-10 21:22:17 : Valik 95-93-54-54-67-274
2005-10-10 21:22:17 : Valik 95-93-54-54-67-2741
2005-10-10 21:22:17 : Valik 95-93-54-54-67-27417
2005-10-10 21:22:17 : Valik 95-93-54-54-67-274179
2005-10-10 21:22:17 : Valik 95-93-54-54-67-2741797
2005-10-10 21:22:17 : Valik 95-93-54-54-67-27417979
2005-10-10 21:22:17 : Valik 95-93-54-54-67-274179798
2005-10-10 21:22:17 : Valik 95-93-54-54-67-2741797983
2005-10-10 21:22:17 : Valik 95-93-54-54-67-27417979839
2005-10-10 21:22:17 : *************************************************************

EDIT

forgot to reset the variables for Valik... now corrected

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I did this test thinking in Future value... doesn't matter if its a mac-id or what ever... 8)

Valuater- Thanks for plotting my solution! You're right about the General solution being better than just a specific solution (didn't it take Einstein longer to create the General Theory of Relativity?) Of course, the next problem that came into mind was formatting a phone number! I'm going to look at RegExp's to see if I can extend Valik's ideas to a 3-3-4 format. Time to get out the Vulcan Dictionary!

;)

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Here's the code (thanks to Valik) for formatting a phone number!

Local $sOriginal = "1234567890"
Local $sFormatted = StringRegExpReplace($sOriginal, "(.{3}){2}(....{1})", "\1-\2-\3")
MsgBox(0, "", $sFormatted)
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Simon says: Quick, pick a color from 1 to 10.

Is this the scale from which we are choosing:

1 Microwave

2 Infrared

3 Red

4 Orange

5 Yellow

6 Green

7 Blue

8 Violet

9 Ultraviolet

10 Xray

Do the colors have to come from the Human "visible spectrum", or some other sample population?

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...