Undocumented and Semi-documented lingo

The following describes some useful undocumented and semi-documented lingo. Being undocumented, they are not officially supported. But for the most part, they seem to work fine.

scriptsyntax property

Members have a .scriptsyntax property which can be either #lingo (which seems to be the default if you create a new member dynamically) and #javascript. It can be read and set.

Using max and min with lists:

Lingo's max() and min() functions work with lists (though they do not do a 'deep' search of nested lists). Examples:

aList = [2,3,4,1]

put aList.max()

-- 4

put aList.min()

-- 1

aList = ["Luke", "woz", "ere", "2002"]

put aList.max()

-- "woz"

put aList.min()

-- "2002"

-- mixing up types

p1 = #zz

p2 = #aa

aList = [3, p1, p2, ["z", "aa", 2.91, 1, 3], "bar" ]

put aList.max()

-- #zz

put aList.min()

-- ["z", "aa", 2.9100, 1, 3]

Note: the last example demonstrates that symbols are sorted as strings, not by their integer value (the #aa symbol would have a higher integer value since it is made after the #zz symbol).

Getting a random number within a range:

The random function can take two parameters to return a value within a range. For example, the following lingo will return a random number between -5 and 5:

put random(-5,5)

Note however, there seems to be a bug if both numbers in the range are negative, and the first number is closer to zero than the second.

put random(3,3) -- works

put random(6,3) -- works (even though first number is > than second)

put random(-3,3) -- works

put random(-6, -3) -- works

put random(-3, -6) -- DOES NOT WORK (returns some massive integer)


The floodfill() command can be used to - 'flood fill' a contiguous region of colour (like the paint bucket tool). Apparently it is buggy with small regions.

img = image(9,9,24)

img.fill(img.rect, rgb(0,255,0))

img.draw(point(0,4), point(10,4), [#ShapeType: #Line, #Color: rgb(0,0,0)])

img.floodfill(0,0,rgb(255,0,0)) --> fill top half with red

tmp = new(#bitmap)

tmp.image = img

Using the dither option with copypixels.

The copypixels command can accept an option #Dither property. The two valid values for this property that I know of are 1215 and 1969.

anImage.copyPixels(img, aRect, aRect, [#dither:1215])

anImage.copyPixels(img, aRect, aRect, [#dither:1969])

fontMember.fontList() and fontMember.outlineFontList().

These two font xtra functions can be used to return a list of installed fonts. For example:

on GetFontList ()

  fontMember = new(#font)

  theFontList = fontMember.fontList()

  erase fontMember

  return theFontList


The commandLine (Windows and OSX only)

You can use the undocumented the commandLine to get startup parameters of a projector. There is a helpful article on MXDJ on using the command line to create double-clickable documents for a projector.

Using atan with two parameters.

Carsten Henssinger provided this tip:

the atan can also take 2 arguments (the opposite leg and the adjacent leg), thus working like the C atan2 function. This protects from dividing by zero (which can happen if you divide the opposite leg by the adjacent leg) and also returns the right angle in the right quadrant without having to do a distinction of cases

setContentsAfter and setContentsBefore

The setContentsAfter() and setContentsBefore() methods of the Text Xtra can be used to insert a string into a text member but preserve the formatting of the existing content of the textmember.

Using the .stretch property to reset sprite dimensions

If, at runtime, you import an image into a sprite on the stage (by setting the filename of the member of that sprite), the image can get resized to match the dimensions of the sprite (although the sprite hasn't changed size, it is 'stretched' or 'squashed' relative to the new source image). If you set the .stretch property of the sprite to FALSE, it will display the image at the correct dimensions. Thanks to James Newton for describing this tip on Direct-L

First published 21/03/2005