templeos-info/public/Wb/Home/Src/Demo/PhoneNumWords.HC.HTML

95 lines
6.2 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF1>U8</span><span class=cF0> char_map[26]=</span><span class=cF6>&quot;22233344455566677778889999&quot;</span><span class=cF0>;
<a name="l2"></a>
<a name="l3"></a></span><span class=cF2>/*</span><span class=cF0>
<a name="l4"></a></span><span class=cF2>Fmt of word lst entry:</span><span class=cF0>
<a name="l5"></a></span><span class=cF2> U8 ACD_WORD_CHAR</span><span class=cF0>
<a name="l6"></a></span><span class=cF2> U8 word[] with terminating zero</span><span class=cF0>
<a name="l7"></a></span><span class=cF2> I16 block; //definition offset in ::/Adam/AutoComplete/ACDefs.DATA</span><span class=cF0>
<a name="l8"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l9"></a></span><span class=cF1>U0</span><span class=cF0> PhoneNumWords(</span><span class=cF1>U8</span><span class=cF0> *num)
<a name="l10"></a>{
<a name="l11"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
<a name="l12"></a> </span><span class=cF1>U8</span><span class=cF0> *_num=</span><span class=cF5>StrNew</span><span class=cF0>(num),*dst=_num,
<a name="l13"></a> *dict=</span><span class=cFB>acd</span><span class=cF0>.word_lst,*st,*src;
<a name="l14"></a> </span><span class=cF1>while</span><span class=cF0> (*num) </span><span class=cF7>{</span><span class=cF0>
<a name="l15"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'0'</span><span class=cF0>&lt;=*num&lt;=</span><span class=cF6>'9'</span><span class=cF0>)
<a name="l16"></a> *dst++=*num;
<a name="l17"></a> num++;
<a name="l18"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l19"></a> *dst=0;
<a name="l20"></a>
<a name="l21"></a> </span><span class=cF1>while</span><span class=cF0> (*dict++) </span><span class=cF7>{</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>dict</span><span class=cF7>)</span><span class=cF0>&gt;2) {
<a name="l23"></a> dst=st=</span><span class=cF5>StrNew</span><span class=cF0>(dict);
<a name="l24"></a> </span><span class=cF1>while</span><span class=cF0> (ch=</span><span class=cF5>ToUpper</span><span class=cF7>(</span><span class=cF0>*dst</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'A'</span><span class=cF0>&lt;=ch&lt;=</span><span class=cF6>'Z'</span><span class=cF0>)
<a name="l26"></a> *dst=char_map[ch-</span><span class=cF6>'A'</span><span class=cF0>];
<a name="l27"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l28"></a> *dst=</span><span class=cF3>CH_SPACE</span><span class=cF0>;
<a name="l29"></a> dst++;
<a name="l30"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l31"></a> *dst=0;
<a name="l32"></a>
<a name="l33"></a> src=_num;
<a name="l34"></a> </span><span class=cF1>while</span><span class=cF0> (*src) </span><span class=cF7>{</span><span class=cF0>
<a name="l35"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrNCmp</span><span class=cF7>(</span><span class=cF0>st,src,</span><span class=cF5>StrLen</span><span class=cF0>(st)</span><span class=cF7>)</span><span class=cF0>) {
<a name="l36"></a> ch=*src;
<a name="l37"></a> *src=0;
<a name="l38"></a> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>,_num;
<a name="l39"></a> *src=ch;
<a name="l40"></a> </span><span class=cF6>&quot;$GREEN$%s$FG$&quot;</span><span class=cF0>,dict;
<a name="l41"></a> </span><span class=cF6>&quot;%s\n&quot;</span><span class=cF0>,src+</span><span class=cF5>StrLen</span><span class=cF0>(st);
<a name="l42"></a> }
<a name="l43"></a> src++;
<a name="l44"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l45"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l46"></a> }
<a name="l47"></a> dict+=</span><span class=cF5>StrLen</span><span class=cF0>(dict)+3;
<a name="l48"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l49"></a> </span><span class=cF5>Free</span><span class=cF0>(_num);
<a name="l50"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l51"></a>}
<a name="l52"></a>
<a name="l53"></a></span><span class=cF1>U0</span><span class=cF0> PNWDemo()
<a name="l54"></a>{
<a name="l55"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l56"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>st=</span><span class=cF5>GetStr</span><span class=cF0>(</span><span class=cF6>&quot;Phone Num:&quot;</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> &amp;&amp; *st) </span><span class=cF7>{</span><span class=cF0>
<a name="l57"></a> PhoneNumWords(st);
<a name="l58"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l60"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l61"></a>}
<a name="l62"></a>
<a name="l63"></a>PNWDemo;
</span></pre></body>
</html>