Re: [NTG-context] How to print a random whole number between x and y?

2022-06-17 Thread Wolfgang Schuster via ntg-context

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
___
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
___


[NTG-context] How to print a random whole number between x and y?

2022-06-17 Thread Joel via ntg-context
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?
--Joel
___
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
___