output file "CSV2HTML" include "Tlbx WebKit.incl" _window = 1 begin enum output 1 _webView end enum void local fn BuildWindow CGRect r = fn CGRectMake( 0, 0, 600, 220 ) window _window, @"Rosetta Code CSV to HTML", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable r = fn CGRectMake( 20, 20, 560, 180 ) wkwebview _webView, r,, _window end fn local fn CSV2HTML as CFStringRef NSUInteger i, count CFStringRef csvStr = @"Character,Speech\n¬ The multitude,The messiah! Show us the messiah!\n¬ Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!\n¬ The multitude,Who are you\n¬ Brians mother,I'm his mother; that's who!\n¬ The multitude,Behold his mother! Behold his mother!" CFArrayRef linesArray = fn StringComponentsSeparatedByString( csvStr, @"\n" ) CFMutableStringRef htmlStr = fn MutableStringWithCapacity(0) MutableStringAppendString( htmlStr, @"\n" ) MutableStringAppendString( htmlStr, @"" ) MutableStringAppendString( htmlStr, @"\n" ) count = len( linesArray ) for i = 1 to count - 1 CFStringRef tempStr = linesArray[i] CFArrayRef tempArr = fn StringComponentsSeparatedByString( tempStr, @"," ) MutableStringAppendString( htmlStr, @"\n" ) MutableStringAppendString( htmlStr, fn StringWithFormat( @">\n", tempArr[0] ) ) MutableStringAppendString( htmlStr, fn StringWithFormat( @"\n", tempArr[1] ) ) MutableStringAppendString( htmlStr, @"\n" ) next MutableStringAppendString( htmlStr, @"
CharacterSpeech
From Monty Python's \"The Life of Brian\"
%@%@


" ) end fn = fn StringWithString( htmlStr ) local fn LoadHTML2WebView CFStringRef htmlStr = fn CSV2HTML fn WKWebViewLoadHTMLString( _webView, htmlStr, NULL ) end fn void local fn DoDialog( ev as long, tag as long, wnd as long, obj as CFTypeRef ) select (ev) case _windowWillClose : end end select end fn on dialog fn DoDialog fn BuildWindow fn LoadHTML2WebView HandleEvents