forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Problems with #include

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Tue Jun 14, 2005 12:40 pm    Post subject: Problems with #include Reply with quote

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
View user's profile Send private message
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Jun 15, 2005 3:00 am    Post subject: Try this Reply with quote

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
View user's profile Send private message Send e-mail
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Thu Jun 16, 2005 3:25 pm    Post subject: Reply with quote

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. Smile

David...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group