how do I test for a unique string with multiple possibilities?String test, with complicated argumentsString test, with an OR connectorTesting for commercial at (@) in a stringHow to do multiple string replacements?Numerical conditional within tikz keys?How to test if a string is emptyPackage to test whether a string is in a listAppend unique characters read from filecontents to a stringTest whether a string is in a list with variableVisualize multiple string segments

Are UK pensions taxed twice?

Can a rogue effectively triple their speed by combining Dash and Ready?

What is a subpixel in Super Mario Bros, and how does it relate to wall clipping?

Socratic Paradox

Is there an evolutionary advantage to having two heads?

Draw a checker pattern with a black X in the center

Mapping a function f[xi_,xj_] over a list x1, ...., xn with the i < j restriction

The deliberate use of misleading terminology

What does "Marchentalender" on the front of a postcard mean?

Improve OR inside INNER JOIN

How can I prevent interns from being expendable?

Why do Russians call their women expensive ("дорогая")?

Fastest way to perform complex search on pandas dataframe

Why teaching kids Torah is the only forbidden profession for singles Yihud-wise?

Why does the 6502 have the BIT instruction?

Looking after a wayward brother in mother's will

What is game ban VS VAC ban in steam?

What does it mean when you think without speaking?

How to capture more stars?

What caused the tendency for conservatives to not support climate change regulations?

Why is A union B also called "A or B"?

Can an old DSLR be upgraded to match modern smartphone image quality

What are the benefits of cryosleep?

Comment dit-on « I’ll tell you what » ?



how do I test for a unique string with multiple possibilities?


String test, with complicated argumentsString test, with an OR connectorTesting for commercial at (@) in a stringHow to do multiple string replacements?Numerical conditional within tikz keys?How to test if a string is emptyPackage to test whether a string is in a listAppend unique characters read from filecontents to a stringTest whether a string is in a list with variableVisualize multiple string segments













2















I'm writing a macro that takes a string and it returns an href based on that string. The string could have 150 different values. My question is how to write this in an efficient way. Using pdflatex.



Here's what I've got right now, shortened to two conditions for explanation:



documentclassarticle
usepackagehyperref
newcommandmyref[1]%
ifnumpdfstrcmp#1aaa=0%
hrefexample.com/aaamy aaa link
fi
ifnumpdfstrcmp#1bbb=0%
hrefexample.com/bbbmy bbb link
fi

begindocument
Here is myrefaaa.
enddocument


But of course once I get a success (#1=aaa, say), I'm still testing the other 149 conditions for no reason. How to code this efficiently?










share|improve this question






















  • Are all of the outcomes of the form hrefexample.com/<string>my <string> link?

    – Joseph Wright
    9 hours ago











  • Ah, I simplified too much. It will actually take two args. first arg goes in the link address, the second provides the link text. Like hrefexample.com/aaaThe Title of the AAA Document (link text will have completely different text on each invocation of the macro.

    – Tim A
    9 hours ago















2















I'm writing a macro that takes a string and it returns an href based on that string. The string could have 150 different values. My question is how to write this in an efficient way. Using pdflatex.



Here's what I've got right now, shortened to two conditions for explanation:



documentclassarticle
usepackagehyperref
newcommandmyref[1]%
ifnumpdfstrcmp#1aaa=0%
hrefexample.com/aaamy aaa link
fi
ifnumpdfstrcmp#1bbb=0%
hrefexample.com/bbbmy bbb link
fi

begindocument
Here is myrefaaa.
enddocument


But of course once I get a success (#1=aaa, say), I'm still testing the other 149 conditions for no reason. How to code this efficiently?










share|improve this question






















  • Are all of the outcomes of the form hrefexample.com/<string>my <string> link?

    – Joseph Wright
    9 hours ago











  • Ah, I simplified too much. It will actually take two args. first arg goes in the link address, the second provides the link text. Like hrefexample.com/aaaThe Title of the AAA Document (link text will have completely different text on each invocation of the macro.

    – Tim A
    9 hours ago













2












2








2


1






I'm writing a macro that takes a string and it returns an href based on that string. The string could have 150 different values. My question is how to write this in an efficient way. Using pdflatex.



Here's what I've got right now, shortened to two conditions for explanation:



documentclassarticle
usepackagehyperref
newcommandmyref[1]%
ifnumpdfstrcmp#1aaa=0%
hrefexample.com/aaamy aaa link
fi
ifnumpdfstrcmp#1bbb=0%
hrefexample.com/bbbmy bbb link
fi

begindocument
Here is myrefaaa.
enddocument


But of course once I get a success (#1=aaa, say), I'm still testing the other 149 conditions for no reason. How to code this efficiently?










share|improve this question














I'm writing a macro that takes a string and it returns an href based on that string. The string could have 150 different values. My question is how to write this in an efficient way. Using pdflatex.



Here's what I've got right now, shortened to two conditions for explanation:



documentclassarticle
usepackagehyperref
newcommandmyref[1]%
ifnumpdfstrcmp#1aaa=0%
hrefexample.com/aaamy aaa link
fi
ifnumpdfstrcmp#1bbb=0%
hrefexample.com/bbbmy bbb link
fi

begindocument
Here is myrefaaa.
enddocument


But of course once I get a success (#1=aaa, say), I'm still testing the other 149 conditions for no reason. How to code this efficiently?







conditionals strings pdfstrcmp






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 9 hours ago









Tim ATim A

1,172514




1,172514












  • Are all of the outcomes of the form hrefexample.com/<string>my <string> link?

    – Joseph Wright
    9 hours ago











  • Ah, I simplified too much. It will actually take two args. first arg goes in the link address, the second provides the link text. Like hrefexample.com/aaaThe Title of the AAA Document (link text will have completely different text on each invocation of the macro.

    – Tim A
    9 hours ago

















  • Are all of the outcomes of the form hrefexample.com/<string>my <string> link?

    – Joseph Wright
    9 hours ago











  • Ah, I simplified too much. It will actually take two args. first arg goes in the link address, the second provides the link text. Like hrefexample.com/aaaThe Title of the AAA Document (link text will have completely different text on each invocation of the macro.

    – Tim A
    9 hours ago
















Are all of the outcomes of the form hrefexample.com/<string>my <string> link?

– Joseph Wright
9 hours ago





Are all of the outcomes of the form hrefexample.com/<string>my <string> link?

– Joseph Wright
9 hours ago













Ah, I simplified too much. It will actually take two args. first arg goes in the link address, the second provides the link text. Like hrefexample.com/aaaThe Title of the AAA Document (link text will have completely different text on each invocation of the macro.

– Tim A
9 hours ago





Ah, I simplified too much. It will actually take two args. first arg goes in the link address, the second provides the link text. Like hrefexample.com/aaaThe Title of the AAA Document (link text will have completely different text on each invocation of the macro.

– Tim A
9 hours ago










3 Answers
3






active

oldest

votes


















4














I would e.g. create command names:



documentclassarticle
usepackagehyperref
makeatletter
@namedefaaa@linkhrefexample.com/aaamy aaa link
@namedefbbb@linkhrefexample.com/bbbmy bbb link

newcommandmyref[1]%
csname #1@linkendcsname

begindocument
Here is myrefaaa.
enddocument





share|improve this answer
































    2














    let biber do the searching for you:



    assuming there is a file test.bib with



    @onlinetex,
    note=my aaa text,
    url=tex.stackexchange.com


    @onlinegoogle,
    note=my bbb text,
    url=www.google.com



    then



    documentclassarticle
    usepackagebiblatex

    addbibresourcetest.bib

    DeclareFieldFormaturlhref#1printfieldnote
    DeclareCiteCommandmyrefusebibmacrourl

    usepackagehyperref

    begindocument
    Here is myreftex

    myrefgoogle

    enddocument





    share|improve this answer










    New contributor



    ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.


























      1














      You can use xparse:



      pdfcompresslevel=0
      documentclassarticle
      usepackagexparse
      usepackagehyperref

      ExplSyntaxOn

      NewDocumentCommandnewrefmmm
      % #1 = key, #2 = URL, #3 = description, #4 = options for href
      prop_gput:Nnx g_tima_sites_prop #1 @ url tl_to_str:n #2
      prop_gput:Nnn g_tima_sites_prop #1 @ desc #3


      NewDocumentCommandmyrefm
      % #1 = key
      tima_href:xx
      prop_item:Nn g_tima_sites_prop #1 @ url
      prop_item:Nn g_tima_sites_prop #1 @ desc


      prop_new:N g_tima_sites_prop
      cs_new_protected:Nn tima_href:nn href#1#2
      cs_generate_variant:Nn tima_href:nn xx

      ExplSyntaxOff

      newreftexworkshttp://profs.scienze.univr.it/~gregorio/introtexworksTeX works intro
      newrefararahttp://profs.scienze.univr.it/~gregorio/introararaArara intro
      newreftex.sxhttps://tex.stackexchange.comNice site

      begindocument

      myreftexworks

      myrefarara

      myreftex.sx

      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%2f493041%2fhow-do-i-test-for-a-unique-string-with-multiple-possibilities%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









        4














        I would e.g. create command names:



        documentclassarticle
        usepackagehyperref
        makeatletter
        @namedefaaa@linkhrefexample.com/aaamy aaa link
        @namedefbbb@linkhrefexample.com/bbbmy bbb link

        newcommandmyref[1]%
        csname #1@linkendcsname

        begindocument
        Here is myrefaaa.
        enddocument





        share|improve this answer





























          4














          I would e.g. create command names:



          documentclassarticle
          usepackagehyperref
          makeatletter
          @namedefaaa@linkhrefexample.com/aaamy aaa link
          @namedefbbb@linkhrefexample.com/bbbmy bbb link

          newcommandmyref[1]%
          csname #1@linkendcsname

          begindocument
          Here is myrefaaa.
          enddocument





          share|improve this answer



























            4












            4








            4







            I would e.g. create command names:



            documentclassarticle
            usepackagehyperref
            makeatletter
            @namedefaaa@linkhrefexample.com/aaamy aaa link
            @namedefbbb@linkhrefexample.com/bbbmy bbb link

            newcommandmyref[1]%
            csname #1@linkendcsname

            begindocument
            Here is myrefaaa.
            enddocument





            share|improve this answer















            I would e.g. create command names:



            documentclassarticle
            usepackagehyperref
            makeatletter
            @namedefaaa@linkhrefexample.com/aaamy aaa link
            @namedefbbb@linkhrefexample.com/bbbmy bbb link

            newcommandmyref[1]%
            csname #1@linkendcsname

            begindocument
            Here is myrefaaa.
            enddocument






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 8 hours ago

























            answered 9 hours ago









            Ulrike FischerUlrike Fischer

            204k9312704




            204k9312704





















                2














                let biber do the searching for you:



                assuming there is a file test.bib with



                @onlinetex,
                note=my aaa text,
                url=tex.stackexchange.com


                @onlinegoogle,
                note=my bbb text,
                url=www.google.com



                then



                documentclassarticle
                usepackagebiblatex

                addbibresourcetest.bib

                DeclareFieldFormaturlhref#1printfieldnote
                DeclareCiteCommandmyrefusebibmacrourl

                usepackagehyperref

                begindocument
                Here is myreftex

                myrefgoogle

                enddocument





                share|improve this answer










                New contributor



                ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.























                  2














                  let biber do the searching for you:



                  assuming there is a file test.bib with



                  @onlinetex,
                  note=my aaa text,
                  url=tex.stackexchange.com


                  @onlinegoogle,
                  note=my bbb text,
                  url=www.google.com



                  then



                  documentclassarticle
                  usepackagebiblatex

                  addbibresourcetest.bib

                  DeclareFieldFormaturlhref#1printfieldnote
                  DeclareCiteCommandmyrefusebibmacrourl

                  usepackagehyperref

                  begindocument
                  Here is myreftex

                  myrefgoogle

                  enddocument





                  share|improve this answer










                  New contributor



                  ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





















                    2












                    2








                    2







                    let biber do the searching for you:



                    assuming there is a file test.bib with



                    @onlinetex,
                    note=my aaa text,
                    url=tex.stackexchange.com


                    @onlinegoogle,
                    note=my bbb text,
                    url=www.google.com



                    then



                    documentclassarticle
                    usepackagebiblatex

                    addbibresourcetest.bib

                    DeclareFieldFormaturlhref#1printfieldnote
                    DeclareCiteCommandmyrefusebibmacrourl

                    usepackagehyperref

                    begindocument
                    Here is myreftex

                    myrefgoogle

                    enddocument





                    share|improve this answer










                    New contributor



                    ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    let biber do the searching for you:



                    assuming there is a file test.bib with



                    @onlinetex,
                    note=my aaa text,
                    url=tex.stackexchange.com


                    @onlinegoogle,
                    note=my bbb text,
                    url=www.google.com



                    then



                    documentclassarticle
                    usepackagebiblatex

                    addbibresourcetest.bib

                    DeclareFieldFormaturlhref#1printfieldnote
                    DeclareCiteCommandmyrefusebibmacrourl

                    usepackagehyperref

                    begindocument
                    Here is myreftex

                    myrefgoogle

                    enddocument






                    share|improve this answer










                    New contributor



                    ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.








                    share|improve this answer



                    share|improve this answer








                    edited 8 hours ago





















                    New contributor



                    ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.








                    answered 9 hours ago









                    ianian

                    1934




                    1934




                    New contributor



                    ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.




                    New contributor




                    ian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.























                        1














                        You can use xparse:



                        pdfcompresslevel=0
                        documentclassarticle
                        usepackagexparse
                        usepackagehyperref

                        ExplSyntaxOn

                        NewDocumentCommandnewrefmmm
                        % #1 = key, #2 = URL, #3 = description, #4 = options for href
                        prop_gput:Nnx g_tima_sites_prop #1 @ url tl_to_str:n #2
                        prop_gput:Nnn g_tima_sites_prop #1 @ desc #3


                        NewDocumentCommandmyrefm
                        % #1 = key
                        tima_href:xx
                        prop_item:Nn g_tima_sites_prop #1 @ url
                        prop_item:Nn g_tima_sites_prop #1 @ desc


                        prop_new:N g_tima_sites_prop
                        cs_new_protected:Nn tima_href:nn href#1#2
                        cs_generate_variant:Nn tima_href:nn xx

                        ExplSyntaxOff

                        newreftexworkshttp://profs.scienze.univr.it/~gregorio/introtexworksTeX works intro
                        newrefararahttp://profs.scienze.univr.it/~gregorio/introararaArara intro
                        newreftex.sxhttps://tex.stackexchange.comNice site

                        begindocument

                        myreftexworks

                        myrefarara

                        myreftex.sx

                        enddocument





                        share|improve this answer



























                          1














                          You can use xparse:



                          pdfcompresslevel=0
                          documentclassarticle
                          usepackagexparse
                          usepackagehyperref

                          ExplSyntaxOn

                          NewDocumentCommandnewrefmmm
                          % #1 = key, #2 = URL, #3 = description, #4 = options for href
                          prop_gput:Nnx g_tima_sites_prop #1 @ url tl_to_str:n #2
                          prop_gput:Nnn g_tima_sites_prop #1 @ desc #3


                          NewDocumentCommandmyrefm
                          % #1 = key
                          tima_href:xx
                          prop_item:Nn g_tima_sites_prop #1 @ url
                          prop_item:Nn g_tima_sites_prop #1 @ desc


                          prop_new:N g_tima_sites_prop
                          cs_new_protected:Nn tima_href:nn href#1#2
                          cs_generate_variant:Nn tima_href:nn xx

                          ExplSyntaxOff

                          newreftexworkshttp://profs.scienze.univr.it/~gregorio/introtexworksTeX works intro
                          newrefararahttp://profs.scienze.univr.it/~gregorio/introararaArara intro
                          newreftex.sxhttps://tex.stackexchange.comNice site

                          begindocument

                          myreftexworks

                          myrefarara

                          myreftex.sx

                          enddocument





                          share|improve this answer

























                            1












                            1








                            1







                            You can use xparse:



                            pdfcompresslevel=0
                            documentclassarticle
                            usepackagexparse
                            usepackagehyperref

                            ExplSyntaxOn

                            NewDocumentCommandnewrefmmm
                            % #1 = key, #2 = URL, #3 = description, #4 = options for href
                            prop_gput:Nnx g_tima_sites_prop #1 @ url tl_to_str:n #2
                            prop_gput:Nnn g_tima_sites_prop #1 @ desc #3


                            NewDocumentCommandmyrefm
                            % #1 = key
                            tima_href:xx
                            prop_item:Nn g_tima_sites_prop #1 @ url
                            prop_item:Nn g_tima_sites_prop #1 @ desc


                            prop_new:N g_tima_sites_prop
                            cs_new_protected:Nn tima_href:nn href#1#2
                            cs_generate_variant:Nn tima_href:nn xx

                            ExplSyntaxOff

                            newreftexworkshttp://profs.scienze.univr.it/~gregorio/introtexworksTeX works intro
                            newrefararahttp://profs.scienze.univr.it/~gregorio/introararaArara intro
                            newreftex.sxhttps://tex.stackexchange.comNice site

                            begindocument

                            myreftexworks

                            myrefarara

                            myreftex.sx

                            enddocument





                            share|improve this answer













                            You can use xparse:



                            pdfcompresslevel=0
                            documentclassarticle
                            usepackagexparse
                            usepackagehyperref

                            ExplSyntaxOn

                            NewDocumentCommandnewrefmmm
                            % #1 = key, #2 = URL, #3 = description, #4 = options for href
                            prop_gput:Nnx g_tima_sites_prop #1 @ url tl_to_str:n #2
                            prop_gput:Nnn g_tima_sites_prop #1 @ desc #3


                            NewDocumentCommandmyrefm
                            % #1 = key
                            tima_href:xx
                            prop_item:Nn g_tima_sites_prop #1 @ url
                            prop_item:Nn g_tima_sites_prop #1 @ desc


                            prop_new:N g_tima_sites_prop
                            cs_new_protected:Nn tima_href:nn href#1#2
                            cs_generate_variant:Nn tima_href:nn xx

                            ExplSyntaxOff

                            newreftexworkshttp://profs.scienze.univr.it/~gregorio/introtexworksTeX works intro
                            newrefararahttp://profs.scienze.univr.it/~gregorio/introararaArara intro
                            newreftex.sxhttps://tex.stackexchange.comNice site

                            begindocument

                            myreftexworks

                            myrefarara

                            myreftex.sx

                            enddocument






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 6 hours ago









                            egregegreg

                            744k8919493288




                            744k8919493288



























                                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%2f493041%2fhow-do-i-test-for-a-unique-string-with-multiple-possibilities%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

                                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

                                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

                                François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480