Declaring a Function Before it is used
- Posted by "Michelle Rogers" <michellerogers at bellsouth.net> Oct 28, 2003
- 434 views
Also, can anyone tell me if there is a way to declare a function before it is used. If not, how do you handle things like: Run Function A, which calls Function B Function B calls Function C If statement then Function C calls Function D else Function C calls Function A end if This seems impossible to handle if you can't declare Function A ahead of time, because you can't move it ahead of Function C to solve the problem, since that causes a problem of not being able to call Functions B and C from Function A Michelle ----- Original Message ----- From: "Michelle Rogers" <michellerogers at bellsouth.net> To: <EUforum at topica.com> Sent: Tuesday, October 28, 2003 5:36 AM Subject: Re: Fastest Way to... > > > Hello, can someone tell me what is wrong with this? I'm using the hackserv > as a basis for a mud. I've tried to change it to accomodate telnet, gmud, > zmud, etc..(basically any client) where it only supported telnet in the > beginning. I KNOW this is too much code..but i've just been adding stuff in > trying to make it work and nothing seems to work. I KNOW that I'm > overlooking something really easy..but I can't figure it out. Can someone > tell me if you know what is wrong with this? > > elsif action = FD_READ then -- The client said somethin' > junk = "" > owork = "" > while not match({CRLF},junk) do > owork = WsockReadData(sock,1) > if atom(owork) then > exit > end if > if length(owork)<1 then > exit > end if > if atom(owork) then > exit > end if > if length(owork)<1 then > exit > end if > junk = junk & owork > > end while > -- junk now contains the client's responce > > -- find this user in our list > iwork = getUserFromSocket(sock) > > > if length(players)>0 then > for x=1 to length(players) do > if players[x][1]=sock then > charnum=x > end if > end for > end if > > players[charnum][6]=players[charnum][6]&junk > > if compare({10},players[charnum][6][(length(players[charnum][6]))]) or > compare({13},players[charnum][6][length(players[charnum][6])]) then > > if compare({10},players[charnum][6][length(players[charnum][6])]) then > > players[charnum][6]=players[charnum][6][1..(length(players[charnum][6])-1)] > end if > > if compare({13},players[charnum][6][length(players[charnum][6])]) then > > players[charnum][6]=players[charnum][6][1..(length(players[charnum][6])-1)] > end if > > if compare({10},players[charnum][6][length(players[charnum][6])]) then > > players[charnum][6]=players[charnum][6][1..(length(players[charnum][6])-1)] > end if > junk=players[charnum][6] > > warnErr("junk:"&sprint(junk)) > > players[charnum][6]="" > call_proc(players[charnum][7],{sock,junk}) > junk="" > end if > > > Thank you in advance, > > Michelle > > > ----- Original Message ----- > From: "C. K. Lester" <euphoric at cklester.com> > To: <EUforum at topica.com> > Sent: Monday, October 27, 2003 11:34 PM > Subject: Re: Fastest Way to... > > > > Pete Lomax wrote: > > > > >>Okay, here's my attempt: > > >> > > >>junk =3D pos <=3D 0 > > >>pos =3D pos * junk > > >>pos +=3D not junk > > >> > > >> > > >That's about 3 times slower. > > > > > >In your first post, you "unrolled the loop" which is a classic way to > > >make something as fast as possible. > > > > > >Pete > > > > > > > > hey, Pete, thanks for that info. I later realized that it won't be a > > static size sequence, so I have to accommodate all sizes. > > > > I bet looping through the sequence when length() is more than ? would be > > faster than the sequence operations... right? > > > > > > TOPICA - Start your own email discussion group. FREE! > > > > > > > TOPICA - Start your own email discussion group. FREE! > >