Wednesday, 3 July 2019

Assembler emulator

Here it is an assembler x86 emulator wrote in Livecode by Andre Garcia:
You can download from here:: http://tinyurl.com/p48nhwd
There are 4 registers: ax, bx, cx, dx.
These are the commands;
  • GET - ask a number
  • PUT - shows ax register
  • MOV - copy the target register
    • MOV <target>, <register>
    • MOV <target>, <number>
  • CMP - compare registers
  • JA - jump if greater than
  • JB - jump if less than
  • JAE - jump if greater or equal
  • JBE - jump if less or equal
  • JNA - jump if not greater
  • JNB -jump if not less
  • JE -jump if equal
  • JNE -jump if not equal
  • JMP - jump!
  • XCHG - exchange 2 registers
  • ADD - add
  • SUB - subtract
  • AND - bitwise and
  • OR - bitwise or
  • XOR - exclusive or
  • CALL - call a  subroutine
  • RET - return from a  subroutine
  • HALT - stop the software
  • SETE - set 1/0 if equal
  • SETNE - set 1/0 if not equal
  • SETLE - set 1/0 if lower or equal
  • SETL - set 1/0 if lower
  • SETG - set 1/0 if greater
  • SETGE - set 1/0 if greater or equal
  • SETNLE - set 1/0 if not lower or equal
  • SETNL - set 1/0 if not lower
  • SETNGE - set 1/0 if not greater or equal
  • SETNG - set 1/0 if not greater


Tuesday, 2 July 2019

Menu builder


Menu builder is a tool in Livecode to create cool top menu:

Please not that on Mac it appears externally of the program:

Normal

On a Mac

The too in in the menu Tool -> Menu Builder:
On the left there are the main menu items, on the right the submenu of each item.
Dal menu builder potete aggiungere tutta una serie di effetti semplicemente usando il mouse, e le modifiche appariranno nel nome con un codice. This is the list of special chars and their meanings:
  • -   simple dash is a line divider
  • !c  this put a check before the menu item
  • !n this remove a check before the menu item
  • !r this put a list point before the item
  • !u this remove a list point before the item
  • & special char to call the item
  • / shortcat chara
  • ( rende il menu disabilitato
  • TAB to creat esubmenus
Fo examle this text
produce this:

You can use tags to change just what you see, but not the command; for example wiht multiple languages, you change only the tag. Example

Paste/V|Incolla





Monday, 1 July 2019

Creating PDF with links

Livecode permits you to print any part of your programs as a PDF (or on a real printer).
If you want, you can create a PDF with links. The command to use is print link.
For example on a window create a text (http://www.paypal.com) and the use Text-> Link menu. Like this:




For example the button code is:

on mouseUp
   set the printPaperSize to (item 3 to 4 of the rect of this stack)
   put the rect of field "example" into temp
   ask file "Save PDF as:" with "Example.pdf"   
   if it is empty then
      exit mouseUp
   end if
   open printing to PDF it   
   print card 1 of this stack   
   print link to URL "http://www.paypal.com/" with rect temp
   close printing
end mouseUp

This is the result in a PDF reader:


Thursday, 27 June 2019

Different types of rounding numbers

Rounding number is useful in so many applications, that I need to mention how i works in Livecode.
We have the following function:  round(), trunc(),  ceil(), floor().Let's see how they works with examplse.
Let's tart with round(), it can round to the nearest integer or to the number o decimal indicated by the second item:

put round(2.4) # it returns 2
put round(2.6) # it returns 3 
put round(2.712, 1) # it returns 2.7
put round(2.765, 1) # it returns 2.8

The function trubc() returns onl the integer part of the number:

put trunc(2.712) # it returns 2

If we need the the nearest integer more or equal the given number, you need ceil():

put ceil(2.2321) # it returns 3

If we need the the nearest integer less or equal the given number, you need floor():

put floor(2.712) # it returns 2

Sunday, 23 June 2019

Find and replace

A very understimated Livecode tool is the editor Find and Replace
In order to open Find and Replace window click on "Edit -> Find & Replace":



otherwise you can press  Ctrl+Shift+F.



This window permit you to find or replace anything wherever is in your code.

Programmers use find to double check if a mistyping lead to an error or to check other programmer work. Please note that find works only on saved program; if you type and you don't save, the text just typed is ignored.


Find and Relace window permits you to refine your search with these option:
  • simple text (all chars are interpreted as simple chars)
  • jolly chars, like asterisk
  • regular expressions
  • case insensitive or case sensitive. 
  • one of the words or all words
  • in what part of the program limit the research (stack, carc ,button current source, etc.9
Results list show where they are:



Clicking on one of the results, you'll be immediately in the part of the code.


Replace is incredibly amazing, you can change a name in all the program, without worrying to forget some part of the program. Livecode program are so evolute, that other competitor programming language have so many files spread across folders that you usually miss something and never change what the code.

Wednesday, 22 May 2019

Livecode 9.0.5 released!

The last version of livecode contains a lot of new features:

Infinity constant

The constant infinity has been added to the language in this release. As a result, the unquoted literal infinity is now reserved. Any existing uses of it should be quoted, as otherwise it will resolve to the floating point value representing infinity, rather than the string "infinity".

Math operation refactor

The math operations have been refactored to use common code for error checking. One of three different execution errors can now be thrown:"numeric: domain error" "numeric: range error (overflow)" "numeric: divide by zero". The error checking depends solely on the finiteness or otherwise of the operation's input(s) and output.
A domain error occurs when a math operation, given finite inputs, results in not-a-number (NaN) -this is the case when the function is not defined for the given inputs, for example acos(2); or the output does not exist in the extended real line (ℝ ∪ {−∞, +∞}), for example, sqrt(-1). A range error occurs when a math operation's output overflows given finite inputs, i.e. when the result is greater than the maximum value of a 64-bit floating point, for example 10^308 * 2.A divide by zero error occurs when a math operation causes division by zero either directly, for example 1/0 or 0^-1 or as part of its computation, for example 10 wrap 0. Math operations now do not throw execution errors when any of the inputs are non-finite, for example neither of (1^(-inf) + inf) / 2 = inf or sqrt(-inf) = NaN causes an execution error.

New container layer mode

Container layer mode support has been added to the accelerated rendering architecture.The container layer mode only has an effect on unadorned groups whose ancestors are alsocontainer layer mode unadorned groups.A container layer mode group provides a container for static and dynamic layers, allowing nestedgroups to also benefit from being cached for fast re-rendering.For more information, see the layerMode entry in the dictionary

Progress, isSecure and allowUserInteractinfeatures added to browserwidget

The message browserProgressChanged has been added to the browser widget to allow monitoring the progress of page loads.The property isSecure has been added to the browser widget to determine if the content of thecurrent URL has been loaded securely.The property allow UserInteraction has been added to the browser widget to control if the browser should respond to user input.See the dictionary for full documentation.

Deploy64-bit Windows standalones

You can now deploy 64-bit standalones for Windows. The Standalone Settings dialog now has a Windows x86 and a Windows x86_64 checkbox allowing you to choose to build either or both32-bit and 64-bit executables

New keyboardType field property

A new property has been added to fields to control the keyboard type displayed on the mobile keyboard.

NewAndroidArchitectures

Android builds now support four architectures. Previously android was built for armv6 only.Android is now built for armv7, arm64, x86 and x86_64.Checkboxes are included on in the Android standalone settings to choose which architectures toinclude in the build. When deploying your application via the Test button to a device the devicearchitecture will be detected and used even if not chosen in standalone settings.

New mobileSetKeyboardDisplay and mobileGetKeyboardDisplay handlers

A new command mobileSetKeyboardDisplay has been added to support a pan mode where the view is panned up if the currently focused field control is not visible when the keyboard is shown. Use mobileGetKeyboardDisplay to get the current mode. There are two modes supported:
  • over - the default where the keyboard displays over the stack
  • pan - the view is panned up the minimum amount required to ensure the foucused field isvisible

StaticlinkedcodelibrariesforiOSdevicebuilds

The standalone builder now supports .lcext compiled objects that link static libraries used by aLCB module to the module compiled as C++ using lc-compile's --forcebuiltins --outputauxc options. Additionally, the Using compiled librariessection of the Extending LiveCode guide has been updated to describe the creation of .lcextobjects

New layerClipRect control property

A new property 'layerClipRect' has been added to all controls. Use the layerClipRect property to clip an object's display to a rectangle. The clipping rectangleonly changes what part of the object is rendered, it has no effect on interaction; in particular,mouse events will still occur as they would without it being set

New log command and logMessage property

A new command (log) and global property (logMessage) have been added to allow an easy and low-cost method to disable or redirect script logs.The log command invokes the handler named by the logMessage as though the logMessage were directly written in the script. For backwards compatability the default value of the logMessage is log so any scripts that currently have a log handler will continue to work. To allow this log has been special cased as both a command name and a permitted handler name. If the logMessage is set to empty then the log command will not invoke any handler or evaluate any of the parameters in the argument list. In this example the log command will not be called with pInfo as loading resources whenthe uBuildMode of the stack is release

 on preOpenStack
  -- uBuildMode property set before building standalone 
  if the uBuildMode of this stack is "release" then 
   set the logMessage to empty 
  end if 
  loadResources 
 end preOpenStack 

 command loadResources 
   log "loading resources" 
 end loadResources 

 on log pInfo 
  -- unhandled put will go to system logs 
    put pInfo
 end log

New returnKeyType field property

A new property has been added to fields to control the return key type displayed on the mobile keyboard

Implement filter where clause

A new clause has been added to the filter command to filter where an expression evaluates to true. For example:
put "foo,bar,baz" into tList
filter items of tList where each begins with "b"  -- tList contains "bar,baz"

mobileSetKeyboardReturnKey on android

The mobileSetKeyboardReturnKey is now supported on android and theiphoneSetKeyboardReturnKey synonym is now deprecated

Accelerated DataGrid

The DataGrid has been updated to use the new container layer mode feature when running inform view mode.To take advantage of this, the datagrid must be at top-level or contained withing groups all havingcontainer layer mode set. It must have showBorder set to false, and the acceleratedRendering property must be enabled on the stack with appropriate compositor property settings. To get the maximum benefit from accelerated rendering, the behavior script for a row templateshould changing properties within the template unnecessarily. A new datagrid property minimal layout has been added. When this property is true, a rowtemplate will only receive the LayoutControl message if its data or its width or height haschanged as opposed to every time its rect changes (e.g. due to scrolling).

TreeViewwidget

The tree view widget now will automatically expand to reveal a row when it is selected. If scrollHilitedElementIntoView is not true then the scroll position will be adjusted to maintainthe currently visible top row. The tree view widget now has the ability to get and set the fold state of the selected element viathe hilitedElementFoldState property. Values are folded, unfolded, and leaf.Setting a value other than folded or unfolded will throw an error. Setting a value when nothing is selected or setting a value on a leaf node will have no effect. The autoFoldStateReset boolean property is added to allow the fold state to be reset when thearray data is set. Default value is false to match existing behavior. The tree view widget now has the ability to automatically select a new row when it is added. The tree view widget now has the ability to scroll the selected row into view. If true, this willhappen when setting the arrayData, setting the hilitedElement, and when adding a new row (when hiliteNewElement is true).Two properties have been added to achieve these options:
  • hiliteNewElement: either true or false
  • scrollHilitedElementIntoView: either true or false
The default values for both are false to match the behavior of previous versions of the widget. When selecting a row that is partially visible, the view will be adjusted so that the full row is visible. When changing the readOnly property, the view will only change position if the value is being setto true and the Add new elementrow is currently visible. The tree view widget now has the ability to get and set the fold state.One property has been added to achieve this option: foldState array. The fold state array is structured as follows: [key1] ["folded"] ["array"] [subkey1] ["folded"] [key2] ["folded"]


Mac Status Menu library

An mac status menu library has been added. Use the new library to create, delete and setproperties on a status menu. The menu's items property uses the familiar menu text formatfrom LiveCode menus

AndroidUtilitiesmoduleAndroidPermissionChecking

The ability to check Android permissions in LCB has been added to the android utility module. Use these handlers to check and request permissions before accessing resources (e.g. cameraaccess). The following handler have been added:
  • AndroidRequestPermission - Display a dialog requesting a given permission.
  • AndroidPermissionExists - Check to see if a given permission name is valid.
  • AndroidHasPermission - Check to see if a given permission has been granted. 

Just for Indy e Business versions

PDFWidget

A PDF widget has been implemented for all platforms with the exception of HTML5 and is available in LiveCode Business. The widget has a wide range of properties allowing you to alter the appearance of the widget, the way the user can interact with the document and providing details about the loaded document.

Android Barcode Scanning Widget

A new Android widget had been added that allows for scanning of barcodes using the device'scamera. Multiple barcodes can be detected in a single frame. Turning the guide on will set the widget tosingle detect mode, with only barcodes overlapping the guide being detected. Callbacks are sent on barcode detection and removal.See the dictionary for full details.
The barcode widget has the following properties:
  • device: The camera device to use.
  • previewWidth: The width of the camera's resolution.
  • previewHeight: The height of the camera's resolution.
  • previewFPS: The camera's frame rate.
  • overlayShowLabels: If labels should be displayed on top of each detected 
  • barcode.overlayShowRects: If rectangles should be displayed around each detected 
  • barcode.overlayShowGuide: If the scanning guide should be displayed.
  • overlayLabelColor: The color of any barcode labels .
  • overlayRectColor: The color of any barcode rectangles.
  • acceptedFormats: A list of barcode types to detect.
  • snapshotMode: If and when a snapshot should be taken of the barcode.
The barcode widget sends the following messages:
  • barcodeDetected: Sent when a new barcode is detected.
  • barcodeRemoved: Sent when a previously detected barcode is no longer in the frame.
  • barcodeClicked: Sent when a detected barcode has been clicked by the us

Android Barcode Library

A new Android library has been added that provides functionality for detecting barcodes inimages. The library defines the function barcodeLibraryDetect which takes an image and returns anarray of detected barcodes. See the dictionary for full details

Tuesday, 21 May 2019

Text margins

Default margins are 8 pixel from the border:
We can change them in many ways: with the property margins, all to a single value:

on mouseUp
   set the margins of field 1 to 0
end mouseUp


or with margins and all four different values:

on mouseUp
   set the margins of field 1 to 2,10,10,0
end mouseUp


Or with the single properties: topMargin, rightMargin , bottomMargin , leftMargin.