Board index » delphi » single linked lists/'C' system command
ewatson
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
ewatson
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
single linked lists/'C' system command
Sorry about the empty post.
I would like to know of some coding that would allow me to sort a single linked list via pointer movement not data movement. I have a sort that works for a double linked list but I cant seem to make it work for a single linked list. Also, in 'C' I have access to a command 'system' that allows me to run DOS programs from within my program, but I cant seem to find an equivalent Pascal command, which means I have to break my programs in two if I have to sort some intermediate work files. I hope somebody can help me. thanks |
Frank Peel
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:single linked lists/'C' system commandQuoteewatson <exwat...@interhop.net> wrote in message Quote> Sorry about the empty post. Good hunting! Quote> I would like to know of some coding that would allow me to sort several steps. It shouldn't be too difficult once you can visualise it, since you managed it for the doubly-linked list, but you will get your brain in a twist if you don't have diagrams to work from. In a singly-linked list your program will have to remember the item pointing Quote> Also, in 'C' I have access to a command 'system' that allows me your program not to hog all the memory, by using the {$M directive. FP |
Osmo Ronkan
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:single linked lists/'C' system commandIn article <8113o6$c3...@news.auracom.net>, Quoteewatson <exwat...@interhop.net> wrote: correct length or hell breaks loose. uses dos; Type pnode=^node; {$f+} Function MakeList:pnode; break: Function ListLen(p:pnode):longint; Function Sum(p:pnode):word; Function Lshr1(x:longint):longint; Procedure SortList(var list:pnode; len:longint); { find the last node in the first half list } for i:=2 to lshr1(len) do r:=r^.next; q:=r^.next; { get the first nor of the second half list} SortList(p,lshr1(len)); if p^.data<=q^.data then begin { get the first element of the } if p=nil then r^.next:=q Function testList(p:pnode):boolean; function timer:real; var p:pnode; begin Quote>Also, in 'C' I have access to a command 'system' that allows me exec(getenv('compspec'),'/c '+command); swapvectors Remember to limit the heap with {$M... Alternatively you could use the following provided you have enough Remember some programs like PRINT can load a TSR portion when first Remember to check the variable Doserror after executing an external program. Unit Dheap; Interface uses dos; {$ifdef msdos } Const execerror:boolean=false; { if set, exit ASAP } procedure exec(const com,par:string); {$endif} Const freeenv:word=300; { amount of free environment for shell/push } Procedure Shell(const st:string); Implementation {$ifdef msdos} type words=record lo,hi:word; end; procedure exec(const com,par:string); dos.exec(com,par); rg.bx:=words(HeapEnd).hi-prefixseg; { Execerror is set if one loads a TSR from exec() } Function MaxProg:word; { kilobytes } {$endif} type string11=string[11]; Function Envsize:word; assembler; xor ax,ax mov ah,30h; int 21h; cmp al,3; jb @dos2 { check dos version } add di,3 @dos2: mov ax,di Function commandparams:string11; Procedure Shell(const st:string); Procedure Push; End. |
Frederic Bonro
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:single linked lists/'C' system commandQuoteOsmo Ronkanen wrote: label called break and jumping to it using goto? |
Osmo Ronkan
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:single linked lists/'C' system commandIn article <38358A15.76F85...@mail.dotcom.fr>, Frederic Bonroy <fbon...@mail.dotcom.fr> wrote: Quote>Osmo Ronkanen wrote: break. I originally used break but then edited it for compatibility. Osmo |