October 29, 2025, 01:10:53 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Error "local subroutines not supported"

Started by Techno, June 11, 2015, 04:29:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Techno

Dear support,

I don't understand what wrong here with an local subroutine?.

This is the code translated from Creative Basic into IWBasic v3.0



DEF win   : WINDOW
Def Time : string
def n$ : string
def fcolor : uint
DEF bcolor : uint
def c1 : double
DEF c2 : double
DEF c3 : double
DEF c4 : double
DEF ohm : double

openwindow(win,0,0,640,420,@SIZE|@MINBOX,0,"4 Band Resistor ", &mainHandler)
setwindowcolor(win, rgb(152,198,255))
StartTimer(win, 1000)

CONTROL(win,@STATIC,"#1 Band",39,15,70,20,1,71)
SETCONTROLCOLOR(win,71,RGB(0,0,0),rgb(152,198,255))

CONTROL(win,@STATIC,"#2 Band",123,15,70,20,1,72)
SETCONTROLCOLOR(win,72,RGB(0,0,0),rgb(152,198,255))

CONTROL(win,@STATIC,"#3 Band",207,15,70,20,1,73)
SETCONTROLCOLOR(win,73,RGB(0,0,0),rgb(152,198,255))

CONTROL(win,@STATIC,"#4 Band",291,15,70,20,1,74)
SETCONTROLCOLOR(win,74,RGB(0,0,0),rgb(152,198,255))

CONTROL(win,@STATIC,"",500,300,120,20,1,75)
SETCONTROLCOLOR(win,75,RGB(0,0,0),rgb(152,198,255))

CONTROL(win,@EDIT,"Edit1",39,40,70,20,0x50802000,1)
SETCONTROLCOLOR(win,1,RGB(0,0,0),RGB(128,128,0))

CONTROL(win,@EDIT,"Edit2",123,40,70,20,0x50802000,2)
SETCONTROLCOLOR(win,2,RGB(0,0,0),RGB(128,128,0))

CONTROL(win,@EDIT,"Edit3",207,40,70,20,0x50802000,3)
SETCONTROLCOLOR(win,3,RGB(0,0,0),RGB(128,128,0))

CONTROL(win,@EDIT,"Edit4",291,40,70,20,0x50802000,4)
SETCONTROLCOLOR(win,4,RGB(0,0,0),RGB(128,128,0))

CONTROL(win,@STATIC,"Tolerance",390,130,70,20,0,60)
CONTROL(win,@STATIC,"Ohms",390,150,70,20,0,61)
CONTROL(win,@STATIC,"KilOhms",390,170,70,20,0,62)
CONTROL(win,@STATIC,"MegOhms",390,190,70,20,0,63)

FOR x = 60 to 63 /* ID Controls */
setcontrolcolor(win,x,RGB(0,0,0),rgb(152,198,255))
next x

CONTROL(win,@STATIC,"+/-20%",465,130,130,20,0,64)
CONTROL(win,@STATIC,"0",465,150,130,20,0,65)
CONTROL(win,@STATIC,"0",465,170,130,20,0,66)
CONTROL(win,@STATIC,"0",465,190,130,20,0,67)

for x = 64 to 67
SETCONTROLCOLOR(win,x,RGB(255,0,0),rgb(152,198,255))
next x

'======================================================
'Color 1
'======================================================
CONTROL(win,@BUTTON,"Black",39,60,70,20,0x8000,10)
SETCONTROLCOLOR(win,10,RGB(255,255,255),RGB(0,0,0))

CONTROL(win,@BUTTON,"Brown",39,80,70,20,0x8000,11)
SETCONTROLCOLOR(win,11,RGB(255,255,255),RGB(128,64,0))

CONTROL(win,@BUTTON,"Red",39,100,70,20,0x8000,12)
SETCONTROLCOLOR(win,12,RGB(255,255,255),RGB(255,0,0))

CONTROL(win,@BUTTON,"Orange",39,120,70,20,0x8000,13)
SETCONTROLCOLOR(win,13,RGB(255,255,255),RGB(255,147,37))

CONTROL(win,@BUTTON,"Yellow",39,140,70,20,0x8000,14)
SETCONTROLCOLOR(win,14,RGB(0,0,0),RGB(240,240,0))

CONTROL(win,@BUTTON,"Green",39,160,70,20,0x8000,15)
SETCONTROLCOLOR(win,15,RGB(255,255,255),RGB(0,202,0))

CONTROL(win,@BUTTON,"Blue",39,180,70,20,0x8000,16)
SETCONTROLCOLOR(win,16,RGB(255,255,255),RGB(72,72,255))

CONTROL(win,@BUTTON,"Violet",39,200,70,20,0x8000,17)
SETCONTROLCOLOR(win,17,RGB(255,255,255),RGB(191,0,191))

CONTROL(win,@BUTTON,"Grey",39,220,70,20,0x8000,18)
SETCONTROLCOLOR(win,18,RGB(255,255,255),RGB(128,128,128))

CONTROL(win,@BUTTON,"White",39,240,70,20,0x8000,19)
SETCONTROLCOLOR(win,19,RGB(0,0,0),RGB(255,255,255))

'======================================================
'Color 2
'======================================================
CONTROL(win,@BUTTON,"Black",123,60,70,20,0x8000,20)
SETCONTROLCOLOR(win,20,RGB(255,255,255),RGB(0,0,0))

CONTROL(win,@BUTTON,"Brown",123,80,70,20,0x8000,21)
SETCONTROLCOLOR(win,21,RGB(255,255,255),RGB(128,64,0))

CONTROL(win,@BUTTON,"Red",123,100,70,20,0x8000,22)
SETCONTROLCOLOR(win,22,RGB(255,255,255),RGB(255,0,0))

CONTROL(win,@BUTTON,"Orange",123,120,70,20,0x8000,23)
SETCONTROLCOLOR(win,23,RGB(255,255,255),RGB(255,147,37))

CONTROL(win,@BUTTON,"Yellow",123,140,70,20,0x8000,24)
SETCONTROLCOLOR(win,24,RGB(0,0,0),RGB(240,240,0))

CONTROL(win,@BUTTON,"Green",123,160,70,20,0x8000,25)
SETCONTROLCOLOR(win,25,RGB(255,255,255),RGB(0,202,0))

CONTROL(win,@BUTTON,"Blue",123,180,70,20,0x8000,26)
SETCONTROLCOLOR(win,26,RGB(255,255,255),RGB(72,72,255))

CONTROL(win,@BUTTON,"Violet",123,200,70,20,0x8000,27)
SETCONTROLCOLOR(win,27,RGB(255,255,255),RGB(191,0,191))

CONTROL(win,@BUTTON,"Grey",123,220,70,20,0x8000,28)
SETCONTROLCOLOR(win,28,RGB(255,255,255),RGB(128,128,128))

CONTROL(win,@BUTTON,"White",123,240,70,20,0x8000,29)
SETCONTROLCOLOR(win,29,RGB(0,0,0),RGB(255,255,255))

'======================================================
'Color 3
'======================================================
CONTROL(win,@BUTTON,"Black",207,60,70,20,0x8000,30)
SETCONTROLCOLOR(win,30,RGB(255,255,255),RGB(0,0,0))

CONTROL(win,@BUTTON,"Brown",207,80,70,20,0x8000,31)
SETCONTROLCOLOR(win,31,RGB(255,255,255),RGB(128,64,0))

CONTROL(win,@BUTTON,"Red",207,100,70,20,0x8000,32)
SETCONTROLCOLOR(win,32,RGB(255,255,255),RGB(255,0,0))

CONTROL(win,@BUTTON,"Orange",207,120,70,20,0x8000,33)
SETCONTROLCOLOR(win,33,RGB(255,255,255),RGB(255,147,37))

CONTROL(win,@BUTTON,"Yellow",207,140,70,20,0x8000,34)
SETCONTROLCOLOR(win,34,RGB(0,0,0),RGB(240,240,0))

CONTROL(win,@BUTTON,"Green",207,160,70,20,0x8000,35)
SETCONTROLCOLOR(win,35,RGB(255,255,255),RGB(0,202,0))

CONTROL(win,@BUTTON,"Blue",207,180,70,20,0x8000,36)
SETCONTROLCOLOR(win,36,RGB(255,255,255),RGB(72,72,255))

CONTROL(win,@BUTTON,"Violet",207,200,70,20,0x8000,37)
SETCONTROLCOLOR(win,37,RGB(255,255,255),RGB(191,0,191))

CONTROL(win,@BUTTON,"Grey",207,220,70,20,0x8000,38)
SETCONTROLCOLOR(win,38,RGB(255,255,255),RGB(128,128,128))

CONTROL(win,@BUTTON,"White",207,240,70,20,0x8000,39)
SETCONTROLCOLOR(win,39,RGB(0,0,0),RGB(255,255,255))

CONTROL(win,@BUTTON,"Gold",207,260,70,20,0x8000,40)
SETCONTROLCOLOR(win,40,RGB(0,0,0),RGB(255,160,106))

CONTROL(win,@BUTTON,"Silver",207,280,70,20,0x8000,41)
SETCONTROLCOLOR(win,41,RGB(0,0,0),RGB(192,192,192))

'======================================================
'Color 4
'======================================================
CONTROL(win,@BUTTON,"Black",291,60,70,20,0x8000,50)
SETCONTROLCOLOR(win,50,RGB(255,255,255),RGB(0,0,0))

CONTROL(win,@BUTTON,"Brown",291,80,70,20,0x8000,51)
SETCONTROLCOLOR(win,51,RGB(255,255,255),RGB(128,64,0))

CONTROL(win,@BUTTON,"Gold",291,100,70,20,0x8000,52)
SETCONTROLCOLOR(win,52,RGB(0,0,0),RGB(255,160,106))

CONTROL(win,@BUTTON,"Silver",291,120,70,20,0x8000,53)
SETCONTROLCOLOR(win,53,RGB(0,0,0),RGB(192,192,192))

CONTROL(win,@BUTTON,"None",291,140,70,20,0x8000,54)
SETCONTROLCOLOR(win,54,RGB(0,0,0),RGB(128,128,0))

'=======================================================================
'Draw the Boxes
'=======================================================================
RECT(win,380,84,10,2,0,0)
RECT(win,390,60,200,50,0,RGB(128,128,0))
RECT(win,410,58,20,54,0,RGB(128,128,0))
RECT(win,432,58,20,54,0,RGB(128,128,0))
RECT(win,454,58,20,54,0,RGB(128,128,0))
RECT(win,476,58,20,54,0,RGB(128,128,0))
RECT(win,590,84,10,2,0,0)

run = 1
WAITUNTIL(run = 0)
closewindow(win)
end

'--------------------------------------------------------------------------------
SUB mainHandler()
SELECT @CLASS
case @IDCLOSEWINDOW
run = 0

case @IDCREATE
CenterWindow(win)

Case @IDTIMER
Time = Time$
hr   = val(Left$(Time, 2))
min  = val(mid$(time,4,2))
sec  = val(Right$(Time,2))

if(hr < 1)  then hr += 12
if(hr > 12) then hr -= 12
if(hr < 12) then n$ = "AM" else n$ = "PM"
SETCONTROLTEXT(win,75,Using("###:0##:0## ",hr,min,sec) + n$)


case @IDCONTROL
' Kleurband 1
if(@CONTROLID >= 10 & @CONTROLID <= 19)  /* ControlID tussen de 10..19 */
SETCONTROLTEXT(win,1, getcontroltext(win, @CONTROLID))

select @CONTROLID
case 10
fcolor = RGB(255,255,255)
bcolor = RGB(0,0,0)
case 11
fcolor = RGB(255,255,255)
bcolor = RGB(128,64,0)
case 12
fcolor = RGB(255,255,255)
bcolor = RGB(255,0,0)
case 13
fcolor = RGB(255,255,255)
bcolor = RGB(255,147,37)
case 14
fcolor = RGB(0,0,0)
bcolor = RGB(240,240,0)
case 15
fcolor = RGB(255,255,255)
bcolor = RGB(0,202,0)
case 16
fcolor = RGB(255,255,255)
bcolor = RGB(72,72,255)
case 17
fcolor = RGB(255,255,255)
bcolor = RGB(191,0,191)
case 18
fcolor = RGB(255,255,255)
bcolor = RGB(128,128,128)
case 19
fcolor = RGB(0,0,0)
bcolor = RGB(255,255,255)
endselect

SETCONTROLCOLOR(win,1,fcolor,bcolor)
RECT(win,410,58,20,54,0,bcolor)
c1 = @controlid - 10
gosub update
endif

' Kleurband 2
if(@CONTROLID >= 20 & @CONTROLID <= 29) THEN
SETCONTROLTEXT(win,2,getcontroltext(win,@CONTROLID))

select @CONTROLID
case 20
fcolor = RGB(255,255,255)
bcolor = RGB(0,0,0)
case 21
fcolor = RGB(255,255,255)
bcolor = RGB(128,64,0)
case 22
fcolor = RGB(255,255,255)
bcolor = RGB(255,0,0)
case 23
fcolor = RGB(255,255,255)
bcolor = RGB(255,147,37)
case 24
fcolor = RGB(0,0,0)
bcolor = RGB(240,240,0)
case 25
fcolor = RGB(255,255,255)
bcolor = RGB(0,202,0)
case 26
fcolor = RGB(255,255,255)
bcolor = RGB(72,72,255)
case 27
fcolor = RGB(255,255,255)
bcolor = RGB(191,0,191)
case 28
fcolor = RGB(255,255,255)
bcolor = RGB(128,128,128)
case 29
fcolor = RGB(0,0,0)
bcolor = RGB(255,255,255)
endselect

SETCONTROLCOLOR(win,2,fcolor,bcolor)
RECT(win,432,58,20,54,0,bcolor)
c2 = @CONTROLID - 20
gosub update
endif

' Kleurband 3
if(@CONTROLID >= 30 & @CONTROLID <= 41) then
SETCONTROLTEXT(win,3,getcontroltext(win,@CONTROLID))

select @CONTROLID
case 30
fcolor = RGB(255,255,255)
bcolor = RGB(0,0,0)
case 31
fcolor = RGB(255,255,255)
bcolor = RGB(128,64,0)
case 32
fcolor = RGB(255,255,255)
bcolor = RGB(255,0,0)
case 33
fcolor = RGB(255,255,255)
bcolor = RGB(255,147,37)
case 34
fcolor = RGB(0,0,0)
bcolor = RGB(240,240,0)
case 35
fcolor = RGB(255,255,255)
bcolor = RGB(0,202,0)
case 36
fcolor = RGB(255,255,255)
bcolor = RGB(72,72,255)
case 37
fcolor = RGB(255,255,255)
bcolor = RGB(191,0,191)
case 38
fcolor = RGB(255,255,255)
bcolor = RGB(128,128,128)
case 39
fcolor = RGB(0,0,0)
bcolor = RGB(255,255,255)
case 40
fcolor = RGB(0,0,0)
bcolor = RGB(255,160,106)
case 41
fcolor = RGB(0,0,0)
bcolor = RGB(192,192,192)
endselect

SETCONTROLCOLOR(win,3,fcolor,bcolor)
RECT(win,454,58,20,54,0,bcolor)
c3 = @CONTROLID - 30
gosub update
endif

if(@CONTROLID >= 50 & @CONTROLID <= 54) then
SETCONTROLTEXT(win,4,getcontroltext(win,@CONTROLID))
select @CONTROLID
case 50
fcolor = RGB(255,255,255)
bcolor = RGB(0,0,0)
case 51
fcolor = RGB(255,255,255)
bcolor = RGB(128,64,0)
case 52
fcolor = RGB(0,0,0)
bcolor = RGB(255,160,106)
case 53
fcolor = RGB(0,0,0)
bcolor = RGB(192,192,192)
case 54
fcolor = RGB(0,0,0)
bcolor = RGB(128,128,0)
endselect
SETCONTROLCOLOR(win,4,fcolor,bcolor)
RECT(win,476,58,20,54,0,bcolor)
c4 = @CONTROLID - 50
gosub update
endif
Endselect
Return

sub update

select c4
case 0
SETCONTROLTEXT(win,64,"+/- 1%")
case 1
SETCONTROLTEXT(win,64,"+/- 2%")
case 2
SETCONTROLTEXT(win,64,"+/- 5%")
case 3
SETCONTROLTEXT(win,64,"+/- 10%")
case 4
SETCONTROLTEXT(win,64,"+/- 20%")
endselect

if(c3 < 10)
ohm = (c1 * 10 + c2) * 10 ^ c3
SETCONTROLTEXT(win,65,using("-###,###,###,###,###",ohm))

ohm = (c1 * 10 + c2) * 10 ^ (c3 - 3)
if(c3 - 3 < 0) then
SETCONTROLTEXT(win,66,using("-###,###,###,###,###.##",ohm))
else
SETCONTROLTEXT(win,66,using("-###,###,###,###,###",ohm))
endif

ohm = (c1 * 10 + c2) * 10 ^ (c3 - 6)
if(c3 - 3 < 3) then
SETCONTROLTEXT(win,67,using("-###,###,###,###,###.##",ohm))
else
SETCONTROLTEXT(win,67,using("-###,###,###,###,###",ohm))
endif
else

ohm = (c1 * 10 + c2) * 10 ^ -(c3 - 9)
SETCONTROLTEXT(win,65,using("-###,###.##",ohm))
ohm = (c1 * 10 + c2) * 10^ - (c3 - 6)
SETCONTROLTEXT(win,66,using("-###,###",ohm))
ohm = (c1 * 10 + c2) * 10^ - (c3 - 3)
SETCONTROLTEXT(win,67,using("-###,###",ohm))
endif
return


Compiling Resources...
No Errors

Compiling...
resistorcolors.iwb
File: b:\resistorcolors.iwb (12) Warning: Argument 9 (mainHandler) does not match the declaration of IWBWNDPROC
Different return type: none, should be int
File: b:\resistorcolors.iwb (384) Error: local subroutines not supported
Error(s) in compiling b:\resistorcolors.iwb
Build Failed

Brian

Techno,

The line: SUB mainHandler() should read SUB mainHandler(),INT

The RETURN at the end of that sub-routine should be
RETURN 0
ENDSUB

Your last RETURN on the second sub should also have an ENDSUB

Brian