<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Classic/Legacy CodeWarriorのトピックBasic C question</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134426#M730</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;My application revolves around 10 different scenarios, say Sen1 to Sen 10. If i determine which scenario i have what is the best way to call their corresponding fucntion say Function1 - Function 10. Each of these functions has a large amount of code associated with it and the scenario is constanlty changing.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Is there&amp;nbsp;a dictionary for C statements&amp;nbsp;around?&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by ernestsnaith on &lt;SPAN class="date_text"&gt;05-03-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;02:53 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 May 2006 14:34:38 GMT</pubDate>
    <dc:creator>ernestsnaith</dc:creator>
    <dc:date>2006-05-03T14:34:38Z</dc:date>
    <item>
      <title>Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134426#M730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;My application revolves around 10 different scenarios, say Sen1 to Sen 10. If i determine which scenario i have what is the best way to call their corresponding fucntion say Function1 - Function 10. Each of these functions has a large amount of code associated with it and the scenario is constanlty changing.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Is there&amp;nbsp;a dictionary for C statements&amp;nbsp;around?&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by ernestsnaith on &lt;SPAN class="date_text"&gt;05-03-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;02:53 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2006 14:34:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134426#M730</guid>
      <dc:creator>ernestsnaith</dc:creator>
      <dc:date>2006-05-03T14:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134427#M731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How about "switch".&lt;/P&gt;&lt;P&gt;Regards Peg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2006 15:18:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134427#M731</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-05-03T15:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134428#M732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Can you place a lot of code within a switch though? Ive only just started with C but i thought it just picked the closest value and returned it.&lt;/P&gt;&lt;P&gt;What i am after is&amp;nbsp;a goto with a parameter if this is possible or wise. Is the following possible at all&lt;/P&gt;&lt;P&gt;goto ("Function" + ScenNo)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by ernestsnaith on &lt;SPAN class="date_text"&gt;05-03-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;04:22 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2006 16:21:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134428#M732</guid>
      <dc:creator>ernestsnaith</dc:creator>
      <dc:date>2006-05-03T16:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134429#M733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;I think Peg did mean something like this:&lt;/P&gt;&lt;BLOCKQUOTE dir="ltr"&gt;&lt;P&gt;switch (scenario) {&lt;/P&gt;&lt;BLOCKQUOTE dir="ltr"&gt;&lt;P&gt;case 0: func0(); break;&lt;/P&gt;&lt;P&gt;case 1: func1(); break;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;An other way to do it would be using a array of pointers to functions:&lt;/P&gt;&lt;BLOCKQUOTE dir="ltr"&gt;&lt;P&gt;void (*apf[10])(void) = {func0, func1, func2...};&lt;/P&gt;&lt;P&gt;(*apf[scenario])();&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;In both cases you should write the code for the different scenarios in the functions func0..func10.&lt;/P&gt;&lt;BLOCKQUOTE dir="ltr"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;An excellent 'C dictionary' book would be 'C, A Reference Manual' by Samuel P. Harbison and Guy L. Steele Jr.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2006 16:39:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134429#M733</guid>
      <dc:creator>Sten</dc:creator>
      <dc:date>2006-05-03T16:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134430#M734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can put in as much code as you please, but if you want to keep it readable, normally just a couple of function calls.&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;switch (scenario){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case scenario1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func_scen_1();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case scenario2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func_scen _2();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;default:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;panic();&amp;nbsp;&amp;nbsp;&amp;nbsp; //there is more scenarios than I bargained on!&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;But also remember Rule No. 1&lt;/P&gt;&lt;P&gt;1. Avoid the use of goto!&lt;/P&gt;&lt;P&gt;only use it in phrases like "goto the fridge for a beer" and "goto the beach" etc.&lt;/P&gt;&lt;P&gt;Regards Peg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2006 16:42:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134430#M734</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-05-03T16:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134431#M735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I appologise for how basic these questions are but am i understanding 'Switch' correctly? I have a number 0-10 in Thno, should it branch to corresponding ToothX?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;switch (Thno) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 0: Error(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 1: Tooth1(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 2: Tooth2(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 3: Tooth3(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 4: Tooth4(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 5: Tooth5(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 6: Tooth6(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 7: Tooth7(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 8: Tooth8(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 9: Tooth9(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 10: Error(); break;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is what first put me off switch, I have lots of error such as&lt;/DIV&gt;&lt;DIV&gt;implicit parameter declaration for tooth1&lt;/DIV&gt;&lt;P&gt;Message Edited by ernestsnaith on &lt;SPAN class="date_text"&gt;05-03-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:57 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2006 00:44:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134431#M735</guid>
      <dc:creator>ernestsnaith</dc:creator>
      <dc:date>2006-05-04T00:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134432#M736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Earnest,&lt;/FONT&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE dir="ltr"&gt;&lt;DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;FONT size="1"&gt;ernestsnaith wrote:&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="1"&gt;I app ologise for how basic these questions are but am i understanding 'Switch' correctly? I have a number 0-10 in Thno, should it branch to corresponding ToothX?&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="1"&gt;&amp;nbsp;switch (Thno) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 0: Error(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 1: Tooth1(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 2: Tooth2(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 3: Tooth3(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 4: Tooth4(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 5: Tooth5(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 6: Tooth6(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 7: Tooth7(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 8: Tooth8(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 9: Tooth9(); break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 10: Error(); break;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1"&gt;This is what first put me off switch, I have lots of error such as&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1"&gt;implicit parameter declaration for tooth1&lt;/FONT&gt;&lt;/DIV&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Suggest you remove the case 0: and case 10: switch statements, and make the final switch statement -&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;default: Error();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;as Peg suggested.&amp;nbsp; This will pick up any value ot &lt;FONT face="Courier New"&gt;Thno&lt;/FONT&gt; other than 1 through&amp;nbsp;9.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Each function that is&amp;nbsp;called will need to have a prototype declared&amp;nbsp;prior to&amp;nbsp;its first use.&amp;nbsp; I suspect this may be the reason for your compile errors.&amp;nbsp; The prototypes&amp;nbsp;might take the form -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;void Tooth1(void);&lt;BR /&gt;void Tooth2(void);&lt;BR /&gt;&lt;/FONT&gt;etc.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Normally these would be&amp;nbsp;part of&amp;nbsp;a header file, and the header file included near the beginning of&amp;nbsp;the main file.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2006 12:41:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134432#M736</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-05-04T12:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Basic C question</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134433#M737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;You could also make an array of pointers to your functions, then use the error numbers as an index into the array.&lt;/P&gt;&lt;P&gt;However, this&amp;nbsp;different just for the sake of being different.&amp;nbsp; I would say that 9 out of 10 people would use a "switch."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would &lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Tomahawk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 02:03:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-C-question/m-p/134433#M737</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2006-06-09T02:03:09Z</dc:date>
    </item>
  </channel>
</rss>

