NormalizeUuid$ ( value$ )
Parameters
| value$ - UUID text in D, N or braced form |
Description
|
Returns a UUID as canonical lowercase dashed text, or an empty string if invalid. Ids arrive in mixed styles: an old save wrote them braced, an external tool exported 32 bare hex digits, someone typed one in uppercase. NormalizeUuid collapses every accepted form - the same three that UuidValid accepts (D, N and braced, any letter case) - into one canonical spelling: lowercase 8-4-4-4-12, the same form CreateUuid emits. That single spelling is the point: once every id in your game passes through NormalizeUuid at its border (loading a save, receiving a message, importing mod data), ids compare with plain = , work as Map keys, and never mismatch over case or dashes. Compare normalized against normalized, and store only the normalized form. Invalid text returns an empty string rather than an error, so it doubles as a validate-and-convert in one call - check the result against "" when the input is untrusted. For the full rules, see the Application Data language reference. Requires Extended mode. See also: UuidValid, CreateUuid, UuidToBytes, UuidFromBytes. |
Example
; NormalizeUuid Example ; --------------------- ; Requires Extended mode. ; Object ids arrive in mixed styles from old save files and other ; tools. NormalizeUuid converts every accepted form to canonical ; lowercase dashed (D) text, so ids compare as plain strings. n_form$="00112233445566778899AABBCCDDEEFF" braced$="{00112233-4455-6677-8899-AABBCCDDEEFF}" Print "N form uppercase: "+n_form Print " normalized -> "+NormalizeUuid(n_form) Print "" Print "Braced uppercase: "+braced Print " normalized -> "+NormalizeUuid(braced) Print "" ; Both normalize to the same string, so they can be compared Print "Same id after normalizing: "+(NormalizeUuid(n_form)=NormalizeUuid(braced)) Print "" ; Invalid text normalizes to an empty string Print "NormalizeUuid('not-a-uuid') = '"+NormalizeUuid("not-a-uuid")+"' (empty = invalid)" Print "" Print "Press any key to close the example" WaitKey End
Index