# Structure (enum?) like EndOfLine

**URL:** <https://ifnotnil.com/t/structure-enum-like-endofline/580>\
**Category:** Other\
**Created:** [6 June 2020 14:26 UTC](https://ifnotnil.com/t/structure-enum-like-endofline/580 "2020-06-06T14:26:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [6 June 2020 14:26 UTC](https://ifnotnil.com/t/structure-enum-like-endofline/580/1 "2020-06-06T14:26:13Z")

</div>

How would you create something that works in a manner like EndOfLine does?

I mean… it basically has two syntax

- x=EndOfLine – returns a value based on platform
- x=EndOfLine.xxx - returns a designated value

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [6 June 2020 17:44 UTC](https://ifnotnil.com/t/structure-enum-like-endofline/580/2 "2020-06-06T17:44:40Z")

</div>

EndOf Line is a lot of misdirection 🙂  
There seems to be a global function, EndOfLine, that returns an instance of the EndOfLine Class  
The EndOfLine class has an operator\_convert TO method on it and also ones for OSX, Unix, Windows, and Macintosh line endings.  
Something like

```auto
Module GlobalFunctions
     Global Function EndOfLine() As EndOfLine

Class EndOfLine
	Public Shared Property Macintosh As String
	Public Shared Property OSX As String
	Public Shared Property UNIX As String
	Public Shared Property Windows As String

	Public Function Operator_Add(value As String) As String	
	Public Function Operator_AddRight(value As String) As String
	Public Function Operator_Compare(value As String) As Integer
	Public Function Operator_Convert() As String
End Class

```

introspection can be useful 🙂

```auto
Dim eol As New EndOfLine

Dim tinfo As Xojo.Introspection.TypeInfo = xojo.Introspection.GetType(eol)

Dim pInfo() As Xojo.Introspection.PropertyInfo = tInfo.Properties

For Each prop As Xojo.Introspection.PropertyInfo In pInfo
  Dim typeInfo As Xojo.Introspection.TypeInfo = prop.PropertyType
  
  System.DebugLog prop.Name + " as " + typeInfo.Name
  
Next

Dim mInfo() As Xojo.Introspection.MethodInfo = tInfo.Methods

For Each meth As Xojo.Introspection.MethodInfo In mInfo
  
  Dim typeInfo As Xojo.Introspection.TypeInfo = meth.ReturnType
  
  System.DebugLog meth.Name + "() as " + typeInfo.Name
  
Next

```

EDIT : for those wondering how I know EndOfLine has to be both a class AND a method as described here’s how. ( I’m not “hacking the framework” or anything like that) Code like

```auto
dim s as string = "foo " + EndOfLine + "bar"

```

would not compile IF endofline were just a class. I would get an error. The global method is required to make such a line work.  
Reasoning & experimentation tell me it MUST be this way as I can make a version of this work in my own code (renamed EndOfLine as myEndOfLine) and the code

```auto
dim s as string = "foo " + myEndOfLine + "bar"

```

works

EDIT 2 : [here’s the sample in Xojo](http://great-white-software.com/miscellaneous/my%20end%20of%20line%20sample.zip)
