From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/115280 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wolfgang Schuster via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: How to print a random whole number between x and y? Date: Fri, 17 Jun 2022 17:21:06 +0200 Message-ID: References: <1604222500.2877043.1655475005491.ref@mail.yahoo.com> <1604222500.2877043.1655475005491@mail.yahoo.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6086246154326046380==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29102"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/7.0.56 Cc: Wolfgang Schuster To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Jun 17 17:21:56 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2DnI-0007FP-1D for gctc-ntg-context-518@m.gmane-mx.org; Fri, 17 Jun 2022 17:21:56 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 723536DE; Fri, 17 Jun 2022 17:21:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K_xH2QY2XuK8; Fri, 17 Jun 2022 17:21:12 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 53C6628A46B; Fri, 17 Jun 2022 17:21:12 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 025EB28A46B for ; Fri, 17 Jun 2022 17:21:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v9pLlAzl9fgw for ; Fri, 17 Jun 2022 17:21:09 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.218.47; helo=mail-ej1-f47.google.com; envelope-from=wolfgang.schuster.lists@gmail.com; receiver= Original-Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 0594A6DE for ; Fri, 17 Jun 2022 17:21:08 +0200 (CEST) Original-Received: by mail-ej1-f47.google.com with SMTP id gl15so9412860ejb.4 for ; Fri, 17 Jun 2022 08:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=KpSNvx2Br98GlA32PyhYUBUxYRythcCEuUh4RFBBJtk=; b=paRsTldBo93IZueGyMHuQ5FCZiCnm6AJe9eEo/gnLmDNfb0ESRkpA3yjffvPEiorD1 Gjem+6/PsA9kfxGXOfhtF4hdJ03zLjLi1g0dLWnDo7QXMQJqOARBityqFLNSdz6IgjGG YeuLm45/Rii08ICwIhCvImxmxFGVKxGZA7dYa6nOudG8KTSoDs7hO2f1YyT07Qcv3R89 og67Ze+Ukn+KcQFU7A2ITDu46KUYZ/HQhJQULMJPKj1Tyo1HlWGYRyR46XeXWtQlUBin Q68clFgii6Un3VwDyz5LZo+hBWFom4qAXD1cjGeLc8wFujnrMjY/xe1WR1QQcmxFBBTc aONw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=KpSNvx2Br98GlA32PyhYUBUxYRythcCEuUh4RFBBJtk=; b=iSNIiaOkNblK/NnrtVT/dajAVoHj+XuJuF3lb8khZbGT7okRVKEMh0dMaEdeXYm32L gxDwKE2NAExcwlAzmiBcf6FT+BJBgL6PLFlXRt07m6d7iv6r/h7BAQ+r+db9QKBD835J GHBx8ZatSkQ+P/nMYI0QFjFaPHNpS1Z3Td/+b05He3U/67bbtiUvvDv9+rfL/NmPZK/I giIFAJLVo+e3XRDI88YdgpaXzUanHLlLny1gjluvBvNNP6m7XAXlK5g/fYKpEWrHDDu9 3474c7ESWyrG1kFR7NQMOcSnTSqOa1FGnBBF5Ir1GH/iNEU7M0UfsXO0GhOy77kpoFMD UI6Q== X-Gm-Message-State: AJIora91ThEwRKWxmfSPG/PR2oUoaimoCHHsucg9uC94JP/66Sl+KVmv wX7yO0pR8o8DukjRDQuBIDTPAiidNY0= X-Google-Smtp-Source: AGRyM1vujGnuCJ1p7kKtpZ4FrJW+Nc8ZopASeZHdNMJe3aTq6xZ+kjrf+54ReSp20JBcnkKnxE2R9w== X-Received: by 2002:a17:906:b795:b0:70d:8e9:f4d2 with SMTP id dt21-20020a170906b79500b0070d08e9f4d2mr10146051ejb.188.1655479268470; Fri, 17 Jun 2022 08:21:08 -0700 (PDT) Original-Received: from ?IPv6:2a02:810d:a8bf:f874::5131? ([2a02:810d:a8bf:f874::5131]) by smtp.gmail.com with ESMTPSA id m1-20020a1709062ac100b0071160715917sm2276145eje.223.2022.06.17.08.21.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2022 08:21:07 -0700 (PDT) In-Reply-To: <1604222500.2877043.1655475005491@mail.yahoo.com> Content-Language: en-US X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:115280 Archived-At: This is a multi-part message in MIME format. --===============6086246154326046380== Content-Type: multipart/alternative; boundary="------------069B5D2ED3D08998ECBEFB05" Content-Language: en-US This is a multi-part message in MIME format. --------------069B5D2ED3D08998ECBEFB05 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Joel via ntg-context schrieb am 17.06.2022 um 16:10: > I was using this code for a long time in my document. I have a PDF > with 10 pages, and this would randomly display one of those pages: > >         \ctxlua{math.randomseed( os.time() )} > >         \getrandomnumber \n {1} {10} > >      \placefigure[force, > none]{}{\framed[frame=off]{\externalfigure[comic.pdf][page=\n, > width=\textwidth]}} > > For reasons I cannot understand, after an update of ConTeXt, the code > no longer works, though trying to reduce it to a minimum working > example it works, so I cannot figure out what is wrong in my code. > > Undefined control sequence > > ...domseed( os.time() )} \par \getrandomnumber \n > {1} {10} \par \placefigure... > \doifsomething #1->\edef \m_syst_string_one {#1 > }\ifx \m_syst_string_one \emp... > \event ... {#6}{{\bf #6}} \par \doifsomething {#7} > {#7 } \par \doifsomething ... > > > Is there another solution for generating a random whole number between > 1 and 10? Without a better example there is no way to tell what's wrong with your document. The most likely answer is that you try to expand part of your code which contains the \getrandomnumber line but since \n isn't defined yet you get the error message. What you can try is to replace \getrandomnumber and "page=\n" with "page=\randomnumber{...}{...}". \startbuffer[dummyfile] \dorecurse{10}{\centerbox{\definedfont[Sans sa 10]Page \recurselevel}} \stopbuffer \setuplayout[page] \starttext %\getrandomnumber\n{1}{10} %\typesetbuffer[dummyfile][page=\n] \typesetbuffer[dummyfile][page=\randomnumber{1}{10}] \stoptext Wolfgang --------------069B5D2ED3D08998ECBEFB05 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Joel via ntg-context schrieb am 17.06.2022 um 16:10:
I was using this code for a long time in my document. I have a PDF with 10 pages, and this would randomly display one of those pages:

        \ctxlua{math.randomseed( os.time() )}
        
        \getrandomnumber \n {1} {10}
    
        \placefigure[force, none]{}{\framed[frame=off]{\externalfigure[comic.pdf][page=\n, width=\textwidth]}}
       
For reasons I cannot understand, after an update of ConTeXt, the code no longer works, though trying to reduce it to a minimum working example it works, so I cannot figure out what is wrong in my code.

Undefined control sequence

<argument> ...domseed( os.time() )} \par \getrandomnumber \n
                                                  {1} {10} \par \placefigure...
\doifsomething #1->\edef \m_syst_string_one {#1
                                               }\ifx \m_syst_string_one \emp...
\event ... {#6}{{\bf #6}} \par \doifsomething {#7}
                                                  {#7 } \par \doifsomething ...


Is there another solution for generating a random whole number between 1 and 10?

Without a better example there is no way to tell what's wrong with your document. The most likely answer is that you try to expand part of your code which contains the \getrandomnumber line but since \n isn't defined yet you get the error message.

What you can try is to replace \getrandomnumber and "page=\n" with "page=\randomnumber{...}{...}".

\startbuffer[dummyfile]
\dorecurse{10}{\centerbox{\definedfont[Sans sa 10]Page \recurselevel}}
\stopbuffer

\setuplayout[page]

\starttext

%\getrandomnumber\n{1}{10}
%\typesetbuffer[dummyfile][page=\n]

\typesetbuffer[dummyfile][page=\randomnumber{1}{10}]

\stoptext

Wolfgang --------------069B5D2ED3D08998ECBEFB05-- --===============6086246154326046380== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============6086246154326046380==--