Forum > Beginners
Trouble with DelSpace1 (Solved)
JLWest:
s2String =type TShiftState = set of ( ssShift ssAlt ssCtrl ssLeft ssRight
ssMiddle ssDouble ssMeta ssHyper ssAltGr ssCaps ssNum
ssScroll ssTriple ssQuad ssExtra1 ssExtra2 );
Notes: This type is used when describing a shortcut key or when describing what special keys are pressed on a keyboard when a key event is generated. The set contains the special keys that can be used in combination with a 'normal' key.
sCOPY ='*M1 uses ... classes; type TShiftState = set of ( ssShift ssAlt ssCtrl ssLeft ssRight ssMiddle ssDouble ssMeta ssHyper ssAltGr ssCaps ssNum ssScroll ssTriple ssQuad ssExtra1 ssExtra2 ); Notes: This type is used when describing a shortcut key or when describing what special keys are pressed on a keyboard when a key event is generated. The set contains the special keys that can be used in combination with a ''normal'' key.'
The spaces inside the left '(' and right ')' are not set to one 1 space.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- s2String:=sCopy; sCopy:=DelSpace1(s2String);
KodeZwerg:
--- Quote from: JLWest on November 18, 2022, 01:32:26 am ---The spaces inside the left '(' and right ')' are not set to one 1 space.
--- End quote ---
Is it this you are asking for? Since I do not know what DelSpace1 method is, I wrote that:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function DelDoubleSpace(const AString: string): string;var s: string; p: Integer;begin Result := AString; if (Length(AString) < 1) then Exit; s := AString; repeat p := Pos(' ', s); if (p > 0) then Delete(s, p, 1); until p = 0; Result := s;end;Hope that was it... untested but from theory it should eliminate all double spaces...
dje:
Maybe simplify your question. The following code removes all double spaces as described in the doc:
https://www.freepascal.org/docs-html/rtl/strutils/delspace1.html
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- WriteLn('"', DelSpace1(' apple orange ( pear ) '), '"');The output is:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---" apple orange ( pear ) "
Which looks correct to me. Are you expecting a different result?
JLWest:
function DelSpace1( const S: string ): string;
Notes: DelSpace1 returns a copy of S with all sequences of spaces reduced to 1 space.
I doubt DelSpace1 has a bug. After posting I now believe the blanks aren't spaces but tabs or something.
I'll try you're function bit suspect it won't work.
JLWest:
Yea, they weren't spaces but control characters.
Navigation
[0] Message Index
[#] Next page