I have a database on a LiveCode server that I use to track user interactions in a LiveCode app. It has gotten too big to query in LiveCode without timeout errors (the JSON gets mangled because there are now several thousand records), so I'm trying to generate a text file on the server and download that instead.

I can get the text file to generate on the server, but when I try to download it to my LiveCode app (to eventually save on the end-users computer) the text is in some weird format. I assumed this was some wierd unicode issue and tried to textDecode it, but can't seem to figure out what format it actually is so that just gives me text in a different weird format ("UTF-8", "UTF-16", and "MacRoman" don't seem to work).

My code on the LiveCode Server seems straight forward:
  put "SELECT * FROM promosRedeemed" into tSql
  put revDataFromQuery(TAB, "|", sDbId, tSql) into tRedemptions
  set linedelimiter to "|"
  set itemdelimiter to tab
replace RETURN with " -=- " in tRedemptions // ACCOUNTS FOR LINE BREAKS IN DATA
  replace "|" with RETURN in tRedemptions
  put "redemption-log_" & the seconds & ".txt" into tFileName
open file specialFolderPath("home") & "/public_html/server/apps/iot/logs/" & tFileName for write write tRedemptions to file specialFolderPath("home") & "/public_html/server/apps/iot/logs/" & tFileName close file specialFolderPath("home") & "/public_html/server/apps/iot/logs/" & tFileName


The first line of the text file when viewed in a web browser or text file downloaded directly (outside of LC) is plain text and looks as expected: 294 Wednesday, July 13, 2016 8:36 15 3 MacOS 10.11.5 -=- MacBookPro11,3 -=- 0,0,1920,1200 -=- 39.892219,-85.974632

But when I fetch that URL in LiveCode using...
 put url (tURLtoDownload) into tFullRedemptionList
 put tFullRedemptionList into url ("binfile:Full-IOT_TSM_RedemptionList.xls")

...the first line (and all other lines basically) looks like this:
ã‰Ω◊rÎ:∂(˙Ï˝<un›ó≥<7rp≠ªÎ:Áú˝‚bîsíø˛$@BH[≤<Â∂ª´´zyA¿»L∞ˇF¸ø! ÿD¡÷˙ïx‚¸Óψ&˝G˛¡‡∏dXíÇIAˇц†Í?ˇ’Ø°¸o õÄrNÄâ¸ÔhMıôı0fi‹˝Ç?˛!≈ø¬ Áˇê+è7Å˛e≈ïSPˇ®ˇ‘˝êx~(ßPø5?Ñ–ˇKÍ˝%eSô_ˇŸƒnÿQ?Œ—bSHòˇπ˜áN·w6)¸?TiÛ•ˇá≤¢NÕ!–g(Ù
Ä˙‘
®[      ùïàÎïuá»YäÅ^ZCbà›ïX؃5+IπR*ä”Î≤f%uW


I know I've done similar tasks before (pretty sure this is code I borrowed from other projects I've done) but can't figure out why this text is so garbled. Tried in 9.0.0dp7 and 8.1.6 with the same result. Any ideas what I'm doing wrong?

--Andrew Bell



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to