diff --git a/logicalgates.pas b/logicalgates.pas index e70fea8..ec04613 100644 --- a/logicalgates.pas +++ b/logicalgates.pas @@ -483,13 +483,12 @@ T_wireValue=record FUNCTION get2ComplementValue (CONST wire:T_wireValue; OUT valid:boolean):longint; FUNCTION gatesTotal(CONST gateCount:T_gateCount):longint; -FUNCTION gateCountReport(CONST gateCount:T_gateCount):string; FUNCTION serialize(CONST wireValue: T_wireValue): qword; FUNCTION deserialize(n: qword): T_wireValue; IMPLEMENTATION -USES sysutils,myStringUtil; +USES sysutils; FUNCTION getBinaryString(CONST wire: T_wireValue): shortstring; VAR i:longint; begin @@ -627,16 +626,6 @@ T_wireValue=record for gt in T_gateType do result+=gateCount[gt]; end; -FUNCTION gateCountReport(CONST gateCount: T_gateCount): string; - VAR gt:T_gateType; - begin - result:=''; - for gt in T_gateType do if gateCount[gt]>0 then begin - if result<>'' then result+=LineEnding; - result+=C_gateTypeName[gt]+C_tabChar+intToStr(gateCount[gt]); - end; - end; - FUNCTION parseWireBin(CONST s: string; CONST width: byte): T_wireValue; VAR i:longint; k:longint; diff --git a/sprites.pas b/sprites.pas index 7abe4fc..b8ba3e9 100644 --- a/sprites.pas +++ b/sprites.pas @@ -115,7 +115,7 @@ FUNCTION get7SegmentSprite(CONST wireValue: T_wireValue; CONST marked:boolean):P_sprite; FUNCTION getWatcherSprite(CONST ioLabel_:shortstring; CONST ioIndex:longint; CONST wireValue:T_wireValue; CONST isInput,leftOrRight:boolean):P_sprite; IMPLEMENTATION -USES sysutils,myStringUtil,types,Classes,math; +USES sysutils,types,Classes,math,strutils; VAR ioSpriteMap, blockSpriteMap, ioBlockSpriteMap, @@ -712,6 +712,48 @@ end; end; + FUNCTION split(CONST s:ansistring; CONST splitters:T_arrayOfString; CONST retainSplitters:boolean=false):T_arrayOfString; + PROCEDURE nextSplitterPos(CONST startSearchAt:longint; OUT splitterStart,splitterEnd:longint); inline; + VAR splitter:string; + i:longint; + begin + splitterStart:=length(s)+1; + splitterEnd:=splitterStart; + for splitter in splitters do if length(splitter)>0 then begin + i:=PosEx(splitter,s,startSearchAt); + if (i>0) and (isplitterStart; + while(partStart<=length(s)) do begin + appendToResult(copy(s,partStart,splitterStart-partStart)); + partStart:=splitterEnd; + endsOnSplitter:=splitterEnd>splitterStart; + if endsOnSplitter and retainSplitters then appendToResult(copy(s,splitterStart,splitterEnd-splitterStart)); + nextSplitterPos(partStart,splitterStart,splitterEnd); + end; + if endsOnSplitter and not retainSplitters then appendToResult(''); + setLength(result,resultLen); + end; + begin lines:=split(s,LineEnding);