Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently November 16th, 2024, 1:52 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Save to a txt file
PostPosted: March 27th, 2007, 4:48 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
does anybody know how to save varabiles to a txt file and then you reterive
the data from it but not all data sepcific data.


For this message opuslover has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 27th, 2007, 5:04 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
function Save()
{
var myData = "Whatever you like"
var FileNameObj = OpenFile ("C:\\opus.txt", true)
FileNameObj.WriteLine (myData)
FileNameObj.Close()
}

This script will save the information in the myData variable to the opus.txt file in the C root. If you use the File Management Actions, you can store a users selected path in another variable are replace the OpenFile() string with the variable.

To read the information back in use:

FileNameObj.ReadLine (myData)

Hope it helps,

Mack


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 27th, 2007, 5:45 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Thank you mac for your reply, but if i have more than varible Let us say when I open the text file after saving I find like this
English,What is the past tense of go, went,what is the past tense of write,wrote.......etc
Now how can retrive the second question which is What is the past tense of wrote

I hope that I explained my idea in good way


For this message opuslover has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 27th, 2007, 5:53 pm 
Offline

Joined: November 3rd, 2004, 12:12 pm
Posts: 117
Location: France - Bretagne
I have done that by using "read from disk file" and after "read next line from file" or "read next field from file" action (with "loop X time" to find the x line or the x field)

Benoit

_________________
Opus Pro 06, Win XP.


For this message benoit has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 27th, 2007, 7:11 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
I need more explanation .I'm a novice


For this message opuslover has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 27th, 2007, 10:38 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 511
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
There is also another way, but it might be a bit scary for you, but it's not as difficult as you may think and that's the best way to learn.

You could use a database which simply has datafields for tense and past tense or any combination. You also have an index field and simply loop through the database using a loop counter.

the table would be something like this
INDEX....WORD.....PAST_TENSE
..1............go...........went
..2............write........wrote
..3............have........had
..4............cut...........cut
..5............drink........drank etc

You need to create a DSN (Data Source Name) to create a link to the table in the database....see help files

On each loop, use a SQL query to retrieve the WORD and PAST_TENSE. the query would be something like this (SELECT'WORD''PAST_TENSE'FROM'mytensetable' WHERE 'INDEX'='<LoopCount>')

what it does is.... use the DSN to tell it where to find the database table (mytensetable) then it selects the WORD and PAST_TENSE form the row where the INDEX number equals the loop count...so if the loop count was 3, it would retrieve 'have' and 'had' In the SQL query, you also specify the publicaqtion variables where these two words will be saved. They could be called WORD and PAST_TENSE



The SQL query would retrieve WORD and PAST_TENSE.
Having retrieved 'WORD' ....this could be used in a publication variable which becomes the question so....for publication variable 'question'.....question=("what is the past tense of "+WORD+"?")

this variable could be inserted into a text object, so for the above example the text box would show "what is the past tense of have?"
On the next loop (4), it would show "what is the past tense of cut?" etc

PAST_TENSE....this could be used to compare the users answer to the correct answer.

sorry it's brief outline, but it's not as difficult as it first seems.

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 28th, 2007, 6:08 am 
Offline

Joined: November 3rd, 2004, 12:12 pm
Posts: 117
Location: France - Bretagne
look at the picture :

read from disk file to "temporaire" : put the whole text in variable temporaire

loop 4 times + goto next line in file + read next line from file to menu03 :
put the line 5 of the texte in the variable menu03

hope this help

benoit


You do not have the required permissions to view the files attached to this post.

_________________
Opus Pro 06, Win XP.


For this message benoit has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 28th, 2007, 10:14 am 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Thanks all for your great help .I'll try all and find what'll work for me


For this message opuslover has been thanked by : mackavi


Top
 Profile  
 
 Post subject: A little more
PostPosted: March 28th, 2007, 2:07 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi OpusLover,

here's a little more advanced script that will create the bases of a quiz for your irregular verbs.

var myData = new Array(4)

function theOpen()
{
myClick = ''
myAnswerOne = ''
myAnswerTwo = ''
myAnswerThree = ''

var FileNameObj = OpenFile ("C:\\quiz.txt")
var count = 0

while (count < 4)
{
myData[count] = FileNameObj.ReadLine()
if (myData[count] == 'END')
{
FileNameObj.Close()
count = 4
myClick = 'End of Quiz'
}
count++

}

myQuestion = 'What is the past tense of '+ myData[0] + '?'

myAnswerOne = myData[String.random(3)+1]

while (myAnswerTwo == myAnswerOne || myAnswerTwo == '')
{
myAnswerTwo = myData[String.random(3)+1]
}
while (myAnswerThree == myAnswerOne || myAnswerThree == myAnswerTwo || myAnswerThree == '')
{
myAnswerThree = myData[String.random(3)+1]
}


}

Create the myAnswers / myClick as variables in the Publication.

The txt file looks like:

to go
went
goed
goes
to have
had
haved
hid
to bend
bent
bended
bens
END

Have saved the publication that I tested this in. It's only rough,but if you'd like it,let me know.

Mac


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 28th, 2007, 3:00 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Really nice people and great help.I really done it using mac script with some modifications and i've got Great ideas from sandyn and benoit for other educational programmes.


For this message opuslover has been thanked by : mackavi


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 4 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