Mac version not exporting data

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
gwiller
Posts: 1
Joined: Tue Jan 21, 2020 7:11 pm

Mac version not exporting data

Post by gwiller » Tue Jan 21, 2020 7:24 pm

Hi all,

I am experiencing issues with the Mac version of my LiveCode project not exporting data. I can run the program on a Mac just fine, but it won't produce a .txt file with the data. LiveCode also won't store the data internally. I haven't had any issues with the PC version.

The stack script is included below:

on finish
global data,sessionNum,subID,cond,totaltime,testorder
put ((the ticks - totaltime)/60)/60 into totaltime
-- set the decorations of stack "CAM" to default
-- set the backdrop to none
-- show taskbar
put subID & "," & totaltime & "," & the time & "," & the date & return into everything
put data&return after everything
put everything & return after field "savedata" of card "main task materials"
put the ticks into timestamp
put ("Newcombe"&subID&" "&timestamp&".txt") into filename
open file filename for write
if the result is empty then
write everything to file filename
close file filename
end if
end finish

on extractdata
put field "savedata" of card "main task materials" into everything
put line 1 of everything into subID
put ("Newcombe extraction for "&subID&".txt") into filename
open file filename for write
if the result is empty then
write everything to file filename
close file filename
end if
end extractdata

on matlists
global matlist,matlist2,data,sessionNum,cond,criterion,relearn,IDU,keepscore,
put empty into data
repeat with x = 1 to 100 -- set up to handle up to 100 items; if more, change this value
put 0 into line x of keepscore
end repeat
put 1 into criterion
put empty into matlist
put card field "items" of card "main task materials" into hold
put card field "IDU" of card "main task materials" into IDU
put the number of lines in hold into numitems
repeat with x = 1 to numitems
put "test," & (line x of hold) & return after matlist
put "study," & (line x of hold) & return after matlist
end repeat
put the number of lines in matlist into numlines
if line numlines of matlist is empty then
delete line numlines of matlist
end if
put empty into matlist2
end matlists

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2423
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Mac version not exporting data

Post by jmburnod » Tue Jan 21, 2020 8:33 pm

hi,
Welcome to this forum.
I think you have to define a destination folder because on IDE default folder is the path of LiveCode app in Application folder
This works to write to a file of documents folder. Have a look to specialfolderpath, note some folders are protected for write

Code: Select all

on extractdata
 put field "savedata" of card "main task materials" into everything
   put line 1 of everything into subID
   put specialfolderpath(documents) & "/" & "Newcombe extraction for " & subID & ".txt" into filename
   --put everything into url("file:" & filename)-- you may use this line to write in your file instead the five lines below
   open file filename for write
   if the result is empty then
      write everything to file filename
      close file filename
   end if
end extractdata
Best regards
Jean-Marc

Post Reply

Return to “Bug Triage”