newcommand with parameter blank or zeroVariable-name newcommand with parameters within another newcommandnewcommand to make a plot command using gnuplottexUsing #1 literally in a macroHow I can customize fbox and hrule?Problem with underscores in newcommandHow reuse latex code for later expansion?Newcommand with PythonTextikzpicture as newcommand with argument(s)Loop code for repeated sumsDraw a shape with operation on parameters in Tikz

Is it possible for underground bunkers on different continents to be connected?

Print the phrase "And she said, 'But that's his.'" using only the alphabet

The last tree in the Universe

Nth term of Van Eck Sequence

At zero velocity, is this object neither speeding up nor slowing down?

What made the Ancient One do this in Endgame?

Does WiFi affect the quality of images downloaded from the internet?

VHDL: What is correct way to model open collector output for FPGA?

Arcane Tradition and Cost Efficiency: Learn spells on level-up, or learn them from scrolls/spellbooks?

Should I worry about having my credit pulled multiple times while car shopping?

For Saintsbury, which English novelists constituted the "great quartet of the mid-eighteenth century"?

How many times to repeat an event with known probability before it has occurred a number of times

Does anyone recognize these rockets, and their location?

How can Caller ID be faked?

Does PC weight have a mechanical effect?

Boss making me feel guilty for leaving the company at the end of my internship

When is the phrase "j'ai bon" used?

Why not make one big CPU core?

newcommand with parameter blank or zero

What does the output current rating from an H-Bridge's datasheet really mean?

At what temperature should the earth be cooked to prevent human infection?

How did Avada Kedavra get its name?

Manager wants to hire me; HR does not. How to proceed?

How to address players struggling with simple controls?



newcommand with parameter blank or zero


Variable-name newcommand with parameters within another newcommandnewcommand to make a plot command using gnuplottexUsing #1 literally in a macroHow I can customize fbox and hrule?Problem with underscores in newcommandHow reuse latex code for later expansion?Newcommand with PythonTextikzpicture as newcommand with argument(s)Loop code for repeated sumsDraw a shape with operation on parameters in Tikz






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















i read code in other topic: definited newcommand selectTask.



IF TaskOne/TaskTwo = blank is ok.



Now i want to edit IF TaskOne/TaskTwo = blank or zero.



Please help update this code:



newcommandselectTask[2]%
ifrelax#1relax
ifrelax#2relax
selectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
else
selectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
fi
else
ifrelax#2relax
selectTaskC % 10 TaskOne !=blank, TaskTwo=blank
else
selectTaskD % 11 TaskOne = TaskTwo!=blank
fi
fi



Please help if data = zero or blank.
Thank in advance










share|improve this question



















  • 2





    ifrelax#1relax is not a good test

    – David Carlisle
    9 hours ago











  • your question would be easier to answer if your code was a complete document that could be run with testcases rather than a fragment with undefined commands in each branch

    – David Carlisle
    8 hours ago











  • Adding to @DavidCarlisle's first comment: A better test would be ifrelaxdetokenize#1relax.

    – Skillmon
    8 hours ago












  • There is also ifempty#1relax, but for best results use something like def@tempa#1 to do comparisons.

    – John Kormylo
    8 hours ago












  • If the arguments will always be numeric (or blank), newcommandselectTask[2]ifnum9=#19relax ifnum9=#29relax selectTaskA else selectTaskB fi else ifnum9=#29relax selectTaskC else selectTaskD fi fi

    – Steven B. Segletes
    8 hours ago


















3















i read code in other topic: definited newcommand selectTask.



IF TaskOne/TaskTwo = blank is ok.



Now i want to edit IF TaskOne/TaskTwo = blank or zero.



Please help update this code:



newcommandselectTask[2]%
ifrelax#1relax
ifrelax#2relax
selectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
else
selectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
fi
else
ifrelax#2relax
selectTaskC % 10 TaskOne !=blank, TaskTwo=blank
else
selectTaskD % 11 TaskOne = TaskTwo!=blank
fi
fi



Please help if data = zero or blank.
Thank in advance










share|improve this question



















  • 2





    ifrelax#1relax is not a good test

    – David Carlisle
    9 hours ago











  • your question would be easier to answer if your code was a complete document that could be run with testcases rather than a fragment with undefined commands in each branch

    – David Carlisle
    8 hours ago











  • Adding to @DavidCarlisle's first comment: A better test would be ifrelaxdetokenize#1relax.

    – Skillmon
    8 hours ago












  • There is also ifempty#1relax, but for best results use something like def@tempa#1 to do comparisons.

    – John Kormylo
    8 hours ago












  • If the arguments will always be numeric (or blank), newcommandselectTask[2]ifnum9=#19relax ifnum9=#29relax selectTaskA else selectTaskB fi else ifnum9=#29relax selectTaskC else selectTaskD fi fi

    – Steven B. Segletes
    8 hours ago














3












3








3








i read code in other topic: definited newcommand selectTask.



IF TaskOne/TaskTwo = blank is ok.



Now i want to edit IF TaskOne/TaskTwo = blank or zero.



Please help update this code:



newcommandselectTask[2]%
ifrelax#1relax
ifrelax#2relax
selectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
else
selectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
fi
else
ifrelax#2relax
selectTaskC % 10 TaskOne !=blank, TaskTwo=blank
else
selectTaskD % 11 TaskOne = TaskTwo!=blank
fi
fi



Please help if data = zero or blank.
Thank in advance










share|improve this question
















i read code in other topic: definited newcommand selectTask.



IF TaskOne/TaskTwo = blank is ok.



Now i want to edit IF TaskOne/TaskTwo = blank or zero.



Please help update this code:



newcommandselectTask[2]%
ifrelax#1relax
ifrelax#2relax
selectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
else
selectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
fi
else
ifrelax#2relax
selectTaskC % 10 TaskOne !=blank, TaskTwo=blank
else
selectTaskD % 11 TaskOne = TaskTwo!=blank
fi
fi



Please help if data = zero or blank.
Thank in advance







macros






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago







latexforti

















asked 9 hours ago









latexfortilatexforti

65018




65018







  • 2





    ifrelax#1relax is not a good test

    – David Carlisle
    9 hours ago











  • your question would be easier to answer if your code was a complete document that could be run with testcases rather than a fragment with undefined commands in each branch

    – David Carlisle
    8 hours ago











  • Adding to @DavidCarlisle's first comment: A better test would be ifrelaxdetokenize#1relax.

    – Skillmon
    8 hours ago












  • There is also ifempty#1relax, but for best results use something like def@tempa#1 to do comparisons.

    – John Kormylo
    8 hours ago












  • If the arguments will always be numeric (or blank), newcommandselectTask[2]ifnum9=#19relax ifnum9=#29relax selectTaskA else selectTaskB fi else ifnum9=#29relax selectTaskC else selectTaskD fi fi

    – Steven B. Segletes
    8 hours ago













  • 2





    ifrelax#1relax is not a good test

    – David Carlisle
    9 hours ago











  • your question would be easier to answer if your code was a complete document that could be run with testcases rather than a fragment with undefined commands in each branch

    – David Carlisle
    8 hours ago











  • Adding to @DavidCarlisle's first comment: A better test would be ifrelaxdetokenize#1relax.

    – Skillmon
    8 hours ago












  • There is also ifempty#1relax, but for best results use something like def@tempa#1 to do comparisons.

    – John Kormylo
    8 hours ago












  • If the arguments will always be numeric (or blank), newcommandselectTask[2]ifnum9=#19relax ifnum9=#29relax selectTaskA else selectTaskB fi else ifnum9=#29relax selectTaskC else selectTaskD fi fi

    – Steven B. Segletes
    8 hours ago








2




2





ifrelax#1relax is not a good test

– David Carlisle
9 hours ago





ifrelax#1relax is not a good test

– David Carlisle
9 hours ago













your question would be easier to answer if your code was a complete document that could be run with testcases rather than a fragment with undefined commands in each branch

– David Carlisle
8 hours ago





your question would be easier to answer if your code was a complete document that could be run with testcases rather than a fragment with undefined commands in each branch

– David Carlisle
8 hours ago













Adding to @DavidCarlisle's first comment: A better test would be ifrelaxdetokenize#1relax.

– Skillmon
8 hours ago






Adding to @DavidCarlisle's first comment: A better test would be ifrelaxdetokenize#1relax.

– Skillmon
8 hours ago














There is also ifempty#1relax, but for best results use something like def@tempa#1 to do comparisons.

– John Kormylo
8 hours ago






There is also ifempty#1relax, but for best results use something like def@tempa#1 to do comparisons.

– John Kormylo
8 hours ago














If the arguments will always be numeric (or blank), newcommandselectTask[2]ifnum9=#19relax ifnum9=#29relax selectTaskA else selectTaskB fi else ifnum9=#29relax selectTaskC else selectTaskD fi fi

– Steven B. Segletes
8 hours ago






If the arguments will always be numeric (or blank), newcommandselectTask[2]ifnum9=#19relax ifnum9=#29relax selectTaskA else selectTaskB fi else ifnum9=#29relax selectTaskC else selectTaskD fi fi

– Steven B. Segletes
8 hours ago











3 Answers
3






active

oldest

votes


















3














ifrelax#1relax would be true if the expansion of #1 results in something that starts with any non-character. ifrelaxhboxabcrelax for example would test as true (and typeset abc).



this uses ifx tests which do not expand the tested tokens.



deftmpempty
deftmpzero0

newcommandselectTask[2]%
deftmp#1ifxtmptmpemptylettmptmpzerofi

deftmpb#2ifxtmpbtmpemptylettmpbtmpzerofi
ifxtmptmpzero
ifxtmpbtmpzero
showselectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
else
showselectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
fi
else
ifxtmpbtmpzero
showselectTaskC % 10 TaskOne !=blank, TaskTwo=blank
else
showselectTaskD % 11 TaskOne = TaskTwo!=blank
fi
fi




selectTask%A
selectTask0%A
selectTaskx%B
selectTask0x%B
selectTaskx%C
selectTaskx0%C
selectTaskxy%D





stop





share|improve this answer






























    3














    Here's an implementation according to your idea: the first argument is tested if blank, if it is the following macro is called with 0 argument; similarly the second argument is tested. Then we do a string case choice.



    documentclassarticle
    usepackagexparse

    ExplSyntaxOn

    NewExpandableDocumentCommandselectTaskmm

    latexforti_select_task:nn #1 #2


    cs_new:Nn latexforti_select_task:nn

    tl_if_blank:nTF #1

    __latexforti_select_task_a:nn 0 #2


    __latexforti_select_task_a:nn #1 #2


    cs_new:Nn __latexforti_select_task_a:nn

    tl_if_blank:nTF #2

    __latexforti_select_task_b:nn #1 0


    __latexforti_select_task_b:nn #1 #2


    cs_new:Nn __latexforti_select_task_b:nn

    str_case:nn #1#2

    00selectTaskA
    01selectTaskB
    10selectTaskC
    11selectTaskD



    ExplSyntaxOff

    newcommandselectTaskAI'm task A
    newcommandselectTaskBI'm task B
    newcommandselectTaskCI'm task C
    newcommandselectTaskDI'm task D

    begindocument

    selectTask00 --- selectTask0 -- selectTask0

    selectTask01 --- selectTask1

    selectTask10 --- selectTask1

    selectTask11

    enddocument


    enter image description here



    An implementation with more classical methods (but arguments cannot be as in the previous one).



    documentclassarticle

    makeatletter

    newcommandselectTask[2]%
    expandafterlatexforti@selectexpandafter
    number0#1expandafterexpandafternumber0#2%

    newcommandlatexforti@select[2]%
    ifcasenumexpr#1*2+#2relax % the arguments are binary digits!
    selectTaskA
    or
    selectTaskB
    or
    selectTaskC
    or
    selectTaskD
    fi

    makeatother

    newcommandselectTaskAI'm task A
    newcommandselectTaskBI'm task B
    newcommandselectTaskCI'm task C
    newcommandselectTaskDI'm task D

    begindocument

    selectTask00 --- selectTask0 -- selectTask0

    selectTask01 --- selectTask1

    selectTask10 --- selectTask1

    selectTask11

    enddocument





    share|improve this answer
































      2














      If the arguments are only allowed to be blank or numeric, you can use an ifnum comparison.



      documentclass[]scrartcl
      defselectTaskA00
      defselectTaskB01
      defselectTaskC10
      defselectTaskD11

      newcommandselectTask[2]%
      ifnum9=#19relax
      ifnum9=#29relax
      selectTaskA
      else
      selectTaskB
      fi
      else
      ifnum9=#29relax
      selectTaskC
      else
      selectTaskD
      fi
      fi

      begindocument
      selectTask\
      selectTask0\
      selectTask0\
      selectTask00\
      selectTask1\
      selectTask1\
      selectTask11
      enddocument





      share|improve this answer























        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "85"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f495685%2fnewcommand-with-parameter-blank-or-zero%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        3














        ifrelax#1relax would be true if the expansion of #1 results in something that starts with any non-character. ifrelaxhboxabcrelax for example would test as true (and typeset abc).



        this uses ifx tests which do not expand the tested tokens.



        deftmpempty
        deftmpzero0

        newcommandselectTask[2]%
        deftmp#1ifxtmptmpemptylettmptmpzerofi

        deftmpb#2ifxtmpbtmpemptylettmpbtmpzerofi
        ifxtmptmpzero
        ifxtmpbtmpzero
        showselectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
        else
        showselectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
        fi
        else
        ifxtmpbtmpzero
        showselectTaskC % 10 TaskOne !=blank, TaskTwo=blank
        else
        showselectTaskD % 11 TaskOne = TaskTwo!=blank
        fi
        fi




        selectTask%A
        selectTask0%A
        selectTaskx%B
        selectTask0x%B
        selectTaskx%C
        selectTaskx0%C
        selectTaskxy%D





        stop





        share|improve this answer



























          3














          ifrelax#1relax would be true if the expansion of #1 results in something that starts with any non-character. ifrelaxhboxabcrelax for example would test as true (and typeset abc).



          this uses ifx tests which do not expand the tested tokens.



          deftmpempty
          deftmpzero0

          newcommandselectTask[2]%
          deftmp#1ifxtmptmpemptylettmptmpzerofi

          deftmpb#2ifxtmpbtmpemptylettmpbtmpzerofi
          ifxtmptmpzero
          ifxtmpbtmpzero
          showselectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
          else
          showselectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
          fi
          else
          ifxtmpbtmpzero
          showselectTaskC % 10 TaskOne !=blank, TaskTwo=blank
          else
          showselectTaskD % 11 TaskOne = TaskTwo!=blank
          fi
          fi




          selectTask%A
          selectTask0%A
          selectTaskx%B
          selectTask0x%B
          selectTaskx%C
          selectTaskx0%C
          selectTaskxy%D





          stop





          share|improve this answer

























            3












            3








            3







            ifrelax#1relax would be true if the expansion of #1 results in something that starts with any non-character. ifrelaxhboxabcrelax for example would test as true (and typeset abc).



            this uses ifx tests which do not expand the tested tokens.



            deftmpempty
            deftmpzero0

            newcommandselectTask[2]%
            deftmp#1ifxtmptmpemptylettmptmpzerofi

            deftmpb#2ifxtmpbtmpemptylettmpbtmpzerofi
            ifxtmptmpzero
            ifxtmpbtmpzero
            showselectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
            else
            showselectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
            fi
            else
            ifxtmpbtmpzero
            showselectTaskC % 10 TaskOne !=blank, TaskTwo=blank
            else
            showselectTaskD % 11 TaskOne = TaskTwo!=blank
            fi
            fi




            selectTask%A
            selectTask0%A
            selectTaskx%B
            selectTask0x%B
            selectTaskx%C
            selectTaskx0%C
            selectTaskxy%D





            stop





            share|improve this answer













            ifrelax#1relax would be true if the expansion of #1 results in something that starts with any non-character. ifrelaxhboxabcrelax for example would test as true (and typeset abc).



            this uses ifx tests which do not expand the tested tokens.



            deftmpempty
            deftmpzero0

            newcommandselectTask[2]%
            deftmp#1ifxtmptmpemptylettmptmpzerofi

            deftmpb#2ifxtmpbtmpemptylettmpbtmpzerofi
            ifxtmptmpzero
            ifxtmpbtmpzero
            showselectTaskA % 00 TaskOne = TaskTwo=blank => How if blank or zero?
            else
            showselectTaskB % 01 TaskOne =blank,TaskTwo=!=blank
            fi
            else
            ifxtmpbtmpzero
            showselectTaskC % 10 TaskOne !=blank, TaskTwo=blank
            else
            showselectTaskD % 11 TaskOne = TaskTwo!=blank
            fi
            fi




            selectTask%A
            selectTask0%A
            selectTaskx%B
            selectTask0x%B
            selectTaskx%C
            selectTaskx0%C
            selectTaskxy%D





            stop






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 8 hours ago









            David CarlisleDavid Carlisle

            510k4311591916




            510k4311591916























                3














                Here's an implementation according to your idea: the first argument is tested if blank, if it is the following macro is called with 0 argument; similarly the second argument is tested. Then we do a string case choice.



                documentclassarticle
                usepackagexparse

                ExplSyntaxOn

                NewExpandableDocumentCommandselectTaskmm

                latexforti_select_task:nn #1 #2


                cs_new:Nn latexforti_select_task:nn

                tl_if_blank:nTF #1

                __latexforti_select_task_a:nn 0 #2


                __latexforti_select_task_a:nn #1 #2


                cs_new:Nn __latexforti_select_task_a:nn

                tl_if_blank:nTF #2

                __latexforti_select_task_b:nn #1 0


                __latexforti_select_task_b:nn #1 #2


                cs_new:Nn __latexforti_select_task_b:nn

                str_case:nn #1#2

                00selectTaskA
                01selectTaskB
                10selectTaskC
                11selectTaskD



                ExplSyntaxOff

                newcommandselectTaskAI'm task A
                newcommandselectTaskBI'm task B
                newcommandselectTaskCI'm task C
                newcommandselectTaskDI'm task D

                begindocument

                selectTask00 --- selectTask0 -- selectTask0

                selectTask01 --- selectTask1

                selectTask10 --- selectTask1

                selectTask11

                enddocument


                enter image description here



                An implementation with more classical methods (but arguments cannot be as in the previous one).



                documentclassarticle

                makeatletter

                newcommandselectTask[2]%
                expandafterlatexforti@selectexpandafter
                number0#1expandafterexpandafternumber0#2%

                newcommandlatexforti@select[2]%
                ifcasenumexpr#1*2+#2relax % the arguments are binary digits!
                selectTaskA
                or
                selectTaskB
                or
                selectTaskC
                or
                selectTaskD
                fi

                makeatother

                newcommandselectTaskAI'm task A
                newcommandselectTaskBI'm task B
                newcommandselectTaskCI'm task C
                newcommandselectTaskDI'm task D

                begindocument

                selectTask00 --- selectTask0 -- selectTask0

                selectTask01 --- selectTask1

                selectTask10 --- selectTask1

                selectTask11

                enddocument





                share|improve this answer





























                  3














                  Here's an implementation according to your idea: the first argument is tested if blank, if it is the following macro is called with 0 argument; similarly the second argument is tested. Then we do a string case choice.



                  documentclassarticle
                  usepackagexparse

                  ExplSyntaxOn

                  NewExpandableDocumentCommandselectTaskmm

                  latexforti_select_task:nn #1 #2


                  cs_new:Nn latexforti_select_task:nn

                  tl_if_blank:nTF #1

                  __latexforti_select_task_a:nn 0 #2


                  __latexforti_select_task_a:nn #1 #2


                  cs_new:Nn __latexforti_select_task_a:nn

                  tl_if_blank:nTF #2

                  __latexforti_select_task_b:nn #1 0


                  __latexforti_select_task_b:nn #1 #2


                  cs_new:Nn __latexforti_select_task_b:nn

                  str_case:nn #1#2

                  00selectTaskA
                  01selectTaskB
                  10selectTaskC
                  11selectTaskD



                  ExplSyntaxOff

                  newcommandselectTaskAI'm task A
                  newcommandselectTaskBI'm task B
                  newcommandselectTaskCI'm task C
                  newcommandselectTaskDI'm task D

                  begindocument

                  selectTask00 --- selectTask0 -- selectTask0

                  selectTask01 --- selectTask1

                  selectTask10 --- selectTask1

                  selectTask11

                  enddocument


                  enter image description here



                  An implementation with more classical methods (but arguments cannot be as in the previous one).



                  documentclassarticle

                  makeatletter

                  newcommandselectTask[2]%
                  expandafterlatexforti@selectexpandafter
                  number0#1expandafterexpandafternumber0#2%

                  newcommandlatexforti@select[2]%
                  ifcasenumexpr#1*2+#2relax % the arguments are binary digits!
                  selectTaskA
                  or
                  selectTaskB
                  or
                  selectTaskC
                  or
                  selectTaskD
                  fi

                  makeatother

                  newcommandselectTaskAI'm task A
                  newcommandselectTaskBI'm task B
                  newcommandselectTaskCI'm task C
                  newcommandselectTaskDI'm task D

                  begindocument

                  selectTask00 --- selectTask0 -- selectTask0

                  selectTask01 --- selectTask1

                  selectTask10 --- selectTask1

                  selectTask11

                  enddocument





                  share|improve this answer



























                    3












                    3








                    3







                    Here's an implementation according to your idea: the first argument is tested if blank, if it is the following macro is called with 0 argument; similarly the second argument is tested. Then we do a string case choice.



                    documentclassarticle
                    usepackagexparse

                    ExplSyntaxOn

                    NewExpandableDocumentCommandselectTaskmm

                    latexforti_select_task:nn #1 #2


                    cs_new:Nn latexforti_select_task:nn

                    tl_if_blank:nTF #1

                    __latexforti_select_task_a:nn 0 #2


                    __latexforti_select_task_a:nn #1 #2


                    cs_new:Nn __latexforti_select_task_a:nn

                    tl_if_blank:nTF #2

                    __latexforti_select_task_b:nn #1 0


                    __latexforti_select_task_b:nn #1 #2


                    cs_new:Nn __latexforti_select_task_b:nn

                    str_case:nn #1#2

                    00selectTaskA
                    01selectTaskB
                    10selectTaskC
                    11selectTaskD



                    ExplSyntaxOff

                    newcommandselectTaskAI'm task A
                    newcommandselectTaskBI'm task B
                    newcommandselectTaskCI'm task C
                    newcommandselectTaskDI'm task D

                    begindocument

                    selectTask00 --- selectTask0 -- selectTask0

                    selectTask01 --- selectTask1

                    selectTask10 --- selectTask1

                    selectTask11

                    enddocument


                    enter image description here



                    An implementation with more classical methods (but arguments cannot be as in the previous one).



                    documentclassarticle

                    makeatletter

                    newcommandselectTask[2]%
                    expandafterlatexforti@selectexpandafter
                    number0#1expandafterexpandafternumber0#2%

                    newcommandlatexforti@select[2]%
                    ifcasenumexpr#1*2+#2relax % the arguments are binary digits!
                    selectTaskA
                    or
                    selectTaskB
                    or
                    selectTaskC
                    or
                    selectTaskD
                    fi

                    makeatother

                    newcommandselectTaskAI'm task A
                    newcommandselectTaskBI'm task B
                    newcommandselectTaskCI'm task C
                    newcommandselectTaskDI'm task D

                    begindocument

                    selectTask00 --- selectTask0 -- selectTask0

                    selectTask01 --- selectTask1

                    selectTask10 --- selectTask1

                    selectTask11

                    enddocument





                    share|improve this answer















                    Here's an implementation according to your idea: the first argument is tested if blank, if it is the following macro is called with 0 argument; similarly the second argument is tested. Then we do a string case choice.



                    documentclassarticle
                    usepackagexparse

                    ExplSyntaxOn

                    NewExpandableDocumentCommandselectTaskmm

                    latexforti_select_task:nn #1 #2


                    cs_new:Nn latexforti_select_task:nn

                    tl_if_blank:nTF #1

                    __latexforti_select_task_a:nn 0 #2


                    __latexforti_select_task_a:nn #1 #2


                    cs_new:Nn __latexforti_select_task_a:nn

                    tl_if_blank:nTF #2

                    __latexforti_select_task_b:nn #1 0


                    __latexforti_select_task_b:nn #1 #2


                    cs_new:Nn __latexforti_select_task_b:nn

                    str_case:nn #1#2

                    00selectTaskA
                    01selectTaskB
                    10selectTaskC
                    11selectTaskD



                    ExplSyntaxOff

                    newcommandselectTaskAI'm task A
                    newcommandselectTaskBI'm task B
                    newcommandselectTaskCI'm task C
                    newcommandselectTaskDI'm task D

                    begindocument

                    selectTask00 --- selectTask0 -- selectTask0

                    selectTask01 --- selectTask1

                    selectTask10 --- selectTask1

                    selectTask11

                    enddocument


                    enter image description here



                    An implementation with more classical methods (but arguments cannot be as in the previous one).



                    documentclassarticle

                    makeatletter

                    newcommandselectTask[2]%
                    expandafterlatexforti@selectexpandafter
                    number0#1expandafterexpandafternumber0#2%

                    newcommandlatexforti@select[2]%
                    ifcasenumexpr#1*2+#2relax % the arguments are binary digits!
                    selectTaskA
                    or
                    selectTaskB
                    or
                    selectTaskC
                    or
                    selectTaskD
                    fi

                    makeatother

                    newcommandselectTaskAI'm task A
                    newcommandselectTaskBI'm task B
                    newcommandselectTaskCI'm task C
                    newcommandselectTaskDI'm task D

                    begindocument

                    selectTask00 --- selectTask0 -- selectTask0

                    selectTask01 --- selectTask1

                    selectTask10 --- selectTask1

                    selectTask11

                    enddocument






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 8 hours ago

























                    answered 8 hours ago









                    egregegreg

                    748k8919573300




                    748k8919573300





















                        2














                        If the arguments are only allowed to be blank or numeric, you can use an ifnum comparison.



                        documentclass[]scrartcl
                        defselectTaskA00
                        defselectTaskB01
                        defselectTaskC10
                        defselectTaskD11

                        newcommandselectTask[2]%
                        ifnum9=#19relax
                        ifnum9=#29relax
                        selectTaskA
                        else
                        selectTaskB
                        fi
                        else
                        ifnum9=#29relax
                        selectTaskC
                        else
                        selectTaskD
                        fi
                        fi

                        begindocument
                        selectTask\
                        selectTask0\
                        selectTask0\
                        selectTask00\
                        selectTask1\
                        selectTask1\
                        selectTask11
                        enddocument





                        share|improve this answer



























                          2














                          If the arguments are only allowed to be blank or numeric, you can use an ifnum comparison.



                          documentclass[]scrartcl
                          defselectTaskA00
                          defselectTaskB01
                          defselectTaskC10
                          defselectTaskD11

                          newcommandselectTask[2]%
                          ifnum9=#19relax
                          ifnum9=#29relax
                          selectTaskA
                          else
                          selectTaskB
                          fi
                          else
                          ifnum9=#29relax
                          selectTaskC
                          else
                          selectTaskD
                          fi
                          fi

                          begindocument
                          selectTask\
                          selectTask0\
                          selectTask0\
                          selectTask00\
                          selectTask1\
                          selectTask1\
                          selectTask11
                          enddocument





                          share|improve this answer

























                            2












                            2








                            2







                            If the arguments are only allowed to be blank or numeric, you can use an ifnum comparison.



                            documentclass[]scrartcl
                            defselectTaskA00
                            defselectTaskB01
                            defselectTaskC10
                            defselectTaskD11

                            newcommandselectTask[2]%
                            ifnum9=#19relax
                            ifnum9=#29relax
                            selectTaskA
                            else
                            selectTaskB
                            fi
                            else
                            ifnum9=#29relax
                            selectTaskC
                            else
                            selectTaskD
                            fi
                            fi

                            begindocument
                            selectTask\
                            selectTask0\
                            selectTask0\
                            selectTask00\
                            selectTask1\
                            selectTask1\
                            selectTask11
                            enddocument





                            share|improve this answer













                            If the arguments are only allowed to be blank or numeric, you can use an ifnum comparison.



                            documentclass[]scrartcl
                            defselectTaskA00
                            defselectTaskB01
                            defselectTaskC10
                            defselectTaskD11

                            newcommandselectTask[2]%
                            ifnum9=#19relax
                            ifnum9=#29relax
                            selectTaskA
                            else
                            selectTaskB
                            fi
                            else
                            ifnum9=#29relax
                            selectTaskC
                            else
                            selectTaskD
                            fi
                            fi

                            begindocument
                            selectTask\
                            selectTask0\
                            selectTask0\
                            selectTask00\
                            selectTask1\
                            selectTask1\
                            selectTask11
                            enddocument






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 8 hours ago









                            Steven B. SegletesSteven B. Segletes

                            166k9210427




                            166k9210427



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f495685%2fnewcommand-with-parameter-blank-or-zero%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її