Created
February 9, 2018 21:41
-
-
Save ImkeF/1633eef352bb017b4d84ad3cd23d394e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(Value as any) as text => | |
let | |
t = Value.Type(Value), | |
nonNullableType = Type.NonNullable(t), | |
TypeDescription = | |
if Type.Is(nonNullableType, type number) then "number" | |
else if Type.Is(nonNullableType, type text) then "text" | |
else if Type.Is(nonNullableType, type date) then "date" | |
else if Type.Is(nonNullableType, type null) then "null" | |
else if Type.Is(nonNullableType, type datetime) then "datetime" | |
else if Type.Is(nonNullableType, type time) then "time" | |
else if Type.Is(nonNullableType, type datetimezone) then "datetimezone" | |
else if Type.Is(nonNullableType, type duration) then "duration" | |
else if Type.Is(nonNullableType, type table) then "table" | |
else if Type.Is(nonNullableType, type record) then "record" | |
else if Type.Is(nonNullableType, type list) then "list" | |
else if Type.Is(nonNullableType, type function) then "function" | |
else if Type.Is(nonNullableType, type logical) then "logical" | |
else if Type.Is(nonNullableType, type none) then "none" | |
else if Type.Is(nonNullableType, type type) then "type" | |
else if Type.Is(nonNullableType, type binary) then "binary" | |
else if Type.Is(nonNullableType, type action) then "action" | |
else if Type.Is(type anynonnull, nonNullableType) then "any" | |
else error "Unknown type", | |
TypeString = if TypeDescription = "any" then | |
if Type.IsNullable(t) then | |
"any" else "anynonnull" | |
else if Type.IsNullable(t) then | |
"nullable " & TypeDescription | |
else TypeDescription | |
in | |
TypeString | |
, documentation = [ | |
Documentation.Name = " Type.Text | |
", Documentation.Description = " Returns the type of the <code>Value</code> in textform. | |
" , Documentation.LongDescription = " Returns the type of the <code>Value</code> in textform. | |
", Documentation.Category = " Type | |
", Documentation.Source = " local | |
", Documentation.Author = " Imke Feldmann: www.TheBIccountant.com . | |
", Documentation.Examples = {[Description = " Returns the type of the <code>Value</code> in textform. | |
" , Code = " Type.Text(2) | |
", Result = " number | |
"]}] | |
in | |
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment