Quantcast
Channel: LiveCode Forums
Viewing all articles
Browse latest Browse all 757

Talking LiveCode • Saving and reading txt file

$
0
0
Hey everyone,

Working on allow general saved data to be retrieved in my app, both for game saves and storing whether the in-app purchase has been made.

I am following the guidlines here https://lessons.livecode.com/m/4069/l/1 ... e-appstore and have inputted the code as described:

CODE:

on preOpenStack   loadNonConsumablePurchaseend preOpenStackon loadNonConsumablePurchased   local tPath   put specialFolderPath("documents") & "/nonconsumablepurchased.txt" into tPath   if there is a file tPath then      set the cNonConsumablePurchased of this stack to url("file:" & tPath)      put "PURCHASED" into fld "purchased" of cd "playmodes"   end ifend loadNonConsumablePurchasedsetProp cNonConsumablePurchased pValue   set the cNonConsumablePurchased of this stack to pValue   if pValue then      put "PURCHASED" into fld "purchased" of cd "playmodes"         else      put "NOT PURCHASED" into fld "purchased" of cd "playmodes"   end if   saveNonConsumablePurchasedend cNonConsumablePurchasedon saveNonConsumablePurchased   put the cNonConsumablePurchased of this stack into url("file:" & specialFolderPath("documents") & "/nonconsumablepurchased.txt")end saveNonConsumablePurchasedon purchaseStateUpdate pPurchaseID, pProductID, pState   switch pState      case "paymentReceived"          answer "payment received!"         offerPurchasedProduct pProductID         mobileStoreConfirmPurchase pProductID         mobileStoreDisablePurchaseUpdates         break      case "error"         answer "Error occured during purchase handling:" & return & return & mobileStorePurchaseError(pPurchaseID)         mobileStoreDisablePurchaseUpdates         break      case "invalidSKU"         answer "Invalid SKU."         mobileStoreDisablePurchaseUpdates         break      case "alreadyEntitled"         answer "Already Owned."         mobileStoreDisablePurchaseUpdates         break      case "restored"         answer "restored"         offerPurchasedProduct pProductID         mobileStoreConfirmPurchase pProductID         mobileStoreDisablePurchaseUpdates         break      case "cancelled"         answer "Purchase Cancelled:" && pProductID         mobileStoreDisablePurchaseUpdates         break        end switchend purchaseStateUpdate on offerPurchasedProduct pProductID   if pProductID is "FullGame" then      set the cNonConsumablePurchased of this stack to true   end ifend offerPurchasedProduct
It all works to the point of allowing the in-app purchase, I see "purchased" in the field and all the dialogue boxes saying I've purchased etc.

However, when I quit the app and load it back up, I dont see "purchased" as I should, since I've asked it to check for the txt file and then put that into the field once found.

Any ideas?

Statistics: Posted by Aduro91 — Tue Jan 28, 2025 6:58 pm



Viewing all articles
Browse latest Browse all 757

Trending Articles