old script needs updating
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 5
- Joined: Sun Apr 03, 2016 6:30 am
old script needs updating
Hi,
I've been using my RunRev stacks and not working in LiveCode so much, but have found that an old script now no longer works. I need it to get data out of the stack so if anyone can help I would greatly appreciate it. The script is below. It still puts up the dialog, but doesn't seem to do anything else.
on tabdump
put bg fld "audioname" into audio
set cursor to busy
put bg fld "text" into temptext
put bg fld "starttime" into tempstart
put bg fld "endtime" into tempend
repeat with x=1 to the number of lines of temptext
-- put x &" / " & (the number of lines of "temptext")
put return& line x of temptext after tabdoc
put tab& line x of tempstart after tabdoc
put tab& line x of tempend after tabdoc
end repeat
put".tab" after audio
--set path trapelpel
open file audio
write tabdoc to file audio
close file audio
put "Done writing tab-delimited file " before audio
set cursor to arrow
answer audio
end tabdump
I've been using my RunRev stacks and not working in LiveCode so much, but have found that an old script now no longer works. I need it to get data out of the stack so if anyone can help I would greatly appreciate it. The script is below. It still puts up the dialog, but doesn't seem to do anything else.
on tabdump
put bg fld "audioname" into audio
set cursor to busy
put bg fld "text" into temptext
put bg fld "starttime" into tempstart
put bg fld "endtime" into tempend
repeat with x=1 to the number of lines of temptext
-- put x &" / " & (the number of lines of "temptext")
put return& line x of temptext after tabdoc
put tab& line x of tempstart after tabdoc
put tab& line x of tempend after tabdoc
end repeat
put".tab" after audio
--set path trapelpel
open file audio
write tabdoc to file audio
close file audio
put "Done writing tab-delimited file " before audio
set cursor to arrow
answer audio
end tabdump
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: old script needs updating
What version did this work in, and what version are you now using.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 5
- Joined: Sun Apr 03, 2016 6:30 am
Re: old script needs updating
I am now using LC 8, but recall it was working last on 7.
Re: old script needs updating
Hi Nick,
1. welcome to the forum!
2. Did you already step through the script with the debugger to see what exactly does not work?
The script itself looks OK, nothing that should cause any headache!
Some hints:
a. Since HyperCard there is no more need to use "bg field" or "cd field", just use "field".
b. Not sure if "audio" is maybe a reserved word in LC.
Best
Klaus
1. welcome to the forum!

2. Did you already step through the script with the debugger to see what exactly does not work?
The script itself looks OK, nothing that should cause any headache!
Some hints:
a. Since HyperCard there is no more need to use "bg field" or "cd field", just use "field".

b. Not sure if "audio" is maybe a reserved word in LC.
Best
Klaus
-
- Posts: 5
- Joined: Sun Apr 03, 2016 6:30 am
Re: old script needs updating
Thanks for the suggestions. But debugging doesn't throw any errors. I changed 'audio' to '$audio'. The script is meant to take the contents of three fields and output them to a tab separated file, open the file and paste into it. Instead, it runs but has no output.
Re: old script needs updating
Hi Nick,
hint: $ is also a "keyword" in LC, check the dictionary
OK, no output?
What exactly is in your variable "audio" resp. fld "audioname"?
Maybe this is a permission issue?
I never use the "open/write/close file..." syntax, so I am not sure if the syntax is correct.
Maybe try the shorter URL syntax:
Best
Klaus
hint: $ is also a "keyword" in LC, check the dictionary

OK, no output?
What exactly is in your variable "audio" resp. fld "audioname"?
Maybe this is a permission issue?
I never use the "open/write/close file..." syntax, so I am not sure if the syntax is correct.
Maybe try the shorter URL syntax:
Code: Select all
...
end repeat
put".tab" after audio
--set path trapelpel
## open file audio
## write tabdoc to file audio
## close file audio
put tabdoc into url("file:" & audio)
put "Done writing tab-delimited file " before audio
...
Klaus
-
- Posts: 5
- Joined: Sun Apr 03, 2016 6:30 am
Re: old script needs updating
Hi Klaus,
Thanks very much for your help, but nothing worked. I then went back to LC7 and it all exported fine so that is my solution.
Nick
Thanks very much for your help, but nothing worked. I then went back to LC7 and it all exported fine so that is my solution.
Nick
Re: old script needs updating
To see if the problem is a bug that needs to be reported, it would be good to know where the error occurs.
In the debugger, does the audio variable contain the correct text? If so, then the problem is in writing the file. Do you get an empty file, or no file at all? What is the file path you're writing to? If you search for the file, does it show up in another location? Are you trying to write to a restricted location?
In the debugger, does the audio variable contain the correct text? If so, then the problem is in writing the file. Do you get an empty file, or no file at all? What is the file path you're writing to? If you search for the file, does it show up in another location? Are you trying to write to a restricted location?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 5
- Joined: Sun Apr 03, 2016 6:30 am
Re: old script needs updating
I have checked in LC8 and the error seems to be in writing the file. I can 'put' the content all the way through the script, but it is not being written to file. No file is opened and there is no file of the required name anywhere.
Re: old script needs updating
not really sure if its helps but made a script that use write and read
need 2 field, called data and data2, and one button
write some text in field data
put this script in a button
it is based on https://sites.google.com/a/pgcps.org/livecode/files
has testet it on livecode 8.16, and did work for me
need 2 field, called data and data2, and one button
write some text in field data
put this script in a button
if it works, the text in field "data" will be writen to the file mytext.txt, then open for read, and put into field "data2"on mouseUp
put specialFolderPath("Documents") & "/mytext.txt" into myFile
open file myFile for write
write field "data" to file myFile
close file myFile
open file myFile for read
read from file myFile until EOF
put it into fld "data2"
close file myFile
end mouseUp
it is based on https://sites.google.com/a/pgcps.org/livecode/files
has testet it on livecode 8.16, and did work for me
Re: old script needs updating
Okay, that's progress. Add this to your handler:nick.thieberger wrote:I have checked in LC8 and the error seems to be in writing the file. I can 'put' the content all the way through the script, but it is not being written to file. No file is opened and there is no file of the required name anywhere.
Code: Select all
open file audio
write tabdoc to file audio
answer the result -- ADD THIS
close file audio
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com