Hello Rich,
You are welcome. The following code is what I have. I have put it in the “Open” event handler of the “App” class, so it is easy to add new functions and run it.
This is what I have :
[code] // This Dim must be before the “Using Xojo.IO” line
// to create a Classic FolderItem.
Dim f_CF_Map As FolderItem
Using Xojo.Core // Using the “Core” functions in the new framework
Using Xojo.IO // Using the “IO” InputOutput functions in the new framework
// Xojo.Core variables (to make the following code work as a demo)
Dim textExample As Text
Dim textCharacter As Text
Dim textReverse As Text
Dim textBlank As Text
Dim textResult As Text
Dim textCaseResult As Text
Dim textNewText As Text
Dim textTA() As Text
Dim textFifthCharacter As Text
Dim textSplit() As Text
Dim textArray() As Text
Dim textJoinText As Text
Dim textTrimText As Text
Dim textTrimResult As Text
Dim textChar As Text
Dim UintCodepoint As UInteger
Dim UintCP As UInteger
Dim intCompareResult As Integer
Dim intLen As Integer
Dim intPos As Integer
Dim blnResult As Boolean
// Xojo.IO variables
Dim textOutput As Text
Dim textRecord As Text
Dim f_Map As FolderItem // Xojo.IO FolderItem
Dim f_NF_Map As FolderItem // Xojo.IO FolderItem
Dim tosOutput As TextOutputStream
Dim tisInput As TextInputStream
//Dim f_NF_Map As xojo.IO.FolderItem
textExample = “Hello, World!”
// BeginsWith
blnResult = textExample.BeginsWith(“Hello”) // Returns True
blnResult = textExample.BeginsWith(“hello”) // Returns True
blnResult = textExample.BeginsWith(“hello”, Text.CompareCaseSensitive) // Returns False
// EndsWith
blnResult = textExample.EndsWith("!") // Returns True
blnResult = textExample.EndsWith(“World!”) // Returns True
blnResult = textExample.EndsWith(“world!”, Text.CompareCaseSensitive) // Returns False
// Show boolean result
//MsgBox Str(blnResult)
// Characters and Codepoints
For Each textCharacter in textExample.Characters
textReverse = textCharacter + textReverse
Next
// Show result (!dlroW ,olleH)
// MsgBox textReverse
// Codepoints
For Each UintCP in textExample.Codepoints
UintCodepoint = UintCP
// Show Results
// MsgBox Str(UintCodepoint) // Shows decimal value of each codepoint (character)
Next
// Compare
intCompareResult = textExample.Compare(“hello, world!”) // Value 0; matched
intCompareResult = textExample.Compare(“abc”) // Value 1; original text is greater than “abc”
intCompareResult = textExample.Compare(“Xojo”) // Value -1; original text is less than “Xojo”
intCompareResult = textExample.Compare(“hello, world!”, Text.CompareCaseSensitive) // Value -1
intCompareResult = textExample.Compare(“Hello, world!”, Text.CompareCaseSensitive) // Value -1
// Empty
blnResult = textExample.Empty // Returns False
blnResult = textBlank.Empty // Returns True
// Length
intLen = textExample.Length // Value 13; “Hello, World!”
// IndexOf (is ZERO based)
intPos = textExample.IndexOf(“World”) // Value 7 (start position)
intPos = textExample.IndexOf(“world”) // Value 7 (start position)
intPos = textExample.IndexOf(“world”, Text.CompareCaseSensitive) // Value -1 (case sensitive now)
// Left, Mid, Right
textResult = textExample.Left(5) // Hello
textResult = textExample.Right(6) // World!
textResult = textExample.Mid(7, 5) // Value World (Remember; Mid is ZERO based)
// Lowercase, Titlecase, Uppercase
textCaseResult = textExample.Lowercase // Value hello,world!
textCaseResult = textExample.TitleCase // Value Hello, World! (each word start uppercase)
textCaseResult = textExample.Uppercase // Value HELLO WORLD!
// Replace
textNewText = textExample.Replace(“World”, “Earth”) // Value Hello, Earth!
textNewText = textExample.Replace(“world”, “Earth”) // Value Hello, Earth! (case insensitive)
// Split, Join
textTA() = textExample.Split // Split ALL characters in individual array elements
// Split on 5th character (ZERO based)
textFifthCharacter = TextTA(4) // Value “o” (Position within array is ZERO based)
textSplit() = textExample.Split(",")
// Value textSplit(0) = “Hello”
// Value textSplit(1) = " World!"
// Join
textArray() = Array(“One”, “Two”, “Three”, “Four”)
textJoinText = Text.Join(textArray, “,”) // Value One,Two,Three,Four
// TrimLeft, TrimRight, Trim
textTrimText = " hello "
textTrimResult = textTrimText.Trim // Value “hello” (without quotes)
textTrimResult = textTrimText.TrimLeft // Value “hello " (without quotes)
textTrimResult = textTrimText.TrimRight // Value " hello” (without quotes)
// FromUnicodeCodepoint, Literal
textChar = Text.FromUnicodeCodepoint(224) // Value “” (without quotes)
textChar = &uE0 // Value “” (without quotes)
// Xojo.IO
textOutput = “How much would could a woodchuck chuck if a woodchuck could chuck wood”
// Writing to disk.
// Get a valid FolderItem
f_Map = SpecialFolder.Documents.Child(“Woodchuck.txt”)
// Creating textfile with TextEncoding UTF16
tosOutput = TextOutputStream.Create(f_Map, TextEncoding.UTF16)
// Writing to text file, with encoding UTF16
tosOutput.Write(textOutput)
// Closing TextOutputStream
tosOutput.Close
// Reading from disk
//Open file we created above
tisInput = TextInputStream.Open(f_Map, TextEncoding.UTF16)
// Reading the content of the file
textRecord = tisInput.ReadAll
// closing TextInputStream
tisInput.Close
// Creating a Xojo.IO.FolderItem from a FolderItem coming from the Classic FrameWork
f_CF_Map = GetOpenFolderItem("")
f_NF_Map = New Xojo.IO.FolderItem(f_CF_Map.NativePath.ToText)
MsgBox f_NF_Map.Path
[/code]
I download the webinars of Paul Lefevre which are very educational and nice to follow. However I had one problem, after viewing things get lost and I had to look them up again. So I thought by myself, I create and empty desktop project and add those code at a central place to it. It made things much easier for me.
So you should not only thank me but also Paul Lefevre which in first place teached me all those things.
Maybe it is a good idea if other people can also contribute, to add their findings also here, so we share with each other.
Thank you very much for your nice reply.
Chris