Getting the users country

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Getting the users country

Post by richmond62 » Thu Aug 10, 2023 4:12 pm

Well: there's a thought:

https://lessons.livecode.com/m/2592/l/126625-zip-tool

I wonder if THAT will 'unfold' an .ods file?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Getting the users country

Post by Klaus » Thu Aug 10, 2023 4:18 pm

If the ODS file is in fact a ZIP archive in disguise, that will do the trick!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Getting the users country

Post by richmond62 » Thu Aug 10, 2023 4:36 pm

It does work: I am halfway through running up a stack to open the 'content.xml' file inwith an ODS thing; but guests are just arriving for supper, so, what with 'polite' conversation & alcohol intake will probably not complete the thing until tomorrow.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Getting the users country

Post by richmond62 » Fri Aug 11, 2023 11:15 am

SShot 2023-08-11 at 13.11.24.png
-
Humph!

Well, so far, so good: Opens an ODS file and extracts its contents where you tell it to.

BUT not yet capable of loading the 'content.xml' file into the field yet. :cry:

Bits 'stolen' from all over the place. 8)
Attachments
ODS Cracker.livecode.zip
Stack.
(4 KiB) Downloaded 64 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Getting the users country

Post by richmond62 » Fri Aug 11, 2023 1:46 pm

Of course the next question is how to get this:
-
SShot 2023-08-11 at 15.43.34.png
SShot 2023-08-11 at 15.43.34.png (3.06 KiB) Viewed 3071 times
-
rather than this

<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3"><office:scripts/><office:font-face-decls><style:font-face style:name="Arial Unicode MS" svg:font-family="&apos;Arial Unicode MS&apos;" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="PingFang SC" svg:font-family="&apos;PingFang SC&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="co1" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="0.889in"/></style:style><style:style style:name="ro1" style:family="table-row"><style:table-row-properties style:row-height="0.178in" fo:break-before="auto" style:use-optimal-row-height="true"/></style:style><style:style style:name="ta1" style:family="table" style:master-page-name="Default"><style:table-properties table:display="true" style:writing-mode="lr-tb"/></style:style></office:automatic-styles><office:body><office:spreadsheet><table:calculation-settings table:automatic-find-labels="false" table:use-regular-expressions="false" table:use-wildcards="true"/><table:table table:name="Sheet1" table:style-name="ta1"><table:table-column table:style-name="co1" table:number-columns-repeated="2" table:default-cell-style-name="Default"/><table:table-row table:style-name="ro1"><table:table-cell office:value-type="float" office:value="5" calcext:value-type="float"><text:p>5</text:p></table:table-cell><table:table-cell office:value-type="float" office:value="88" calcext:value-type="float"><text:p>88</text:p></table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell office:value-type="float" office:value="97" calcext:value-type="float"><text:p>97</text:p></table:table-cell><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>cheese</text:p></table:table-cell></table:table-row></table:table><table:named-expressions/></office:spreadsheet></office:body></office:document-content>

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Getting the users country

Post by stam » Fri Aug 11, 2023 3:21 pm

Hi Richmond,
I wasn't suggesting you import the actual spreadsheet file - that would be unusual and difficult.

I was suggesting that if you export TSV from the spreadsheet (or CSV), which is the common way this would be dealt with, that you would have difficulty importing that into a table in LC because of the extra returns within the fields... A problem that JSON would avoid...
Last edited by stam on Fri Aug 11, 2023 3:21 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Getting the users country

Post by richmond62 » Fri Aug 11, 2023 3:21 pm

SShot 2023-08-11 at 17.18.54.png
-
Well . . .

The final nut to crack is some sort of delimitation between the cell items.
Attachments
ODS Cracker.livecode.zip
Stack.
(3.81 KiB) Downloaded 55 times

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Re: Getting the users country

Post by andyh1234 » Mon Aug 14, 2023 4:13 pm

Code: Select all

   put JSONToArray(URL ("https://ipleak.net/json/")) into xArray
   put xArray["country_code"] into fld "ff"
   
Works fine in the desktop IDE but not is the iOS simulator.

I have broken it down and the getting of the URL works fine, it is the JSONToArray that does not seem to work.

Am I missing something, do I need to add an external to get it to work in the mobile environment.

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Getting the users country

Post by stam » Tue Aug 15, 2023 12:34 pm

You need the mergJSON external - it's cross platform including iOS, and anything you build with this will need this external.
Hopefully this will also run in the simulator, do let us know...

S.

PS: Alternatively you could use FerrusLogic's excellent PhotonJSON library (livecode stack rather than external but still needs to be included). This also includes a JSONtoArray function - see more details on their GitHub page https://github.com/Ferruslogic/PhotonJSON

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Re: Getting the users country

Post by andyh1234 » Wed Aug 23, 2023 5:42 pm

Thanks, I don't think I have that external, I am sure at one point in the past I had it but cannot find a download link for it now.

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Getting the users country

Post by stam » Wed Aug 23, 2023 11:27 pm

andyh1234 wrote:
Wed Aug 23, 2023 5:42 pm
Thanks, I don't think I have that external, I am sure at one point in the past I had it but cannot find a download link for it now.
I think it's included, you just need to reference it by selecting the inclusions manually?
Or if not just use PhotonJSON - it's a stack library so you'd need to include that stack.

Post Reply

Return to “iOS Deployment”