PDA

View Full Version : Open aninclude file



MINHLE
- 23rd March 2011, 02:47
HI ALL,

I CANNOT OPEN FILE INCLUDE IN THE PROGRAM, SOME HELP I DO APPRICIATE
THECODE IS COPIED FROM DARREL'S PAGE

I.E:

DATA_READ VAR BYTE
DATATABLE CON EXT
ORIGIN VAR word

GOTO main;V SKIP THE NEXT LINES

ASM
DATATABLE
INCLUDE "HELLO.asm" ; THIS IS THE EXTERNAL DATA TABLE
end
endasm
'--------------------------------------
main:

b0 = 0

ORIGIN = 1 ; FIRST DATA IN THE EXTERNAL TABLE

readcode (datatable + origin), DATA_READ; READ DATA FROM THE EXTERANL TABLE

origin = origin +1; CONTINUE READING UBTIL THE END OF TABLE....

GOTO MAIN

Archangel
- 24th March 2011, 02:06
Include files must be in the same directory as the code you have written.

Gusse
- 24th March 2011, 10:32
Include file can be also in different folder, but then you must define the path.

Example:

.
.\PBP_code <- Your PBP file is located here
.\include <- Your include file is located here

<code><font color="#000000"><b>INCLUDE </b><font color="#FF0000">&quot;..\include\HELLO.asm&quot;</font></code>

HenrikOlsson
- 24th March 2011, 11:00
Or in the root of the PBP install folder. In which case you don't have to specify any path etc, just the filename.

It's my understanding that the compiler starts looking in the same folder as the source file. If the specified file isn't found there it then looks in the PBP install folder.

/Henrik.

Archangel
- 24th March 2011, 18:22
. . . and then I continue to learn . . . so much for repeating the Party Line :D
Henrik, That Makes sense . . . Gusse, it looks as if you have shown a truncated path statement, is there a way to set a PATH in code or in an .ini file somewhere so PBP will automatically seek out the include statements other than in the root or source file directories? I like Gusse's method of having a folder named include, a good place for all of Darrel's hard work, but using Windoze directories the path gets a bit long esp. if you accept "Default" installation parameters. I suppose I could put that include directory in the Root of C: and the path would be short.
Maybe DEFINE path=c:\PBP\code;C:\pbp\include; . . . .

Gusse
- 24th March 2011, 21:54
Actually, I like this include so much that all of my codes are using following structure. This way it is very much easier to do improvement or modification to some specific parts and leave working code untouchable.

Example of master code line:


<code><font color="#000080"><i>'----------------------------------------------
' XXX with PIC18F4520 and Nokia 3310 display
'----------------------------------------------
' Include &amp; Definition section
'----------------------------------------------

'----- Basics ---------------------------------
</i></font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\Definitions.pbp&quot;
</font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\Variables.pbp&quot;

</font><font color="#000080"><i>'----- LCD Selections -------------------------
</i></font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\LCD_5V.pbp&quot;

</font><font color="#000080"><i>'----- Inits and ADC Definitions --------------
</i></font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\Inits.pbp&quot;
</font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\ADCIN.pbp&quot;

</font><b>DEFINE </b>OSC 32

<font color="#000080"><i>'----------------------------------------------
' Main program
'----------------------------------------------
</i></font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\Mainloop.pbp&quot;

</font><font color="#000080"><i>'----- LCD Setups -----------------------------
</i></font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\LCD_3310.pbp&quot;
</font><b>INCLUDE </b><font color="#FF0000">&quot;..\incl\Display_Refresh_3310.pbp&quot;
<font color="#000080"><i>'----------------------------------------------</font></code>

MINHLE
- 26th March 2011, 12:19
hello all,
thanks for your help.

i try to add directory of the file, : it still do not open
include "c:\user\minhle....\hello.asm"

and even copy the file into directory of PBP (where .inc is ) the compiler show up huge errors.

note that i do not run INTERRUPT in the program. and the simple program is to open included file only

Gusse
- 26th March 2011, 17:42
Remove ASM and ENDASM.

"The ASM and ENDASM instructions tells PBP that the code between these
two lines is in assembly language and should not be interpreted as
PICBASIC PRO statements. You can use these two instructions to mix
assembly language code with BASIC statements."