Skip to main content

Posts

Showing posts with the label string

Taking Random Values in Corona

Syntax for taking random numbers or values in corona has been given below. Download the code and try it... Syntax         math.random()          math.random( m )          math.random( m, n ) math.random() ---> a number between 0 and 1 math.random(m) ---> an integer between 1 and n (inclusive) math.random(m,n) ---> an integer between m and n (inclusive) math.random() ---> a number between 0 and 1 math.random(20) ---> an integer between 1 and 20 (inclusive) math.random(20, 40) ---> an integer between 20 and 40 (inclusive)

String Functions In Corona

Here is a list of string function which are very useful... string.byte() Returns the internal numerical codes of the characters in a string. string.char() Returns a string in which each character has the internal numerical code equal to its corresponding argument. string.find() Looks for the first match of a pattern in a string. If found, it returns the indices where the occurrence starts and ends; otherwise, returns nil. string.format() Returns a formatted string following the description given in its arguments. string.gmatch() Returns a pattern-finding iterator. string.gsub() Replaces all occurrences of a pattern in a string. string.len() Returns the length of a string (number of characters). string.lower() Changes uppercase characters in a string to lowercase. string.match() Extracts substrings by matching patterns in a string. string.rep() Replicates a string by returning a string that is the concatenation of n copies of a specified strin...

Android using Bundle for sharing variables

Sharing variables between Activities is quite important point during development time of your Application. This  Example suppose Activity1 from where you run up other Activity2 .   We gonna share variable myValue. In Activity1 : myValue="string values"; Intent intent = new Intent(MainActivity.this,NewClass.class); Bundle bundle = new Bundle(); bundle.putString("myValue", myValue); intent.putExtras(bundle); startActivity(intent); or Intent intent = new Intent(MainActivity.this,NewClass.class); intent.putExtra("myValue",AnyValue); startActivity(intent); In Activity2 : Bundle bundle = getIntent().getExtras(); String value= bundle.getString(“myValue“); or Intent intent=getIntent(); Bundle bundle=intent.getExtras(); String value= bundle.getString(“myValue“);

Types and Values In Corona

Lua is a dynamically typed language. This means that variables do not have types; only values do. There are no type definitions in the language. All values carry their own type. All values in Lua are first-class values. This means that all values can be stored in variables, passed as arguments to other functions, and returned as results. nil   — it usually represents the absence of a useful value. boolean   — represents two conditions 'false' or 'true' number   — represents real (double-precision floating-point) numbers. string   — represents arrays of characters. Lua is 8-bit clean: strings can contain any 8-bit character,   including embedded zeros. function   — click here to get more details table   — the sole data structuring mechanism in Lua.