Code Example

Dynamic Result

1
## Display a simple text string
put "Hello Word"
Hello World
2
## Repeat (count)
## Build a list based on the count
repeat with x = 1 to 5
   put "Line" && x & "<br />"
end repeat
Line 1
Line 2
Line 3
Line 4
Line 5
3
## Mathematical Functions
## Calculate the area of a circle
put 5 into tRadius
put pi & (tRadius * tRadius) into tArea
put round(tArea, 2) into tArea
put tArea
78.54
4
## Strip a filename off a URL string
put "http://serversamples.livecode.com/basic.lc" into tURL
set the itemDel to "/"
delete the last item of tURL
put tURL
http://samples.on-rev.com
5
## Generate the 10 times table
put "<table cellpadding='2'>"
repeat with x = 1 to 10
   put "<tr>"
   repeat with y = 1 to 10
      put "<td>" & (x * y) & "</td>"
   end repeat
   put "</tr>"
end repeat
put "</table>"
12345678910
2468101214161820
36912151821242730
481216202428323640
5101520253035404550
6121824303642485460
7142128354249566370
8162432404856647280
9182736455463728190
102030405060708090100
THE BASICS
Basic LiveCode web scripting

Let's start by looking at the basics of using LiveCode to script a website. LiveCode can be embedded into a webpage in much the same was as other web scripting languages such as PHP or ASP. When a visitor to your website loads a page containing LiveCode code, the LiveCode server engine executes any code it finds. All that you have to do is place your code snippets in between special tags:

<?lc -LiveCode Code Here- ?>

Those who have built a website in PHP or ASP will be familiar with this sort of scripting. LiveCode follows the same structure as other web scriting languages but allows you to do it in LiveCode! We have provided a number of very basic examples and the results they produce. You can start experimenting right away by signing up for your LiveCode Hosting account at https://livecode.com/hosting.