PDA

View Full Version : Using INCLUDE to add a text file in PBP3



Sumobob
- 11th May 2016, 04:05
I am attempting to include a text file in my program. The file consists of 120 rows of 5 numbers (1 - 5). It is to be used as data by the program. The idea is to use a random number the result of which will be used to determine what row to start on in the text file.

As I read the manual, I get the impression that I am limited to .bas files.

Anyone have a good idea how to do this?

Thanks in advance,

Bob.

xpa999
- 15th May 2016, 16:24
A .bas file is simply a text file that conforms to the format that picbasic expects and can compile. You can declare arrays of variables in that file that can be used in the remainder of the program.

Demon
- 15th May 2016, 22:39
Arrange your values prefixed by DATA inside the INCLUDE file, load a table (refer to manual) then process it as you see fit.

Robert

HenrikOlsson
- 16th May 2016, 08:11
But DATA stores the values in EEPROM - don't know if it matters in this case but it needs to be considered.
The topic "Strings in codespace" has come up a couple of times, Darrel had some routines for it but his site is no longer available for apparent reasons. There's a repository somewhere on the forum, perhaps it's there. Anyway, here's the thread (http://www.picbasic.co.uk/forum/showthread.php?t=1999) with the discussion around his code. There are other threads as well.

/Henrik.

amgen
- 16th May 2016, 19:56
has to be 18f device, org 0x.... start location in program memory..... quotes around text, spaces have to be added with dec 34, cr is dec 13
that is text and decimals or hex numbers placed in memory at program time, accessed starting at the org location

END
''==============TABLES============= ''!!! ADD 0,0,0 TO END
ASM
tbl1 org 0xA400
db "HTTP/1.0 200 OK",13,"Content-Length: 800 ",13,13
db "<html>",13,"<h1> PIC 18F...TT Server v1.0</h1>",13,"<input type=",34,"text",34," id=",34,"txt",34,">"
db "<script type=",34,"text/javascript",34,">" ,13," var c=0;var t;var timer_is_on=0; "
db "function timedCount(){document.getElementById('txt').value= c;c=c+1; "
db "t=setTimeout(",34,"timedCount()",34,",1000);}function doTimer(){if (!timer_is_on){timer_is_on=1;timedCount();}} "
db "</script><form method=",34,"get",34,">Project name: <input type=",34,"text",34," name=",34,"PIC",34," value=",34,"PIC18F2525 ",34," />"
db "<br>select one: <select><option>Amps</option> "
db "<option>Volts</option><option>Frequency</option> </select>"
db "<input type=",34,"submit",34," value=",34,"Submit",34," /></form> "
db "<body onLoad=",34,"doTimer()",34,"><p><b>Note: TEXT HERE </b><br><script type=",34,"text/vbscript",34,">"
db "document.write(NOW & ",34," Hello World!",34,")</script><br></body></p> </html> "
db "<style type=",34,"text/css",34,">body{background-color:#d0e4fe;}h1{color:red;} style> "
db "<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> ",0,0,0
db "<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> ",0,0,0
ENDASM
'''---------------------------------------------------------------