English
Source / code snippets

ignore Sonderzeichen

 
In one MultiEdit would like I gladly any Sonderzeichen ignore. I Have me Procedur written, which the too lovely Done. my question on The Experten: Can the too kürzer write. Bestimt there a Loop for, but my old head...
PROC SONDERZEICHEN

    cover$=TRANSLATE$(cover$, ,-)  the should so be. space with hyphen supplant
    cover$=TRANSLATE$(cover$,CHR$(34),)
    cover$=TRANSLATE$(cover$,§,)
    cover$=TRANSLATE$(cover$,$,)
    cover$=TRANSLATE$(cover$,%,)
    cover$=TRANSLATE$(cover$,&,)
    cover$=TRANSLATE$(cover$,/,)
    cover$=TRANSLATE$(cover$,(,)
    cover$=TRANSLATE$(cover$,),)
    cover$=TRANSLATE$(cover$,=,)
    cover$=TRANSLATE$(cover$,?,)
    cover$=TRANSLATE$(cover$,`,)
    cover$=TRANSLATE$(cover$,!,)
    cover$=TRANSLATE$(cover$,°,)
    cover$=TRANSLATE$(cover$,²,)
    cover$=TRANSLATE$(cover$,³,)

    cover$=TRANSLATE$(cover$,{,)

        cover$=TRANSLATE$(cover$,[,)
        cover$=TRANSLATE$(cover$,],)

    cover$=TRANSLATE$(cover$,},)

    cover$=TRANSLATE$(cover$,,)
    cover$=TRANSLATE$(cover$,*,)
    cover$=TRANSLATE$(cover$,,)
    cover$=TRANSLATE$(cover$,~,)
    cover$=TRANSLATE$(cover$,#,)
    cover$=TRANSLATE$(cover$,+,)
    cover$=TRANSLATE$(cover$,|,)
    cover$=TRANSLATE$(cover$,µ,)

ENDPROC

 
06/09/08  
 



Try time
cover$=match$([A-Za-z0-9~-],cover$)
 
06/09/08  
 



unfortunately works not. -
If the ANSI-characters not so wild confusion ständen, could to the simply with of/ one Loop make. but since the Sonderzeichen in Blöcken between whom letters and numbers are, müssten the several creep his and then is the code neither small How in of my Procedur
 
06/09/08  
 




RGH
iF
Try time
cover$=match$([A-Za-z0-9~-],cover$)


the functions definitiv not How desired (well posted, without before To testing? ;) ), but so goes it:
PROC SONDERZEICHEN

    parameters cover$
    cover$=TRANSLATE$(cover$, ,-) the should so be. space with hyphen supplant
    any forbidden characters Remove

    whileloop 1, len(cover$)

        case instr(substr$(cover$, &loop), q§$%&/()=?`!°²³{[]}*+#+|µ) > 0 : cover$ = del$(cover$,&loop,1)

    endwhile

    return cover$

ENDPROC

Var Test$ = Hühnerhof, Rindviefarm, 23%, $34.a[oho], 56µ 123² * 456³ / 45% A&O
Print Sonderzeichen(test $)
waitinput
end

BTW: to XProfan 11 must to the substr$(cover$, &loop) through mid$(cover$,&loop,1) supplant.

Greeting
Roland
 
Intel Duo E8400 3,0 GHz / 4 GB RAM / 1000 GB HDD - ATI Radeon HD 4770 512 MB - Windows 7 Home Premium 32Bit - XProfan X4
06/09/08  
 



@Roland
you are the Grösste
thanks
 
06/09/08  
 



 
06/09/08  
 




Nico
Madysa
functions it too so?
proc SONDERZEICHEN

    parameters cover$
    declare a%
    cover$ = Translate$(cover$, ,-)
    a% = Set(RegEx,1)
    cover$ = Translate$(cover$,[q§~$%&/~(~)=~?`!°²³~{~[~]~}\~*#~+~|µ) ],)
    Set(RegEx,a%)
    return cover$

endproc

 
Nico Madysa
06/09/08  
 




Thomas
Freier
??

In one MultiEdit would like I gladly any Sonderzeichen ignore.


supplant or ignore on Rolfs manner:
Edit: characters in one Editfeld not to permit
 $I PROFALT.INC	Include-File for Source code former Profan-versions (to XProfan 11.0), The yet no Operators benefit.
with usage of  XProfan < 11.0 can The above-mentioned Include-row $I PROFALT.INC bedenkenlos deleted be.
executable ex Profan-Version 6.6
The procedure CHECK_INPUT VERBIETET EINE REIHE
übergebener characters in one Editfeld.
(c) by Rolf cook - Rokosoft 2005
 $P+
SetErrorLevel 0
THESE PROC WERTET AUS  ************************************************************

PROC CHECK_INPUT

    Declare BLEN$,BLAENGE%,RET$
    PARAMETERS IN&,BCHST$
    BLAENGE%=1
    RET$=

    WHILENOT len(BCHST$)+1 = BLAENGE%

        BLEN$=MID$(BCHST$,BLAENGE%,1)

        IF INSTR(BLEN$,gettext$(in&))

            Settext in&,del$(gettext$(in&),len(gettext$(in&)),1)
            setfocus(in&)
            sendmessage(in&,$00B1,len(gettext$(IN&)),len(gettext$(IN&))+1) Cursor on whom Schluss settle
            RET$=blen$

        ENDIF

        INC BLAENGE%

    WEND

    RETURN RET$

ENDPROC

***************************************************************************************
Windowtitle forbidden characters
Cls
Declare Dlg&
Declare Button%
Declare Dlg_Ende%
Declare Eingabe&
Dlg& = Create(dialog,%Hwnd,Please something prompt,350,50,180,70)
Eingabe& = Create(Edit,Dlg&,,10,10,150,20)
SetFocus(Eingabe&)
Dlg_Ende% = 0
Print In this example prohibited:
Print/*-_>< (see CHECK_INPUT ...)
Print ---------------------------------
Whilenot Dlg_Ende%
Waitinput
IF GETFOCUS(EINGABE&)
AUFRUF UND AUSWERTUNG ****************************************
CHECK_INPUT Eingabe&,/*-_><
PARAMETER: HANDLE EDITFELD UND LISTE VERBOTENE ZEICHEN
CASE $(0) <>  : PRINT VERBOTENES ZEICHEN GEFUNDEN:  + $(0)
***************************************************************
ENDIF
If Equ(Button%,2)
Dlg_Ende% = 1
DestroyWindow(Dlg&)
Endif
Wend
End
 
Gruß Thomas
Windows XP SP2, XProfan X2
06/10/08  
 



I needed it even yourself and thereby is me in Rolands code noticed the it characters skipping.

therefore have I a imho hardly (vlt. over regexp) schleunigbare routine prepares:
 {$cleq}

stringToAllowedChars(string s,alwdChrs){

    long c=len(s),i
    caseNot c : return

    do {

        i+

        ifNot inStr(subStr$(s,i),alwdChrs) {

            s=del$(s,i,1)
            i-
            c-

        }

        case i==c : break

    }

    return s

}

Var Test$ = Hühnerhof, Rindviefarm, 23%, $34.a[oho], 56µ 123² * 456³ / 45% A&O
Print stringToAllowedChars(test $,45)
waitinput
end
here too for XProfan without xpse:
proc STRINGTOALLOWEDCHARS

    PARAMETERS s$,ALWDCHRS$
    var C&=LEN(s$)
    var I&=0

    IFNOT C&

        RETURN

    ENDIF

    WHILE 1

        INC I&

        IFNOT INSTR(SUBSTR$(s$,I&),ALWDCHRS$)

            s$=DEL$(s$,I&,1)
            DEC I&
            DEC C&

        ENDIF

        IF I&=C&

            BREAK

        ENDIF

    ENDWHILE

    RETURN s$

endproc

VAR TEST$=Hühnerhof, Rindviefarm, 23%, $34.a[oho], 56µ 123² * 456³ / 45% A&O
PRINT STRINGTOALLOWEDCHARS(TEST$,45)
WAITINPUT
end
Have I vlt. something in the code overlooking? In my few Tests ergaben itself no Error.
 
06/23/08  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

7.780 Views

Untitledvor 0 min.
Walter10/14/19
Erasmus.Herold06/11/19
AndreasS02/10/19
Pauli06/19/14
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie