How to write a script to create an HTML page?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andy60
Posts: 25
Joined: Sun Jan 18, 2015 6:51 pm
Location: Rome, Italy
Contact:

How to write a script to create an HTML page?

Post by andy60 » Sun Feb 08, 2015 5:26 am

dear friends, i have the following Gambas3 code (only partial code). With this code a create an html page:

Code: Select all

  hFile = Open Application.Path & "/test.html" For Create
  Print #hFile, "<!--"
  Print #hFile, "You are free to copy and use this sample in accordance with the terms of the"
  Print #hFile, "Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)"
  Print #hFile, "-->"
  Print #hFile, ""
  Print #hFile, "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
  Print #hFile, "<html xmlns='http://www.w3.org/1999/xhtml'>"
  Print #hFile, "<head>"
  Print #hFile, "<meta http-equiv='content-type' content='text/html; charset=utf-8'/>"
  Print #hFile, "<title>"
  Print #hFile, "test"
  Print #hFile, "</title>"
if a write the following code i can't create any html page, the variable strip my code:

Code: Select all

on mouseUp 
   local myVar
   open file specialFolderPath("desktop") & "/myData.html" for write -- creates a file for Revolution to write to
   put "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>" &  CR into myVar
   put myGoo into field "Field1"
   write myVar to file specialFolderPath("desktop") & "/myData.html" -- writes the text placed in the local variable into the open text file we created
   close file specialFolderPath("desktop") & "/myData.html" -- closes/saves the text file containing the text form the field/local variable into a text file on the desktop
end mouseUp
Have you some help for me? Thx for all.
Andy Bertini
Linux: Mint 17.1 Cinnamon - Gambas 3.6.2 - Gridbox 2.99.174 patched
Mac: OSX Yosemite - Livecode Community 7.0
Blog mzSoftware: http://crmforce.netsons.org/myzone
Email: and.bertini@gmail.com

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

Re: How to write a script to create an HTML page?

Post by Simon » Sun Feb 08, 2015 7:26 am

Hi Andy,
Go get this stack;
http://forums.livecode.com/viewtopic.ph ... es#p100173
Stick this into it

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
test
</body>
</html>
Press the button and... whaoo
Copy that and in your stack

Code: Select all

put (all the data from above) into url ("file:"specialFolderPath("desktop") & "/myData.html")
Simon
Edit; oooops! should have been

Code: Select all

put (all the data from above) into url ("file:" & specialFolderPath("desktop") & "/myData.html")
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

andy60
Posts: 25
Joined: Sun Jan 18, 2015 6:51 pm
Location: Rome, Italy
Contact:

Re: How to write a script to create an HTML page?

Post by andy60 » Sun Feb 08, 2015 11:36 am

Simon wrote:Hi Andy,
Go get this stack;
http://forums.livecode.com/viewtopic.ph ... es#p100173
Stick this into it

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
test
</body>
</html>
Press the button and... whaoo
Copy that and in your stack

Code: Select all

put (all the data from above) into url ("file:"specialFolderPath("desktop") & "/myData.html")
Simon
Edit; oooops! should have been

Code: Select all

put (all the data from above) into url ("file:" & specialFolderPath("desktop") & "/myData.html")
thx Simon, this program is very useful, i made the same process hand by hand :D ....
the only problem is to replace the internal character " in every line with character '

from:

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
to

Code: Select all

<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
great!!!! thx
Andy Bertini
Linux: Mint 17.1 Cinnamon - Gambas 3.6.2 - Gridbox 2.99.174 patched
Mac: OSX Yosemite - Livecode Community 7.0
Blog mzSoftware: http://crmforce.netsons.org/myzone
Email: and.bertini@gmail.com

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

Re: How to write a script to create an HTML page?

Post by Simon » Sun Feb 08, 2015 7:51 pm

Hi Andy,
Glad it helps.
Dreamweaver created that page with " (quote/double quote) not ' (apostrophe/single quote). Why do you use the single quote?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

andy60
Posts: 25
Joined: Sun Jan 18, 2015 6:51 pm
Location: Rome, Italy
Contact:

Re: How to write a script to create an HTML page?

Post by andy60 » Mon Feb 09, 2015 2:06 am

Simon wrote:Hi Andy,
Glad it helps.
Dreamweaver created that page with " (quote/double quote) not ' (apostrophe/single quote). Why do you use the single quote?

Simon
Single quote internally works Well when creating an http page with code.

example: string "this is a 'test'" can't do this output: "this is a "test"" or
"This is a" & "test"

The reason is my Gambas code at the top of the page. I'm porting my software to livecode.
Andy Bertini
Linux: Mint 17.1 Cinnamon - Gambas 3.6.2 - Gridbox 2.99.174 patched
Mac: OSX Yosemite - Livecode Community 7.0
Blog mzSoftware: http://crmforce.netsons.org/myzone
Email: and.bertini@gmail.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”