old script needs updating

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
nick.thieberger
Posts: 5
Joined: Sun Apr 03, 2016 6:30 am

old script needs updating

Post by nick.thieberger » Sun Apr 03, 2016 6:33 am

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: old script needs updating

Post by FourthWorld » Sun Apr 03, 2016 7:21 am

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

nick.thieberger
Posts: 5
Joined: Sun Apr 03, 2016 6:30 am

Re: old script needs updating

Post by nick.thieberger » Sun Apr 03, 2016 12:22 pm

I am now using LC 8, but recall it was working last on 7.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: old script needs updating

Post by Klaus » Sun Apr 03, 2016 12:30 pm

Hi Nick,

1. welcome to the forum! :D
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". :D
b. Not sure if "audio" is maybe a reserved word in LC.


Best

Klaus

nick.thieberger
Posts: 5
Joined: Sun Apr 03, 2016 6:30 am

Re: old script needs updating

Post by nick.thieberger » Sun Apr 03, 2016 12:46 pm

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.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: old script needs updating

Post by Klaus » Sun Apr 03, 2016 12:53 pm

Hi Nick,

hint: $ is also a "keyword" in LC, check the dictionary :D

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
...
Best

Klaus

nick.thieberger
Posts: 5
Joined: Sun Apr 03, 2016 6:30 am

Re: old script needs updating

Post by nick.thieberger » Sun Apr 03, 2016 8:49 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: old script needs updating

Post by jacque » Mon Apr 04, 2016 5:01 pm

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?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

nick.thieberger
Posts: 5
Joined: Sun Apr 03, 2016 6:30 am

Re: old script needs updating

Post by nick.thieberger » Tue Apr 05, 2016 4:15 pm

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.

hpsh
Posts: 52
Joined: Tue Aug 25, 2015 8:06 pm

Re: old script needs updating

Post by hpsh » Tue Apr 05, 2016 5:45 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: old script needs updating

Post by jacque » Tue Apr 05, 2016 7:52 pm

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.
Okay, that's progress. Add this to your handler:

Code: Select all

open file audio
write tabdoc to file audio
answer the result -- ADD THIS
close file audio
If there is an error writing the file, the result can give you a clue. What is the filepath you are writing to? I'm guessing it's a folder that doesn't allow write permissions.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply