Further Market
  • Essentials

    • Foreword
    • What is FM Script ?
    • The philosophy and benefits of FmScript
    • What you will learn
  • Recall

    • Internet: who? what? What is that?
    • Further market and FMScript
    • The compiler
  • Download
  • Getting started

    • Installation
    • Create a business account
    • Connect to the PC application
    • Create your first applet
    • Create your first web applet
    • Compiler view
  • Basics

    • basic rules
    • Reserved keywords
    • The Syntax
    • Coding Style
    • comments
    • Variables, constants, and data types
    • Convertion of types
    • Conditions and loops
  • Functions

    • Create a Menu
    • Create input field (Input2)
    • Create a QR Code
    • Scan a QR Code
    • Strings functions
    • Array functions
    • Date Time functions
    • Mathematics functions
    • JSON functions
    • XML functions
    • Call Http request
    • Manipulate Sessions
    • Financial functions
    • Notifications
    • Bleutooth Printer
  • Demos

    • Advanced Inputs
    • Call http Request
    • loops and conditions
    • Menu inputs
    • Array items count
    • Simpe for
    • simple select count Sql Query
    • Date and Time picker form
    • Get credit balance
    • is valid city
    • user info from phone number
    • get country and city from form
    • simple ussd link switch
    • charge user credit
    • simple message box
    • user entry code
    • get users relations
    • my external payements collected
    • call google Map
    • in App direct publish
    • Geo location
    • Charts
    • menu with hints
    • call system Messenger
    • user start code
    • In call Gallery
    • credit card payment Request
    • MTN CMR Airtime Product Subscription
    • MenuItemAddContacts
    • AJax and FM Input
    • Input2
    • MenuItemAddRichMedias
    • MenuItemAddTagsItems2
    • BlinBlin Menu + javascript
    • GENERAL ALERT MESSAGE WITH JSON OPTIONS
    • Barcode
  • databases

    • CRM
    • External Payments
    • Bills
    • Sales
    • Games
    • Applets
    • Payments Gateway
    • Manipulate Select Queries
  • APIs

    • Further Markey Pay button integration
    • Mobile Money cash collector
    • Bill Api
    • API PUBLISH PRODUCT
    • Sale Api
    • SMS Api
  • Advanced

    • Actions scheduler
    • Events settings
  • USSD CAMEROON

Learn the basics of FM Script

  • Basic rules
  • Reserved keywords
  • Syntax
  • Coding style
  • Comments
  • Variables, constants, and data types
  • Cast and type conversion
  • Conditions and loops

 

Basic rules

All statements end with a semicolon. the point is used only once times per unit to mark the end. We can write several instructions on the same line. An instruction block is delimited by the « (» and «) »instructions.

Reserved keywords

Denomination Description
VAR Used for creating variables
ExternalFunctionParameters System variable containing the parameter value of a function.
SessionEntryCode System variable containing the value as a parameter of a function.
ExternalFunctionParametersWebPost This variable will contain the send parameters by POST has a script on FM
GotoUssdCode Redirects the user to a terminal address provided.
EXIT Stop the execution of instructions in a script
AND / OR Logical test between two expressions
FOR…… DO / WHILE…. DO Reserved for loops
IF / ELSE Conditional test
USER_Connection_GUI Defines the active terminal initialized in a user.
0 : Native Terminal (USSD).
1 : Graphic Terminal (web, Android, Ios)

Syntax

  • The FmScript ignores the case (lowercase / uppercase).
  • A line of code can be written on multiple lines.
  • The decimal point is the point.

Coding style

Here are some tips to make the code more readable:

  • Structure and comment on the different blocks of your source code ;
  • format the source code according to the standard good impression : indentation with two spaces or using the keyboard tab key for each block of code.This format is used in code demos fmscript

Comments

Comments are annotations made by the developer to explain the functioning of a script, an instruction or even a group of instructions. comments do not hinder the execution of a script.
There are two types of comments: comment on a line and multiline comments.

// Comment on one line
/* Comments on several lines */
            

Note: No compilation directive is implemented yet on comments Fmscript at the time this documentation is written (02/2019). the text put in comment will be just considered a raw element ignored during compilation.

 

Variables, constants, and data types

The declaration of a variable is made in a particular clause of the program, identified by the key word VAR. The constraints of formation of an identifier are: only the first 63 characters are taken into account, accented characters are forbidden, the difference is lower / upper case not taken into account, it must start with a letter or underline. It is possible to declare several variables of the same type in one line, each being separated by a comma.

Example:

VAR Result      : String ;
VAR GotoUssdCode : String ;
VAR Amount      : Double ;
VAR i,j         : Integer ;


// Redirect the user to his balance
GotoUssdCode := '*fm*21#';
Result     := 'Hello World' ;
Exit ;

 

The dialog box ShowMessage()

ShowMessage() is a simple statement, called function, that displays a dialog box containing a message. This message is placed between single quotes, even placed between the parentheses of the function ShowMessage()

Example:

                
VAR Result: String ;
ShowMessage('Hello World');
Exit;
                
            

Scope of a variable
At the script level, the variables are local to the script where they are declared and are stored in the stack segment. Sharing of data between scripts is done through sessions (we'll talk about it later).

Data types
Basic types are:

  • INTEGER :Integer
  • STRING : Character
  • DOUBLE : Float
  • BOOLEAN : contains the True or False values

 

There are different system routines for the management of ordinal types:

Routine Role
Pred Returns the predecessor of the argument in the order determined by the type of given


Example:

                
VAR Result: String ;
VAR i,j,k: Integer ;
//----  routine 
K := PRED(5); // K vaut 4
ShowMessage(' K = '+IntTOStr(K)) ;
Exit ;
                
            

 

Cast and type conversion

To assign a variable to another variable of another type it is necessary to use the cast (Casting). In FM script, it is possible to use a system type conversion routine:

Routine Role
Round Converts the value of a real type to that of an integer type, rounding its value
IntToStr Converts a number to a string
StrToInt Converts a string to a number, displaying an error if the string is incorrect
FloatTOStr Convert a Float to a String
StrToFloat Convert a String to a Float


Fmscript integrates two other stunning cast functions: StrToArray and ArrayToStr. These take two instead of one parameter like the others.

StrToArray(ArrayName : String, StringName : String, Delimiter : String);
ArrayToStr(ArrayName : String, ADelimiter : String);
             

Example 1:

VAR Result       : String ;
VAR GotoUssdCode : String ;
VAR Amount       : Float ;
VAR i,j          : Integer ;


// Redirect the user to his balance
GotoUssdCode := '*fm*21#';
I := StrTOInt('25') ;
ShowMessage(' I = '+IntTOStr(I)) ;
Exit ;
       

 

Example 2:

VAR Result      : String ;
VAR GotoUssdCode : String ;
VAR ValueStr    : String ;
VAR i,j         : Integer ;


// Redirect the user to his balance
GotoUssdCode := '*fm*21#';


// Initial String
ValueStr := 'FM Script is the Best';


// Convertion of our string into a table named ArrayName
StrToArray('ArrayName', ValueStr, ' ');


//--- the function uses to get an element of the array is
//--- ArrayGetValue(ArrayName : String, APosition : Integer);
Result := ArrayGetValue('ArrayName', 1); //- contient ‘Script’
Exit ;

 

Where to put the code in the page
So far, many are wondering how to start and run a FM script code. Before getting there I suggest that we discover some indispensable bases.



Compiler View
Create Menu


Our Partners

Support
      Telephone : (+237) 675979899 / 676009100
      Email : fm_support@f-m.fm
      P.O Box : 774 BAFOUSSAM
Available On

no
no

Further Market Inc
Copyright © 2012-2021.