Advertisement
Guest User

Untitled

a guest
Nov 30th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. -- longStr
  2.  
  3. --//////////////////////////////////////////////////////////////////////////////
  4. -- SETUP
  5. function setup()
  6. x = 1
  7. y = 2
  8.  
  9. str = nil
  10. url = "http://data.gc.ca/data/en/api/action/package_show?id=aba94801-fd1c-4897-a24f-64d4381c504a"
  11. http.request(url, handelResponse )
  12. end
  13.  
  14. --//////////////////////////////////////////////////////////////////////////////
  15. -- HANDEL HTTP RESPONSE
  16. -- Our callback function
  17. function handelResponse( data, status, headers )
  18. --print( status..' : '..data )
  19. str = data
  20. end
  21.  
  22. --//////////////////////////////////////////////////////////////////////////////
  23. -- DRAW
  24. -- This function gets called once every frame
  25. function draw()
  26. -- This sets a dark background color
  27. background(40, 40, 50)
  28.  
  29.  
  30. local pos = {WIDTH/2, HEIGHT/2}
  31. local size = {WIDTH, HEIGHT}
  32. local display = nil
  33. if str ~= nil then
  34. --DISPLAY STATS
  35. --================================================
  36. if displayed == nil then displayed = true --only show once
  37. print("------------------------------")
  38. print("type", type(str))
  39. print("length", str.len(str))
  40. print("------------------------------")
  41. print("String Received", str)
  42.  
  43. end
  44.  
  45. --Determin what text to display
  46. --================================================
  47. display = str
  48. display = string.sub(str, 1, 4000)
  49. ---------------------------------------------------
  50. --local search1,search1e = string.find(str, "Return")
  51. --local search2,search2e = string.find(str, "data")
  52. --display = string.sub(str, search1, search2e)
  53. end
  54.  
  55.  
  56. textWrapWidth(size[x]*0.9)
  57. textAlign(LEFT)
  58. if display ~= nil then
  59. text(display, pos[x], pos[y])
  60. else
  61. text("-- NO DATA --", pos[x], pos[y])
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement