Getting the users country
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 9446
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Getting the users country
Well: there's a thought:
https://lessons.livecode.com/m/2592/l/126625-zip-tool
I wonder if THAT will 'unfold' an .ods file?
https://lessons.livecode.com/m/2592/l/126625-zip-tool
I wonder if THAT will 'unfold' an .ods file?
Re: Getting the users country
If the ODS file is in fact a ZIP archive in disguise, that will do the trick!
-
- Livecode Opensource Backer
- Posts: 9446
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Getting the users country
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.
-
- Livecode Opensource Backer
- Posts: 9446
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Getting the users country
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.
Bits 'stolen' from all over the place.
- Attachments
-
- ODS Cracker.livecode.zip
- Stack.
- (4 KiB) Downloaded 94 times
-
- Livecode Opensource Backer
- Posts: 9446
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Getting the users country
Of course the next question is how to get this:
- -
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:experimentalxmlns:loext:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns1.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:xmlns1.0" office:version="1.3"><office:scripts/><office:font-face-decls><style:font-face style:name="Arial Unicode MS" svg:font-family="'Arial Unicode MS'" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="PingFang SC" svg:font-family="'PingFang SC'" 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>
- -
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:experimentalxmlns:loext:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns1.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:xmlns1.0" office:version="1.3"><office:scripts/><office:font-face-decls><style:font-face style:name="Arial Unicode MS" svg:font-family="'Arial Unicode MS'" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="PingFang SC" svg:font-family="'PingFang SC'" 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>
Re: Getting the users country
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...
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.
-
- Livecode Opensource Backer
- Posts: 9446
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Getting the users country
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 89 times
Re: Getting the users country
Code: Select all
put JSONToArray(URL ("https://ipleak.net/json/")) into xArray
put xArray["country_code"] into fld "ff"
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.
Re: Getting the users country
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
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
Re: Getting the users country
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.
Re: Getting the users country
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.