Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
Functions | Variables
Working progressing API

Functions

 lib2d_statusChange (level)
 Change the current level. More...
 
 lib2d_statusDestroy ()
 Destroy the 'status' ''object. More...
 
 lib2d_statusGetLevel (list)
 Get the current level. More...
 
 lib2d_statusGetRsc (list)
 Get the current graphical resources and its level list. More...
 
 lib2d_statusNew (oMother, posx, posy)
 Create a new 'status' ''object. More...
 
 lib2d_statusSetRsc (list)
 Set graphical resources and its level for a 'status'. More...
 
 lib2d_workingDestroy ()
 Destroy the object. More...
 
 lib2d_workingGetNStep ()
 Get the number of steps. More...
 
 lib2d_workingGetPath ()
 Get the 2d resources filename. More...
 
 lib2d_workingGetPeriod ()
 Get the period between steps. More...
 
 lib2d_workingGetSize ()
 Get the 2d resources element size. More...
 
 lib2d_workingGetTransColor ()
 Get the transparency color. More...
 
 lib2d_workingGetWindow ()
 Get the child window. More...
 
 lib2d_workingNew (oMother, posx, posy)
 Create a new object. More...
 
 lib2d_workingSetCallback (cb)
 Set the callback. More...
 
 lib2d_workingSetNStep (iNstep)
 Set the number of steps. More...
 
 lib2d_workingSetPath (szPath)
 Set the 2d resources filename. More...
 
 lib2d_workingSetPeriod (iPeriod)
 Set the period between steps. More...
 
 lib2d_workingSetSize (iSize)
 Set the 2d resources element size. More...
 
 lib2d_workingSetTransColor (iColor)
 Set the transparency color. More...
 

Variables

var L2D_STATUS_lRSC
 List of graphical resources and levels. More...
 
typeof L2D_WORKING_iCOLORTRANSP =I
 Transparency color, if any (default : no transparency color set)
 
var L2D_WORKING_iNSTEP =10
 The number of steps. Default : 1.
 
var L2D_WORKING_iPERIOD =100
 The period (the time bteween each step). Default : 100 ms.
 
var L2D_WORKING_iSIZE =36
 Graphical resource element size, in pixels.
 
var L2D_WORKING_szPATH ="lib/2dos/rsc/process-working.png"
 Graphical resource filename for show the activity.
 

Detailed Description

Package to load : lib/2dos/working.pkg

Dependancies :

workingprogress.png
.// This example is provided 'AS IT'
.// I hope that it will be useful, but WITHOUT ANY WARRANTY.
.//
.// By Iri - april 2014.
.// Web : http://www.scolring.org
.
./*
. Dependancies to run this example :
. _load "lib/2dos/bitmap.pkg"
. _load "lib/2dos/working.pkg"
.*/
.
.typeof win = ObjWin;;
.typeof text = ObjText;;
.var number = 0;;
.
.fun cbEnd (o, p)=
. _closemachine;;
.
.fun cbChange (n)=
. _SETtext text itoa number;
. set number = if number > 100 then 0 else number+1;
. 0;;
.
.fun main ()=
. _showconsole;
.
. set win = _CRwindow _channel nil 0 0 300 200 WN_NORMAL " Working";
. _CRtext _channel win 5 5 290 20 ET_BORDER|ET_ALIGN_CENTER "... working in progres ...";
. set text = _CRtext _channel win 5 55 290 20 ET_ALIGN_CENTER "0";
. let lib2d_workingNew win 112 82 -> res in
. _fooS if !res then "Success !" else strcat "Error : " itoa res;
. let lib2d_statusNew win 152 82 -> res in
. _fooS if !res then "STATUS Success !" else strcat "STATUS Error : " itoa res;
.
.
. _CBwinDestroy win @cbEnd 0;
. 0;;

Function Documentation

lib2d_workingSetPath ( szPath  )

Set the 2d resources filename.

By default, it is "lib/2dos/rsc/process-working.png"

Prototype : fun [S] I

Parameters
S: the new filename to set.
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : the given path is nil
lib2d_workingGetPath ( )

Get the 2d resources filename.

Prototype : fun [] S

Returns
S : the current 2d resource filename.
lib2d_workingSetSize ( iSize  )

Set the 2d resources element size.

By default, it is 36

Prototype : fun [I] I

Parameters
I: the new size to set.
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : the given size is nil
lib2d_workingGetSize ( )

Get the 2d resources element size.

Prototype : fun [] I

Returns
S : the current 2d resource element size
lib2d_workingSetTransColor ( iColor  )

Set the transparency color.

By default, it is 36

Prototype : fun [I] I

Parameters
I: the new transparency color to set. It can be nil if no transparency to set
Returns
I : always 0
lib2d_workingGetTransColor ( )

Get the transparency color.

Prototype : fun [] I

Returns
S : the defined transparency color.
lib2d_workingSetNStep ( iNstep  )

Set the number of steps.

By default, it is 11

Prototype : fun [I] I

Parameters
I: the new number to set.
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : the given size is incorrect
lib2d_workingGetNStep ( )

Get the number of steps.

Prototype : fun [] I

Returns
I : the current 2d resource element size
lib2d_workingSetPeriod ( iPeriod  )

Set the period between steps.

By default, it is 11

Prototype : fun [I] I

Parameters
I: the new period to set.
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : the given period is invalid
Examples:
2dos/working.pkg_.
lib2d_workingGetPeriod ( )

Get the period between steps.

Prototype : fun [] I

Returns
I : the current period
lib2d_workingSetCallback ( cb  )

Set the callback.

This function will be called when a new step is done.

Prototype : fun [fun [I] I] I

Parameters
fun[I] I : the callback to set (can be nil (default). Its argument is the step number.
Returns
I : always 0.
Examples:
2dos/working.pkg_.
lib2d_workingGetWindow ( )

Get the child window.

Prototype : fun [] ObjWin

Returns
ObjWin : the current window or nil if not created yet
lib2d_workingNew ( oMother  ,
posx  ,
posy   
)

Create a new object.

This function should be called AFTER the parameter's setting.

Remarks
One only instance can be created at the time.
See also
lib2d_workingDestroy

Prototype : fun [ObjWin I I] I

Parameters
ObjWin: the mother window
I: the x cordinate, relative to the mother
I: the y cordinate, relative to the mother
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : an instance already running
  • 2 : the mother is nil
  • 3 : unable to load the bitmap resource correctly
  • 4 : unable to create the internal bitmap
  • 5 : unable to create the child window correctly
  • 6 : unable to ctreate the timer
Examples:
2dos/working.pkg_.
lib2d_workingDestroy ( )

Destroy the object.

You should destroy a such object when no longer needed.

All parameters keep available to a next creation. To change them, this API is here !

Prototype : fun [] I

Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : no instance running
Examples:
2dos/working.pkg_.
lib2d_statusSetRsc ( list  )

Set graphical resources and its level for a 'status'.

Each resource should have the same size.

Prototype : fun [[[S I I] r1]] I

Parameters
[[SI I] r1] : a list : a resource and a level (min and max) for this resource
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : the list is nil
lib2d_statusGetRsc ( list  )

Get the current graphical resources and its level list.

Prototype : fun [] [[S I] r1]

Returns
[[S I] r1] : the list
lib2d_statusGetLevel ( list  )

Get the current level.

Prototype : fun [] I

Returns
I : the current level or nil if error / no instance running
lib2d_statusChange ( level  )

Change the current level.

Prototype : fun [I] I

Parameters
I: the level to set
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : the given level is nil
  • 2 : unable to load the resource (bad path, no resource defined to this level, ...)
  • 3 : (for info only) : the current resource is unchanged.
Examples:
2dos/working.pkg_.
lib2d_statusNew ( oMother  ,
posx  ,
posy   
)

Create a new 'status' ''object.

Remarks
One only instance can be created at the time.
See also
lib2d_statusDestroy

Prototype : fun [ObjWin I I] I

Parameters
ObjWin: the mother window
I: the x cordinate, relative to the mother
I: the y cordinate, relative to the mother
Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : an instance already running
  • 2 : the mother is nil
  • 3 : the resources list is nil
  • 4 : unable to load the bitmap resource correctly
  • 5 : unable to create the child window correctly
Examples:
2dos/working.pkg_.
lib2d_statusDestroy ( )

Destroy the 'status' ''object.

You should destroy a such object when no longer needed.

All parameters keep available to a next creation. To change them, the API is here !

Prototype : fun [] I

Returns
I : 0 if success or a positive value if an error occurs :
  • 1 : no instance running
Examples:
2dos/working.pkg_.

Variable Documentation

L2D_STATUS_lRSC
Initial value:
=["lib/2dos/rsc/status-0-24.png" 0 24] ::
["lib/2dos/rsc/status-25-49.png" 25 49] ::
["lib/2dos/rsc/status-50-74.png" 50 74] ::
["lib/2dos/rsc/status-75-100.png" 75 100] ::
nil

List of graphical resources and levels.