ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
Subject: Re: How to print a random whole number between x and y?
Date: Fri, 17 Jun 2022 17:21:06 +0200	[thread overview]
Message-ID: <c99af57f-c490-cefc-e9ef-7992f4ca50af@gmail.com> (raw)
In-Reply-To: <1604222500.2877043.1655475005491@mail.yahoo.com>


[-- Attachment #1.1: Type: text/plain, Size: 1649 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 2936 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2022-06-17 15:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1604222500.2877043.1655475005491.ref@mail.yahoo.com>
2022-06-17 14:10 ` Joel via ntg-context
2022-06-17 15:21   ` Wolfgang Schuster via ntg-context [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c99af57f-c490-cefc-e9ef-7992f4ca50af@gmail.com \
    --to=ntg-context@ntg.nl \
    --cc=wolfgang.schuster.lists@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).