Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
Pages: 1
is the return value of a function always the last data type before the function ends with ";;"
for example:
fun drawBitmap(text, wsize, tsize, widget)=
let wsize -> [texWidth texHeight] in
let tsize -> [tw th] in
let _FILLbitmap (_CRbitmap _channel texWidth texHeight) 0xffffff -> bmpRgb in
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0x00 -> bmp8 in
//open let fillbitmap8
(
if bmpRgb==nil then
//open bmprgb if then else
(
_fooS "there is no rgb bitmap";
_ADDcompText ongoing_chat_textfield "there is no rgb bitmap" hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
)
else if bmp8 == nil then
(
_fooS "there is no bitmap mask";
_ADDcompText ongoing_chat_textfield "there is no bitmap mask" hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
)
else if widget == nil then
(
_ADDcompText ongoing_chat_textfield "no widget passed to bitmap" hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
_fooS "no widget passed to bitmap";
0;
)
else
//open else
(
let _CRalphaBitmap _channel bmpRgb bmp8 nil nil -> abmp in
//open abmp let
(
if abmp == nil then
//open abmp if then else
(
_fooS "there is no abmp, in other words, no alpha bitmap";
_ADDcompText ongoing_chat_textfield "there is no abmp, in other words, no alpha bitmap" hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
)
else
//open else
(
_fooS "there is a bmprgb bitmap, there is a bmp8 bitmap, and there is a local varaible abmp that contains an alphabitmap";
_ADDcompText ongoing_chat_textfield "there is a bmprgb bitmap, there is a bmp8 bitmap, and there is a local varaible abmp that contains an alphabitmap" hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
let _GETalphaBitmaps abmp -> [rgb alpha] in
//open GETalphaBitmaps let
(
_DRAWtext rgb hacker_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xffffff text;
_DRAWtext8 alpha hacker_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xffffff text;
if ((SO3BitmapWidgetBlitAlpha widget abmp) == nil) then
//open blit if then else
(
_fooS "failed to blitmap";
_ADDcompText ongoing_chat_textfield strcatn "\n"::"failed to blitmap to widget"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
)
else
(
_fooS "bltmap succeeded, do you see one?";
_ADDcompText ongoing_chat_textfield strcatn "\n"::"created blitmap to widget"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
//close blit if then else
);
//close GETalphaBitmaps let
);
//bitmaps copied in alpha bitmap so we can destroy them
_DSbitmap bmpRgb;
_DSbitmap8 bmp8;
//close else
0;
);
//close abmp let
0;
);
// close bmprgb if then else
75;
);
Would this function return the integer 75?
Offline
yes
thx arkeon, I will figure out where this widget script is not working.
Offline
Yes, the function returns the return value of the last statement.
fun foobar (a)=
_fooS "The function name is 'foobar'"; // a statement, ended by ;
a;; // another statement
foobar returns 'a' (the value of a) because this is the last statement.
fun calcul (a, b)=
if a < b then
b-a // the last statement if a < b
else
a-b;; // the last statement if a >= b
fun calcul2 (a, b)=
if a < b then
b-a
else
a-b;
75;; // always the last statement, so 'calcul2' always returns '75'
fun calcul3 (a, b)=
if a == b then
nil // the last statement if a == b
else
calcul a b;; // the last statement if a != b and returns the return value of the called function
fun main ()=
_showconsole;
_fooId calcul 10 3; // display '7'
_fooId calcul 4 12; // display '8'
_fooId calcul2 10 3; // display '75'
_fooId calcul2 4 12; // display '75'
_fooId calcul3 10 3; // display '7'
_fooId calcul3 4 4; // display 'NIL'
0;;
Offline
Your drawBitmap function returns a wrong value ?
What type of value want you return ?
I'm not sure yet, it's just a question I had.
Offline
Pages: 1