Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 3:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: RANDOM Quotes from TXT file - OPUS PRO
PostPosted: December 17th, 2009, 4:31 pm 
Offline

Joined: December 17th, 2009, 4:16 pm
Posts: 2
Location: Brazil
Hello. I'm Ivo from Brazil!
Sorry my english!
I have some questions...
I have a text file with 288 lines (one quote per line) (quotes.txt)
I need one script for RANDOMIZE and displays this quotes.
It´s possible to embbed this file (txt) to a project?
It´s possible to READ, RANDOMIZE the quotes and SHOW the result (from a text file?) when press a button? ex: "next message"
-------------------------------------------------------------
Using OPUS PROFESSIONAL v6
Thanks!
Ivo Maioli


Top
 Profile Visit website  
 
 Post subject:
PostPosted: December 17th, 2009, 11:11 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Hello Ivo.
Welcome to DW/Opus forum.

'Yes' it is possible.
The 'how to do it' depends on what you mean by randomize. Do you care if there would be a repeat display of a quote?

It seems you have some programming and scripting skills, true? Are you familiar with or comfortable with Arrays?

So let me think on this and find some posts here that cover the pieces for a solution:
* read file line be line (quote lines)
* generating a random number (which line to go to)
* storing an Array of 'visited lines' (if 'no repeat' is required feature) This also allows User to exit and return, with the Pub 'remembering' what was previously displayed.
* including a resource file, e.g. quotes1.txt, with the published Pub (best if you read User Guide and helpfiles on "Additional Resources" and also the "publishing" process/options)

I'll get back in next day or so.

[EDIT:] If anyone else has some pointers, examples, help in the meantime... please do post.

ps. thanks for including Profile info. Good to add some PC/system info for future.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: December 18th, 2009, 1:44 pm 
Offline

Joined: December 17th, 2009, 4:16 pm
Posts: 2
Location: Brazil
So let me think on this and find some posts here that cover the pieces for a solution:
* read file line be line (quote lines) YES
* generating a random number (which line to go to) YES
* storing an Array of 'visited lines' (if 'no repeat' is required feature) This also allows User to exit and return, with the Pub 'remembering' what was previously displayed. NO - Isn't necessary
* including a resource file, e.g. quotes1.txt, with the published Pub (best if you read User Guide and helpfiles on "Additional Resources" and also the "publishing" process/options) NO

I'll get back in next day or so.

[EDIT:] If anyone else has some pointers, examples, help in the meantime... please do post.
----------------------------------------------
OPUS PRO, using WIN XP Pro, CORE 2 DUO 1.8 - 1GB RAM, 300gb SATA
Thanks
IVO MAIOLI

www.ivomaioli.co.cc


Top
 Profile Visit website  
 
 Post subject:
PostPosted: December 19th, 2009, 12:04 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
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+file

This 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?

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group