Page 1 of 1

How to write a script to create an HTML page?

Posted: Sun Feb 08, 2015 5:26 am
by andy60
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.

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

Posted: Sun Feb 08, 2015 7:26 am
by Simon
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")

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

Posted: Sun Feb 08, 2015 11:36 am
by andy60
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

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

Posted: Sun Feb 08, 2015 7:51 pm
by Simon
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

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

Posted: Mon Feb 09, 2015 2:06 am
by andy60
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.