|
Post by firestone on Mar 9, 2007 0:49:38 GMT -5
Can I have an include file with functions and subroutines, and just call them from the main file? I should be able to, since it just appends the file, but when I tried, Liberty BASIC can't find the subs...
|
|
|
Post by Alyce Watson on Mar 9, 2007 7:02:15 GMT -5
I have no problem with this feature. I just re-tested. Here's the main code I used to test:
'include hello.bas call Hello wait
I'd saved this code to disk in the same directory as the main program:
Hello.bas:
sub Hello print "Hello" end sub
When I ran the main program, it printed "Hello" just fine. The saved file that was loaded into LB looked like this:
'include hello.bas call Hello wait
'******************************* 'hello.bas begins here:
sub Hello print "Hello" end sub
|
|
|
Post by firestone on Mar 9, 2007 21:32:51 GMT -5
Alright, I figured out my problem, I had the include as my second line of code, and not my first. I put it as my first, and it works fine now.
|
|
bit
New Member
Posts: 2
|
Post by bit on Dec 13, 2010 9:01:19 GMT -5
I have also troubles with include. My code for both, source and include, is on the same dir, lbworkshop is installed on another one. The sub calculates proportional width and height for an Image to put into a certain frame.
Main, only for testing:
' include calcPictDim.bas
[A] input "ImgWidth :";ImgWidth if ImgWidth=0 then end input "Imgheight :";ImgHeight input "Framewidth :";frameWidth input "Frameheight :";frameHeight call calcPictDim ImgWidth,ImgHeight,frameWidth,frameHeight,propWidth,propHeight print "NewDimension ";propWidth;" x ";propHeight goto [A]
File to iclude:
sub calcPictDim ImgWidth,ImgHeight,frameWidth,frameHeight, byref propWidth,byref propHeight if ImgWidth<=frameWidth then ' wenn Bild in die Box passt propWidth=ImgWidth propHeight=ImgHeight else ImgFakt=frameWidth/ImgWidth propWidth=int(ImgWidth*ImgFakt+ 0.5) propHeight=ImgHeight*ImgFakt propHeight=int(propHeight) if propHeight>frameHeight then ImgFakt=frameHeight/propHeight propWidth=int(propWidth * ImgFakt +0.5) propHeight=int(propHeight*ImgFakt + 0.5) end if end if end sub
The include directive is not effected and no module is included when saving project.
|
|
|
Post by Alyce Watson on Dec 13, 2010 9:10:00 GMT -5
I have also troubles with include. My code for both, source and include, is on the same dir, lbworkshop is installed on another one. The sub calculates proportional width and height for an Image to put into a certain frame. Main, only for testing: ' include calcPictDim.bas
The include directive is not effected and no module is included when saving project. Remove the space between the apostrophe and the word "include". 'include calcPictDim.bas
I tested this and it worked fine.
|
|
bit
New Member
Posts: 2
|
Post by bit on Dec 14, 2010 6:06:16 GMT -5
Many thanks, it works fine. Sorry I didn't expect this blank as important.
|
|