Web access

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Web access

Post by Whytey » Thu Jan 16, 2014 8:09 pm

Hi I am having a bit of a problem getting access to a web database from my tablet (Samsung galaxy tab2) or mobile (Samsung galaxy ace), everything works perfectly on the laptop, most curious please help.

I look forward to hearing from you! :lol:

I'm using livecode version 6.5

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Web access

Post by Klaus » Thu Jan 16, 2014 8:43 pm

Hi Whytey,
Whytey wrote:...most curious please help.
shall we send some money or what? 8)

Come on, we need more info, what database, (parts of) the scripts etc...
e.g. did you check database access in the standalone builder settings?


Best

Klaus

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Web access

Post by Whytey » Thu Jan 16, 2014 9:34 pm

Hi Klaus, that'd be nice if you can make out a cheque to my home address :wink:

the database is the same one I've been struggling with all week pubmed although its looking good now thanks to you all!

code is

Code: Select all

command searchForums
   set the htmlText of field "Results2" to URL ("http://www.ncbi.nlm.nih.gov/pubmed/?term=" & urlEncode(the text of field Search))
end searchForums
but if its working nicely on the laptop can't be a code problem right? in the standalone application settings (android) the only box I checked is internet under application permissions it says minimum android version 2.2 froyo. I haven't put anything in Custom URL scheme, push Sender ID or Status bar Icon. In 'general' I clicked search for required inclusions when saving the standalone. I couldn't see anything to check in the tablet settings have I missed something?

Sorry for the lack of info :roll:

Thanks!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Web access

Post by jacque » Fri Jan 17, 2014 10:10 pm

Did you also enable the internet library in the General pane of standalone settings?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Web access

Post by Whytey » Fri Jan 17, 2014 11:20 pm

Hi Jacque, I've clicked on select inclusions for the standalone application in General and selected Geometry, Internet and Printing in the script libraries I also have the ask dialog and answer dialog boxes checked and remove all profiles on objects in the property profiles section of general. In general I just have internet selected in application permissions, nothing is in custom URL scheme is there anything else you can think of I haven't done? I'm on livecode version 6.5, I have also tried 6.15.

Thanks Jacque!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Web access

Post by jacque » Fri Jan 17, 2014 11:52 pm

That should do it. Sounds like you have the right things selected. You could temporarily break down the command into smaller pieces and test the result to see what the error is:

Code: Select all

put "http://www.ncbi.nlm.nih.gov/pubmed/?term=" & urlEncode(the text of field Search) into tURL
answer "URL is:" && tURL -- just to be sure it's right
put url tURL into tData
answer "Result is:" && the result
answer "Data is:" && tData
That should tell you if anything is going wrong, and maybe show a clue what the problem is. One or the other of those dialogs will probably be empty. It's a good idea to always test the result in your code anyway so that you can abort gracefully if something goes wrong. Your script could do this:

Code: Select all

put URL ("http://www.ncbi.nlm.nih.gov/pubmed/?term=" & urlEncode(the text of field Search)) into tData
if the result is not empty then -- error
  answer the result
else
  set the htmltext of fld "results2" to tData
end if
In-line error checking will save you lots of headaches.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Web access

Post by Whytey » Sat Jan 18, 2014 2:12 pm

Hi Jacque,

Very interesting, so I put in your code

Code: Select all

command searchForums
put "http://www.ncbi.nlm.nih.gov/pubmed/?term=" & urlEncode(the text of field Search) into tURL
answer "URL is:" && tURL -- just to be sure it's right
put url tURL into tData
answer "Result is:" && the result
answer "Data is:" && tData
end searchForums
I searched for McGrew MJ (this is one that does not work at all), the website was correct as I checked in pubmed and it brought down all the correct results together with the junk text, however my 5 boxes were blank so there is obviously a problem with parsing the data into the boxes; for some entries it works well but for others it does not work at all.

I have been trying to parse based on a line by line approach now, as I say this worked well for some entries as I was getting horribly confused with the skip approach and my code is

Code: Select all

on mouseUp
   searchForums 
  put fld "Results2" into tText
    put wordoffset("Results:",tText) into tStart
    put wordoffset("[Pubmed]",tText) into tEnd
    put word tStart to tEnd of tText into fld "Box1"
    put line 1 to "10" of fld "Box1" into fld "BoxA" of card "test"
    put line "11" to "22" of fld "Box1" into fld "BoxB" of card "test"
    put line 23 to 33 of fld "Box1" into fld "BoxC" of card "test"
    go card "test"
    end mouseUp

command searchForums
set the htmlText of field "Results2" to URL ("http://www.ncbi.nlm.nih.gov/pubmed/?term=" & urlEncode(the text of field Search)) 
end searchForums

You mentioned there might be a better way to parse this data if the PMID: was on the same line. Could you possibly explain your thoughts on this? If I search McGrew MJ, these are the five results on pubmed I want to bring down

Results: 1 to 20 of 23
Select item 24223709
1.
A novel piggybac transposon inducible expression system identifies a role for akt signalling in primordial germ cell migration.
Glover JD, Taylor L, Sherman A, Zeiger-Poli C, Sang HM, McGrew MJ.
PLoS One. 2013 Nov 4;8(11):e77222. doi: 10.1371/journal.pone.0077222.
PMID: 24223709 [PubMed - in process] Free PMC Article
Related citations
Select item 22586100
2.
Efficient genetic modification and germ-line transmission of primordial germ cells using piggyBac and Tol2 transposons.
Macdonald J, Taylor L, Sherman A, Kawakami K, Takahashi Y, Sang HM, McGrew MJ.
Proc Natl Acad Sci U S A. 2012 Jun 5;109(23):E1466-72. doi: 10.1073/pnas.1118715109. Epub 2012 May 14.
PMID: 22586100 [PubMed - indexed for MEDLINE] Free PMC Article
Related citations
Select item 21124737
3.
Characterisation and germline transmission of cultured avian primordial germ cells.
Macdonald J, Glover JD, Taylor L, Sang HM, McGrew MJ.
PLoS One. 2010 Nov 29;5(11):e15518. doi: 10.1371/journal.pone.0015518.
PMID: 21124737 [PubMed - indexed for MEDLINE] Free PMC Article
Related citations
Select item 20220842
4.
Somatic sex identity is cell autonomous in the chicken.
Zhao D, McBride D, Nandi S, McQueen HA, McGrew MJ, Hocking PM, Lewis PD, Sang HM, Clinton M.
Nature. 2010 Mar 11;464(7286):237-42. doi: 10.1038/nature08852.
PMID: 20220842 [PubMed - indexed for MEDLINE]
Related citations
Select item 20184756
5.
Functional conservation between rodents and chicken of regulatory sequences driving skeletal muscle gene expression in transgenic chickens.
McGrew MJ, Sherman A, Lillico SG, Taylor L, Sang H.
BMC Dev Biol. 2010 Feb 25;10:26. doi: 10.1186/1471-213X-10-26.
PMID: 20184756 [PubMed - indexed for MEDLINE] Free PMC Article
Related citations

Thanks Jacque for all your help! Seems like this is a tougher task than I thought :shock:

Look forward to hearing from you! :D

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Web access

Post by Whytey » Sat Jan 18, 2014 4:42 pm

Ok so by taking the parsing part out and just having the code

Code: Select all

on mouseUp
   searchForums 
   put fld "Results2" into tText
   answer "Data is:" && tText
end mouseUp

command searchForums
set the htmlText of field "Results2" to URL ("http://www.ncbi.nlm.nih.gov/pubmed/?term=" & urlEncode(the text of field Search)) 
end searchForums
I can get a nice list of papers coming down on my tablet as well as on the computer so doesn't seem to be an internet problem rather a parsing problem. I now need to find a way to parse the top five entries in the tText, any ideas?

This is exactly what the tText box that comes up looks like on my tablet (all entries now come up)

Data is: stem cells-PubMed Mobile

Search

Search Results (199871)
Filter by Free Full Text or Review

Biologically Based Therapy for the Intervertebral Disk: Who Is the Patient?
Erwin WM, et al. Global Spine J. 2013
Combined Transplantation of Human Neuronal and Mesenchymal Stem Cells following Spinal Cord Injury.
Park DY et al. Global Spine J. 2013.
Stem cells and biological approaches to treatment of wrist problems.
Chong AK et al. J Wrist Surg. 2013
The role of fat grafting in the treatment of posttraumatic maxillofacial deformities.
Arcuri F et al.
Craniomaxillofac Trauma Reconstr. 2013
Cell-based therapies for regenerating bone.
Goodman SB et al.
Minerva Ortop Traumatol. 2013
Amide-Type Local Anesthetics and Human Mesenchymal Stem Cells: Clinical Implications for Stem Cell Therapy.
Dregalla RC et al. Stem Cells Transl Med. 2014
Mesenchymal Stromal Cells Mediate Aspergillus Hyphal Extract-Induced Allergic Airway Inflammation by Inhibition of the Th17 Signaling Pathway.
Lathrop MJ et al.
Stem Cells Transl Med. 2014
Effect of Human Wharton's Jelly Mesenchymal Stem Cell Paracrine Signaling on Keloid Fibroblasts.
Arno AI et al.
Stem Cells Transl Med. 2014
Human Bone Marrow-Derived Mesenchymal Stem Cells Display Enhanced Clonogenicity but Impaired Differentiation With Hypoxic Preconditioning.
Boyette LB et al. Stem Cells
Transl Med. 2014
Potential Application of Temozolomide in Mesenchymal Stem Cell-Based TRAIL Gene Therapy Against Malignant Glioma.
Kim SM et al.
Stem Cells Transl Med. 2014

A Page 1 of 19988A Next
Standard Pubmed
NIH/NLM
NCBI
Copyright
Help

As you can see its a stream of text so if we can find a way to separate this stream into the boxes that would be brilliant!

I look forward to hearing from you!

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Web access

Post by Thierry » Sat Jan 18, 2014 5:35 pm

Whytey wrote:I can get a nice list of papers coming down on my tablet as well as on the computer so doesn't seem to be an internet problem rather a parsing problem. I now need to find a way to parse the top five entries in the tText, any ideas?

This is exactly what the tText box that comes up looks like on my tablet (all entries now come up)

Biologically Based Therapy for the Intervertebral Disk: Who Is the Patient?
Erwin WM, et al. Global Spine J. 2013
.....
Hi Whytey,

Here is a code snippet to parse and split the 5 first entries.
( as long as I understood what an entry is. )

Code: Select all

on Doit
   put fld 1 into Txtsource -- search text result
   put empty into  fld 2 -- 5 splitted first entries
   
   -- need to get rid of the first lines
   -- let this as an exercice to you as I don't know
   -- what are the common lines from different searchs
   
   -- I assume the above works
   -- the 1st line then is : Biologically Based Therapy.....
   
   repeat with i=1 to 5
      -- from the start of the text, look for any number of lines
      -- with the end of last line finishing by a 4 digits
      -- followed or not by a dot and may be some extra space before the return
      if matchChunk( Txtsource, "(?ms)^(.*?\d{4}\.?\s*\n)",pS,pE) then
         put char pS to pE of Txtsource into pubMedEntry
         delete char pS to pE of Txtsource
         put "------ N" &i &cr& pubMedEntry after fld 2
      else
         answer "Sorry, not 5 five entries"
         exit repeat
      end if
   end repeat
end Doit
You have to cook some code to redirect the entries into different fields..

HTH,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Web access

Post by jacque » Sat Jan 18, 2014 9:32 pm

The method I had in mind for simpler parsing looks like it won't work, because each text sample you've posted is a little different. Unless there is consistency with the data you're retrieving, parsing is going to be difficult. Computers are so literal. The first examples were defined by "select" and "PMID", another example had numbered entries, and the last one is all a single text block without any of the details (it only contains the article name, author, and date.)

Thierry, our regex guru, has provided a good way to parse your last example where the only marker for the end of an entry is a year. For the numbered entries, I'd probably look for an integer followed by a period to find the beginning of each entry. We already talked about parsing the earlier examples with "select" and "PMID" to define the start and end points.

So it's messy. If you can find a way to always get the data formatted consistently (maybe change the search query?) then the task would be much easier.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Web access

Post by Simon » Sun Jan 19, 2014 3:35 am

Hi Whytey,
I thought I'd join in the fun with my simple minded approach;
Select item.zip
LC 6
(29.58 KiB) Downloaded 221 times
If your 5 examples are correct to the letter then this might not work.
Draw backs, each entry ends up on a single line of it's own (not pretty). And like Jacque I looked for specific words so only through testing will you know how robust it is.

At any rate, hopefully this will allow you to see the data w/o all the noise.

Simon
Edit: I tested this using http://www.ncbi.nlm.nih.gov/pubmed/?ter ... germ+cells
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Whytey
Posts: 31
Joined: Fri Jan 10, 2014 6:40 pm

Re: Web access

Post by Whytey » Sun Jan 19, 2014 11:06 pm

Hi all, thank you so much for your help!! So with a whole weekend of fiddling around I've sorted it :o :D :mrgreen: !! So on the laptop you get a whole stream of junk text coming down with the entries but when I entered your code Jacque to test everything was working ok, I found things looked a lot neater and more organised on the tablet and mobile. So like you suggested Thierry I deleted the first 7 lines and after fiddling around (and trying to learn a little about Regex so I could understand your complicated code Thierry!) it seemed that each entry coming down on the tablet was actually on a single line (amazing!!) so once I realised that it was pretty simple to sort into the boxes no complicated parsing needed!! Simon, Klaus thank you so much for your suggestions I've learnt a huge amount on livecode from you all and I know I'm gonna need your codes in the future!! Super happy!! :mrgreen:

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Web access

Post by jacque » Mon Jan 20, 2014 4:25 pm

Yay! Sometimes the reward is in the journey. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply