{"id":226,"date":"2016-06-16T23:38:49","date_gmt":"2016-06-16T21:38:49","guid":{"rendered":"http:\/\/arnoldvanhofwegen.com\/blog\/?p=226"},"modified":"2016-06-17T11:45:52","modified_gmt":"2016-06-17T09:45:52","slug":"delineenline-community-effort-part-3","status":"publish","type":"post","link":"https:\/\/arnoldvanhofwegen.com\/blog\/delineenline-community-effort-part-3\/","title":{"rendered":"DELINE\/ENLINE (community effort) Part 3"},"content":{"rendered":"<p>The testing goes on. Focussing on <code>\/with<\/code> and in particular the <code>char<\/code> case now.<\/p>\n<p>So now we have this code<\/p>\n<pre>\r\n\tdeline*: func [\r\n\t\tcheck?   [logic!]\r\n\t\t_with [integer!]\t\t\t\t\t\t\t\t\t;-- with is reserved \r\n\t\tlines [integer!]\r\n\t\t\/local\r\n\t\t\tdata \t[red-string!]\r\n\t\t\tbuffer\t[red-string!]\r\n\t\t\tval  \t[red-value!]\r\n\t\t\twith-arg [red-value!]\t\t\t\t\t\t\t;-- with char! or string! value\r\n\t\t\tchar \t[red-char!]\r\n\t\t\ts\t \t[series!]\r\n\t\t\tp\t\t[byte-ptr!]\r\n\t\t\tlen  \t[integer!]\r\n\t\t\tunit \t[integer!]\r\n\t\t\tcp   \t[integer!]\r\n\t\t\tcr   \t[integer!]\r\n\t\t\tlf   \t[integer!]\r\n\t\t\tp4        [int-ptr!]\r\n\t\t\tblk\t\t[red-block!]\r\n\t\t\ttail      [byte-ptr!]\r\n\r\n\t][\r\n\t\t#typecheck [deline _with lines]\r\n\t\tdata: as red-string! stack\/arguments\r\n\t\tprint lines print _with\r\n\t\tlf: 10\r\n\t\tcr: 13\r\n\t\teither positive? lines [\r\n\t\t\tprint \"lines refinement found\"\r\n\t\t\tval\/header: TYPE_BLOCK\r\n\r\n\t\t\t; To do: return a block of lines using some split functionality\r\n\t\t][\r\n\t\t\teither positive? _with [\r\n\t\t\t\tprint \"with refinement found\"\r\n\t\t\t\tval: as red-value! data + 1\r\n\t\t\t\teither TYPE_OF(val) = TYPE_CHAR [\r\n\t\t\t\t\tprint \"char type\"\r\n\t\t\t\t\t;print val\r\n\t\t\t\t\t;val\/header: TYPE_CHAR\r\n\t\t\t\t\tlf: val\/data2\r\n\t\t\t\t\tprint lf\r\n\t\t\t\t][  print \"string type\"\r\n\t\t\t\t\t;print val\r\n\t\t\t\t\tval\/header: TYPE_STRING\r\n\t\t\t\t]\r\n\t\t\t][print \"No refinement used\" ]\r\n\t\t]\r\n\r\n\t\ts:  GET_BUFFER(data)\r\n\t\tunit: GET_UNIT(s)\r\n\t\tp:\t  string\/rs-head data\r\n\t\tlen:  string\/rs-length? data\r\n\t\ttail: as byte-ptr! s\/tail\r\n\t\tprint val\/header print \"-\" print val\/data1 print \"-\" print val\/data2 print \"-\" print val\/data3\r\n\t\tbuffer: string\/rs-make-at stack\/push* ( len ) * unit\r\n\r\n\t\twhile [p < tail][\r\n\t\t\tcp: switch unit [\r\n\t\t\t\tLatin1 [as-integer p\/value]\r\n\t\t\t\tUCS-2  [(as-integer p\/2) << 8 + p\/1]\r\n\t\t\t\tUCS-4  [p4: as int-ptr! p p4\/value]\r\n\t\t\t]\r\n\r\n\t\t\tp: p + unit\r\n\t\t\teither 13 = cp [ ; CR\r\n\t\t\t\tstring\/append-char GET_BUFFER(buffer) lf unit\r\n\t\t\t\tp: p + unit\r\n\t\t\t\tcp: switch unit [\r\n\t\t\t\t\tLatin1 [as-integer p\/value]\r\n\t\t\t\t\tUCS-2  [(as-integer p\/2) << 8 + p\/1]\r\n\t\t\t\t\tUCS-4  [p4: as int-ptr! p p4\/value]\r\n\t\t\t\t]\r\n\t\t\t\tif 10 = cp [\r\n\t\t\t\t\tp: p + unit            \t\t\t\t;-- Next!\r\n\t\t\t\t]\r\n\t\t\t][\r\n\t\t\t\teither 10 = cp [\r\n\t\t\t\t\tstring\/append-char GET_BUFFER(buffer) lf unit\r\n\t\t\t\t][\r\n\t\t\t\t\tstring\/append-char GET_BUFFER(buffer) cp unit\r\n\t\t\t\t\t;string\/append-char GET_BUFFER(buffer) 97 unit ;-- \"a\" for testing \r\n\t\t\t\t]\r\n\t\t\t]\r\n\t\t]\r\n\t\tstack\/set-last as red-value! buffer\r\n\t\tbuffer\r\n\t]\r\n<\/pre>\n<p>Still using a lot of debugging prints and plenty odd variables. But still compiling and also now returning some results.<\/p>\n<pre>\r\nred>> deline\/with {hello\r\n{    all} \"b\"\r\n-11with refinement foundstring type7-0-3473324-0== \"hello^\/all\"\r\nred>> deline\/with {hello\r\n{    all} #\"b\"\r\n-11with refinement foundchar type9810-15-98-0== \"helloball\"\r\nred>> \r\n<\/pre>\n<p>Feeling more and more confident, in the next blog some prints can be removed, and experiment with returning a block is still on the list.<\/p>\n<p>To be continued...<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The testing goes on. Focussing on \/with and in particular the char case now. So now we have this code deline*: func [ check? [logic!] _with [integer!] ;&#8211; with is reserved lines [integer!] \/local data [red-string!] buffer [red-string!] val [red-value!] &hellip; <a href=\"https:\/\/arnoldvanhofwegen.com\/blog\/delineenline-community-effort-part-3\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"gallery","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts\/226"}],"collection":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/comments?post=226"}],"version-history":[{"count":1,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":227,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts\/226\/revisions\/227"}],"wp:attachment":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/media?parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/categories?post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/tags?post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}