Friday, June 20, 2014

Naming Conventions

Pre-Conditions

This tutorial is written explicitly for LiveCode 6.6.2 Stable and might not work with other versions. The tutorial will not be updated!

Namespace

LiveCode does currently not have anything like a namespace as found in in C or PHP. There are two different ways how you can handle this.

Possibility 1

ee = first and last letter of company name

Player = what the substack does

Example: eePlayerStart, eePlayerStop, eeDbGet, eeDbInsert

Possibility 2

Since a few month I've started with a new naming convention with dots.

ee = first and last letter of company name

player = what the stack/library does

playVideo = method name

Example:

  • ee.player.playVideo
  • ee.sql.insert
  • ee.couchdb.createDocument

This naming convention does not clash with the Livecode engine. I've asked my Account Manager at Livecode and got positive feedback by the core team.

 

Variable Prefixes

The variable prefixes have been defined as best practice in the comprehensive manual that comes with LiveCode which you can find within the install directory.

Prefix Variable Type Example
g Global Variable gMyVar
s Script Local Variable sMyVar
t Handler Local Variable tMyVar
p Parameter pMyVar
k Constant KMYVAR
 

Tool Prefixes

These are my personal prefixes for the tool names.
Prefix Variable Type Example
btn Button btnSave
lbl Label lblName
fld Text Field fldName
chb Check Box chbName
cob Combo Box cobName
rdb Radio Button rdbName
lst Scrolling List lstName
mnu Option Menu mnuName
tab Tab Panel tabName
img Image Area imgName
tbl Basic Table tblName
dg DataGrid dgName

LiveCode and OOP

With some small scripts you can turn your way of writing applications in LiveCode in to full OOP (object oriented programing).

This article explains the details.

Monday, June 16, 2014

Install LiveCode Community Server 6.6.2 on MacOS X

Pre-Conditions

This tutorial is written explicitly for LiveCode 6.6.2 Stable and might not work with other versions. The tutorial will not be updated!

Create Directories and copy community server directory

Go in to the user directory and create the Sites and cgi-bin folder:

cd ~/
mkdir Sites
mkdir Sites/cgi-bin
Copy the LiveCode Directory that you downloaded and unzipped over to the cgi-bin directory:
cp -R ~/Downloads/LiveCodeCommunityServer-6_6_2-Mac ~/Sites/cgi-bin/livecode662

Create Apache Configuration in user directory

Edit /etc/apache2/users/your_mac_user.conf file and add following configuration:

<Directory "/Users/your_mac_user/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
AddHandler livecode-script .lc
Action livecode-script /livecode-cgi/livecode-community-server
</Directory>
<Directory "/Users/your_mac_user/Sites/cgi-bin/livecode662/">
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
ScriptAlias /livecode-cgi/livecode-community-server /Users/your_mac_user/Sites/cgi-bin/livecode662/livecode-community-server

Create file ~/Sites/test.lc for testing:

<html>
<head>
<title>My LiveCode Server Test Page</title>
</head>
<body>
<h1>My LiveCode Server Test Page</h1>
<?lc
put "<p>Hello World! from LiveCode Server</p>"
put "<p>The date is" && the date & "</p>"
?>

The Apache Webserver is installed by default on MacOS X. To start Apache you can type following command:

sudo apache2ctl start

Once finished try logging in over following URL: http://127.0.0.1/~your_mac_user/

Troubleshooting

  • Make sure that the directories are "chmod 755" within the cgi-bin folder.
  • Make sure that the slashes at the end of the directory pathes are present in the user apache conf script.

Some notes on Yosemite

After upgrading to Yosemite I had to do following:

In /etc/apache2/httpd.conf - Comment all modules except:

  • LoadModule authz_host_module libexec/apache2/mod_authz_host.so
  • LoadModule authz_core_module libexec/apache2/mod_authz_core.so
  • LoadModule access_compat_module libexec/apache2/mod_access_compat.so
  • LoadModule mime_module libexec/apache2/mod_mime.so
  • LoadModule log_config_module libexec/apache2/mod_log_config.so
  • LoadModule log_debug_module libexec/apache2/mod_log_debug.so
  • LoadModule log_forensic_module libexec/apache2/mod_log_forensic.so

In /etc/apache2/extra/httpd-userdir.conf - Uncomment following line:

  • Include /private/etc/apache2/users/*.conf

Do a restart:

apachectl restart

Development Frameworks

RevIgniter - Full blown MVC Framework - Use with TextMate 2.0-Alpha for Color Coding
RevSpark - Minimal Web Framework - Use with TextMate 2.0-Alpha for Color Coding