RE: Help creating procedures
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 19, 2001
- 339 views
Hi David, > From: dstanger at belco.bc.ca > To: EUforum <EUforum at topica.com> > Reply-To: EUforum at topica.com > Subject: Help creating procedures > Date: 20/07/2001 4:11:43 AM > > I am writng a program in DOS32 that displays bitmaps a lot and I am > attempting to write two procedures that will make this task > easier to code. > My first procedure allows me to load a bitmap and display it > at a certain > point on screen with one line of code: > > procedure image(sequence name, integer x, integer y) > > integer error > object bitmap > > bitmap = read_bitmap(name & ".bmp") > error = sequence(bitmap) > > if error = 0 then > puts(1, "Error loading bitmap") > abort(0) > else > all_palette(bitmap[1] / 4) > bitmap = bitmap[2] > display_image({x,y}, bitmap) > end if > > end procedure > > Now I can call a bitmap and display it like so: > image("c:\\euphoria\\bitmaps\\test", 100, 100) > > What I want to do now it have another procedure called > address that would > allow me to list the address seperately and have image() use > that each time > so that I do not have to type it repeatedly. Something like: > > procedure address(sequence where_is_it) > end procedure > > Used like so: > > address("c:\\euphoria\\bitmaps\\") > > My problem is that when I try to place where_is_it in > procedure image() I am > informed that where_is_it has not been declared. I have been > trying all > sorts of things but nothing solves the problem. This error is > resulting > before the program even runs. I suspect that the problem is that the "address" procedure has been defined after the "image" procedure. Euphoria is a bit simplistic in this regard, unlike some other languages. Euphoria can only use routines if it has already seen their definition earlier in the source code. Thus ... procedure aa() end procedure procedure bb() aa() end procedure is okay but ... procedure bb() aa() end procedure procedure aa() end procedure is not okay. You may have to manually rearrange your source code so that Euphoria stops complaining. ----------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au --------------------- confidential information intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient of this message you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. If you have received this message in error please notify the sender immediately. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of Global Technology Australasia Limited.