| View previous topic :: View next topic |
| Author |
Message |
dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Tue Jun 14, 2005 12:40 pm Post subject: Problems with #include |
|
|
Hi
I've written a library of functions & commands which I want to include in my other scripts. The library seems to get included but when I try and use the extra commands I get an invalid list operation. Here is part of the library...
| Code: | #DEFINE COMMAND,s>,dup,drop,swap,over,rot,pick,roll,r>,s>r,s<r
#DEFINE FUNCTION,s<,r<
%%stack = 1
%%returnstack = 2
list create,%%stack
list create,%%returnstack
exit
rem return 1 item off the top of the stack
:s<
if @zero(@count(%%stack))
warn STACK EMPTY!
stop
end
list seek,%%stack,0
%a = @item(%%stack)
list delete,%%stack
exit %a
rem place items on the stack
:s>
repeat
if @zero(@count(%%stack))
list add,%%stack,%1
else
list seek,%%stack,0
list insert,%%stack,%1
end
shift
until @null(%1)
exit
|
Then if I do...
| Code: |
#include stackmachine.dsc
s> 3,2,1
exit
|
I get an invalid list operation when trying to use the command. What am I doing wrong?
Thanks... |
|
| Back to top |
|
 |
WidgetCoder Contributor


Joined: 28 May 2002 Posts: 126 Location: CO, USA
|
Posted: Wed Jun 15, 2005 3:00 am Post subject: Try this |
|
|
The interpreter will not find your list create command unless it's called under a label, Try...
| Code: |
#DEFINE COMMAND,s>,dup,drop,swap,over,rot,pick,roll,r>,s>r,s<r
#DEFINE FUNCTION,s<,r<
:OpenStack
%%stack = 1
%%returnstack = 2
list create,%%stack
list create,%%returnstack
exit
:CloseStack
list close,%%stack
list close,%%returnstack
exit
rem return 1 item off the top of the stack
:s<
if @zero(@count(%%stack))
warn STACK EMPTY!
stop
end
list seek,%%stack,0
%a = @item(%%stack)
list delete,%%stack
exit %a
rem place items on the stack
:s>
repeat
if @zero(@count(%%stack))
list add,%%stack,%1
else
list seek,%%stack,0
list insert,%%stack,%1
end
shift
until @null(%1)
exit
|
|
|
| Back to top |
|
 |
dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Thu Jun 16, 2005 3:25 pm Post subject: |
|
|
Thanks man your a STAR, anything is now working! So can you only inlcude COMMANDS & FUNCTIONS, no straight code?
Thanks again, I'm very happy and excited about my new stack commands.
David... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|