First, the 'Read lines from file' part. There are a couple methods.
1) are you familiar with the basic, simple OpusScript method for read line after line. The basic concept is this: OpenFile()... then ReadLine(), ReadLine(), ReadLine()...
-- this is mostly useful for reading-in the file content serially, whether you display one line at a time or you populate a larger text box with several lines.
2)
I'm going to suggest a somewhat different approach. Actually, it is the same method as above but instead of placing the text in a textbox on the page,
populate a ListBox object.
'Why?'
Because you will have the ListBox either positioned 'off-page', or otherwise make it 'Hidden'. You will later use the INDEX feature of the ListBox as a way to access any line you choose. Or
that the random value specifies (this is what will make this solution 'simple').
So first... populate a ListBox. You can keep is 'Visible' for now (hide it later).
Here's an example:
viewtopic.php?t=2477&highlight=listbox+text
Quote:
download the IMP, it contains a listbox, populated from an external text file.
(the discussion is about other things, but the basic example should pave the way for you)and:
viewtopic.php?t=2015&highlight=listbox+text(no example here, but shows the script)viewtopic.php?t=3801&highlight=readline+fileThis one is a bit more involved (and the added complexity may get in the way). But maybe just viewing it will give you some confidence how the 'selection' part works.
Sample IMP:
viewtopic.php?t=3632&highlight=listbox+text- - - - -
So once you have the ListBox populated with your textlines, all you need to do is generate a random number between 0 and 287... then
use that value as the index number for the ListBox selection command.
Search the forum for: generate random number (or similar search).
Otherwise the scripting for 'random' is fairly straight forward.
The
ListBox selection (by button click & index value) is illustrated in that 'tickbox' example, and probably in others.
That one selected line is displayed in a separate, standard textbox object.- - - - - -
You asked
Quote:
It´s possible to embbed this file (txt) to a project?
but then you say 'no' to "...include a resource file"
'Yes of course' you can include your text file with 288 quotes. And the way to do it is specify that file as an additional resource (a couple of ways to do that).
Let us know if you need more help.
BTW... there are a number of relevant threads and useful examples --- from developers working on 'quiz' or 'quizzes' (presenting questions to students, etc... randomnizing multiple choice tests, etc.). That's another area that may provide some methods and pieces.Quote:
It´s possible to embbed this file (txt) to a project?