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.