[fpc-pascal] Drawing window out line
Hi , Could Any One help Me to writing Horizontal and vertical line to message window in Free Pascal as i MEM and MEMW function not supported in free pascal. note : we can not use Video and CRT Unit both in single unit. i want to use CRT unit only. below is the my sample code PROCEDURE draw_window_outline(top_left_x, top_left_y, width, height, style, fore, back : BYTE); VAR x,y: BYTE; offset : INTEGER; BEGIN IF (style255) AND (width2) AND (height2) THEN BEGIN offset:=(top_left_x-1)*2 +(top_left_y-1)*160; MEM[$B800:offset]:=top_left_corner[style]; MEM[$B800:offset+1]:=back*16+fore; FOR x:=1 TO (width-2) DO BEGIN MEM[$B800:offset+x*2]:=horizontal[style]; MEM[$B800:offset+x*2+1]:=back*16+fore; END; MEM[$B800:offset+(width-1)*2]:=top_right_corner[style]; MEM[$B800:offset+(width-1)*2+1]:=back*16+fore; FOR y:=1 TO (height-2) DO BEGIN MEM[$B800:offset+y*160]:=vertical[style]; MEM[$B800:offset+y*160+1]:=back*16+fore; MEM[$B800:offset+(width-1)*2+y*160]:=vertical[style]; MEM[$B800:offset+(width-1)*2+y*160+1]:=back*16+fore; END; offset:=(top_left_x-1)*2 +(top_left_y+height-2)*160; MEM[$B800:offset]:=bottom_left_corner[style]; MEM[$B800:offset+1]:=back*16+fore; FOR x:=1 TO (width-2) DO BEGIN MEM[$B800:offset+x*2]:=horizontal[style]; MEM[$B800:offset+x*2+1]:=back*16+fore; END; MEMW[$B800:offset+(width-1)*2]:=bottom_right_corner[style]; MEM[$B800:offset+(width-1)*2+1]:=back*16+fore; END; END; Thanks, Sudarshan -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Drawing-window-out-line-tp5719322.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Drawing window out line
mokashe.ram wrote: Hi , Could Any One help Me to writing Horizontal and vertical line to message window in Free Pascal as i MEM and MEMW function not supported in free pascal. note : we can not use Video and CRT Unit both in single unit. i want to use CRT unit only. below is the my sample code MEM[$B800:offset]:=top_left_corner[style]; I thought it had already been explained to you that you cannot use MEM[] etc. on current operating systems, therefore that is not your sample code: it's stuff that you're asking other people to translate for you. If you want help on this then post a minimal program that compiles but exhibits the problem, i.e. ten lines or so that initialises the video stuff, tries to write to it (exhibiting the error) and tidies up. What's going on here? All of a sudden two people start asking very similar questions about MEM[], MEMW[] and so on. If this is classwork it's probably safe to assume that your instructor is reading this mailing list with interest, perhaps he'd like to fill in what operating system etc. your code's supposed to run on since you've not told us :-) -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Drawing window out line
On Thu, May 22, 2014 09:00, mokashe.ram wrote: Hi, Could Any One help Me to writing Horizontal and vertical line to message window in Free Pascal as i MEM and MEMW function not supported in free pascal. note : we can not use Video and CRT Unit both in single unit. i want to use CRT unit only. below is the my sample code PROCEDURE draw_window_outline(top_left_x, top_left_y, width, height, style, fore, back : BYTE); VAR x,y: BYTE; offset : INTEGER; BEGIN IF (style255) AND (width2) AND (height2) THEN BEGIN offset:=(top_left_x-1)*2 +(top_left_y-1)*160; MEM[$B800:offset]:=top_left_corner[style]; MEM[$B800:offset+1]:=back*16+fore; FOR x:=1 TO (width-2) DO BEGIN MEM[$B800:offset+x*2]:=horizontal[style]; MEM[$B800:offset+x*2+1]:=back*16+fore; END; MEM[$B800:offset+(width-1)*2]:=top_right_corner[style]; MEM[$B800:offset+(width-1)*2+1]:=back*16+fore; FOR y:=1 TO (height-2) DO BEGIN MEM[$B800:offset+y*160]:=vertical[style]; MEM[$B800:offset+y*160+1]:=back*16+fore; MEM[$B800:offset+(width-1)*2+y*160]:=vertical[style]; MEM[$B800:offset+(width-1)*2+y*160+1]:=back*16+fore; END; offset:=(top_left_x-1)*2 +(top_left_y+height-2)*160; MEM[$B800:offset]:=bottom_left_corner[style]; MEM[$B800:offset+1]:=back*16+fore; FOR x:=1 TO (width-2) DO BEGIN MEM[$B800:offset+x*2]:=horizontal[style]; MEM[$B800:offset+x*2+1]:=back*16+fore; END; MEMW[$B800:offset+(width-1)*2]:=bottom_right_corner[style]; MEM[$B800:offset+(width-1)*2+1]:=back*16+fore; END; END; If using just unit Crt, you need to call procedures TextColor and TextBackground for proper setting of your foreground and background colour (fore and back in your example) and then replace references to Mem on _even_ addresses (the odd ones are handled automatically by the previous setting of TextColor and TextBackground) with a combination of GotoXY and Write calls. Obviously, it's better to do it in lines (i.e. call GotoXY for the first character in a sequence of modified characters on that line, then combine the whole sequence to a string (e.g. starting with char (top_left_corner[style]) followed by width-2 instances of char (horizontal[style]) and finally char (top_right_corner[style])) and then call Write for the whole created string. Note that using unit Video is both more efficient and also easier for translation of your original code. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Drawing window out line
On Thu, May 22, 2014 09:55, Mark Morgan Lloyd wrote: mokashe.ram wrote: . . it's probably safe to assume that your instructor is reading this mailing list with interest, perhaps he'd like to fill in what operating system etc. your code's supposed to run on since you've not told us :-) In the first thread (coming from different person ;-) ), there's been a post via Nabble (before the poster subscribed to the mailing list) where he stated that the target was Win32. This e-mail never appeared on this list because it went to the moderation queue as part of the spam protection efforts and it was apparently deleted by one of the moderators by mistake (either me or Jonas). Since there was no other information included and it didn't change the situation substantially, I decided not to ask the poster for resending his e-mail at that time (I do it in other cases if I notice such a situation happening - you know, there are sometimes quite many spam messages, so one may easily miss a valid one among them). Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Drawing window out line
Tomas Hajny wrote: On Thu, May 22, 2014 09:55, Mark Morgan Lloyd wrote: mokashe.ram wrote: . . it's probably safe to assume that your instructor is reading this mailing list with interest, perhaps he'd like to fill in what operating system etc. your code's supposed to run on since you've not told us :-) In the first thread (coming from different person ;-) ), there's been a post via Nabble (before the poster subscribed to the mailing list) where he stated that the target was Win32. This e-mail never appeared on this list because it went to the moderation queue as part of the spam protection efforts and it was apparently deleted by one of the moderators by mistake (either me or Jonas). That's one of the problems when people use gmail: hints such as their real timezone are removed. One person pretending to be two, or asking similar questions as different threads, can happen if they don't appreciate that the etiquette in a mailing list differs from that of IRC: in the latter case one sometimes needs to ask multiple times as the user population churns. Going back to the earlier message: note : we can not use Video and CRT Unit both in single unit. i want to use CRT unit only. Perhaps somebody would like to confirm this, but my understanding is that Video and CRT can't be used in the same /program/, not just the same /unit/. Unless there's a very good reason, I'd have thought that using FreeVision would have been the best way to go, since this already knows about things like window outlines and stands a reasonable chance of having already sorted out e.g. codepage selection issues. However since this isn't CIX I think we need to answer the question as posed- once it's in a sufficiently-concise form that we have a chance :-) -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Drawing window out line
On Thu, May 22, 2014 10:51, Mark Morgan Lloyd wrote: . . Going back to the earlier message: note : we can not use Video and CRT Unit both in single unit. i want to use CRT unit only. Perhaps somebody would like to confirm this, but my understanding is that Video and CRT can't be used in the same /program/, not just the same /unit/. Unless there's a very good reason, I'd have thought that using FreeVision would have been the best way to go, since this already knows about things like window outlines and stands a reasonable chance of having already sorted out e.g. codepage selection issues. . . Two comments: 1) (In)compatibility of units Video and Crt is platform (implementation) specific thing. They can be used together without any issues on platforms providing sufficient access to the console (i.e. basically anything except for *nix platforms which provide limited set of console features accessible across the different operating systems and technical implementations) _as_long_as_you_know_what_you_do_ (i.e. you should understand that changing the video buffer without UpdateScreen intermixed with Crt.Write calls will obviously not give a reasonable outcome and results of Crt.Write may not be accessible for reading via VideoBuf^). Among others, this includes Win32 as well as far as I know. 2) FreeVision has its limitations too - especially when talking about stuff like Unicode (which may be handled better in unit Crt due to fewer limitations/more limited set of features provided there). Unfortunately, that's partly valid also for unit Video - it would need to be extended/updated for multibyte encoding, because the current implementation hard-codes that the TVideoCell = word. I have started working on extending and updating unit Video to cover this and allow building unit Crt functionality on top of unit Video (and Keyboard) in rather generic manner very long time ago, but I have never finished it because it required quite a lot of time (in order to make it working on all supported platforms) which I didn't have. Some concepts in this area are still not completely obvious, because we may not have generic (platform-independent) functionality for e.g. finding out how many display characters are necessary for a Unicode string which may not be normalized yet (i.e. it may include standalone accents which need to be combined with the main letter, etc.). Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal