English
Forum

String single Letters apart

 

Jörg
Sellmeyer
Gibts a faster/kürzere Version as that here?
CompileMarkSeparation
Set("Decimals",0)

Proc Zerlege1

    Parameters Text$,Trenner$
    Declare Ergebnis$

    WhileLoop Len(Text$)

        Ergebnis$ = Ergebnis$ + Mid$(Text$,&Loop,1) + Trenner$

    Wend

    Return Ergebnis$

EndProc

Proc Zerlege2

    Parameters Text$,Trenner$
    Declare Ergebnis$

    WhileLoop Len(Text$)

        Ergebnis$ = Ergebnis$ + SubStr$(Text$,&Loop) + Trenner$

    Wend

    Return Ergebnis$

EndProc

Proc Zerlege3

    Parameters Text$,Trenner$
    Declare Ergebnis$,c&
    c&=len(text$)-1

    WhileLoop c&,1,-1

        Text$ = Ins$(Trenner$,Text$,&loop)

    Wend

    Return Text$

EndProc

Proc Zerlege4

    Parameters t$,u$
    declare e$,f&
    f&=Addr(t$)

    whileloop 0,Len(t$)-1

        e$=e$+Char$(f&,&Loop,1)+u$

    endwhile

    Return e$

endproc

Def MultiByteToWideChar(6) !"Kernel32","MultiByteToWideChar"

Proc Zerlege5

    Parameters Text$,Trenner$
    Declare c&,b#
    c& = Len(Text$) * 2 + 1
    Dim b#,c&
    MultiByteToWideChar(0,0,Addr(Text$),Len(Text$),b#,c& )
    Text$ = Translate$(Char$(b#,0,c& - 1),"z","|")
    Return Text$

EndProc

Cls
Var a& = &GetTickCount
ClearClip
PutClip "Z01 Z02 Z03 Z04 Z05
"

WhileLoop 5

    Zerlege1(MkStr$("ABCDEFGHIJKLMNOP",200),"|")
    PutClip  Str$(&GetTickCount - a&) + " "
    a& = &GetTickCount
    Zerlege2(MkStr$("0123456789012345",200),"|")
    PutClip  Str$(&GetTickCount - a&,) + " "
    a& = &GetTickCount
    Zerlege3(MkStr$("QRSTUVWXYZÄÖÜß@A",200),"|")
    PutClip  Str$(&GetTickCount - a&) + " "
    a& = &GetTickCount
    Zerlege4(MkStr$("0987654321098765",200),"|")
    PutClip  Str$(&GetTickCount - a&) + " "
    a& = &GetTickCount
    Zerlege5(MkStr$("qjeudkfotlgkcjdh",200),"|")
    PutClip  Str$(&GetTickCount - a&) + "
    "
    WindowTitle Str$(&Loop)

Wend

Print GetClip$(on class=s2>)
WaitInput
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/08/08  
 



Perhaps instead of WhileLoop Len(Text$)

var c&=len(Text$)-1
whileLoop c&,1,-1

and instead of Result$ = Result$ + Mid$(Text$,& Loop,1) + Trenner$

Result$ = in that$(trenner$,Text$,&loop)

be unfortunately strain timewise very eingespannt...
 
08/08/08  
 



Nachtrag: bow in the XProfan: print sizeOf(explode("12:34",":")) gives 4 from instead of 2. i'm clear and so it the does (sizeof on long), correctly. ists but not.

Nachtrag: print sizeOf(explode("",".")) gives (naturally then) too 4 from, instead of <b><u>NULL</u></b> (but with the the missing NULL with Explode wish Roland Yes so)
 
08/08/08  
 




Jörg
Sellmeyer
iF
Nachtrag: bow in the XProfan: print sizeOf(explode("12:34",":")) gives 4 from instead of 2. i'm clear and so it the does (sizeof on long), correctly. ists but not.


Why bow? From what want Thou since the Size detect? from the function SizeOf? or mean You Profan ought to there with of/ one Error Message react?

mandatory now time your example testing.
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/08/08  
 



Explode Result: Dynamisches String-aray

explode supply one aray back, Arrays can in Arrays transfer go. One sizeOf on one aray ought to The Number of Entries zurückliefern - no bandwidth.

i'm clear How Roland the resolved has, but here are missing simply another couple Ausnahmendeklarationen.
 
08/08/08  
 




Jörg
Sellmeyer
so here time one Statistikdurchlauf. Seltsamerweise is the first Version at first Durchlauf similar quick, How Nr two. with further Durchläufen need tappt im dunkeln almost twice such a long time.
your Version (#3) shining The schnellst To his. I forget over ands over again, that it in that$ at all gives.
CompileMarkSeparation
Set("Decimals",0)

Proc Zerlege1

    Parameters Text$,Trenner$
    Declare Ergebnis$

    WhileLoop Len(Text$)

        Ergebnis$ = Ergebnis$ + Mid$(Text$,&Loop,1) + Trenner$

    Wend

    Return Ergebnis$

EndProc

Proc Zerlege2

    Parameters Text$,Trenner$
    Declare Ergebnis$

    WhileLoop Len(Text$)

        Ergebnis$ = Ergebnis$ + SubStr$(Text$,&Loop) + Trenner$

    Wend

    Return Ergebnis$

EndProc

Proc Zerlege3

    Parameters Text$,Trenner$
    Declare Ergebnis$,c&
    c&=len(text$)-1

    WhileLoop c&,1,-1

        Text$ = Ins$(Trenner$,Text$,&loop)

    Wend

    Return Text$

EndProc

Cls
Var a& = &GetTickCount
ClearClip
PutClip "Z01 Z02 Z03
"

WhileLoop 10

    Zerlege1(MkStr$("ABCDEFGHIJKLMNOP",200),"|")
    PutClip  Str$(&GetTickCount - a&) + " "
    a& = &GetTickCount
    Zerlege2(MkStr$("0123456789012345",200),"|")
    PutClip  Str$(&GetTickCount - a&,) + " "
    a& = &GetTickCount
    Zerlege3(MkStr$("QRSTUVWXYZÄÖÜß@A",200),"|")
    PutClip  Str$(&GetTickCount - a&) + "
    "
    WindowTitle Str$(&Loop)

Wend

Print GetClip$()
f='./../../function-references/XProfan/waitinput/'>WaitInput

Results:
Z01 Z02 Z03

375 250 187

516 406 375

875 515 360

875 500 375

875 516 375

875 500 375

891 500 375

875 500 375

890 500 375

875 516 375

 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/08/08  
 




RGH
@iF:
To SizeOf() from the Help:

@SizeOf(V)
V : name of/ one variables
Result: Longint

mind The Description the Parameters! one ought to The function already so benefit, How tappt im dunkeln virtual is and not How one tappt im dunkeln Perhaps gladly had! for something other as a Variablenbezeichner as Parameter is the function crept not definiert.

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
08/08/08  
 




Jac
de
Lad

CompileMarkSeparation
Proc Zerlege3

    Parameters t$,u$
    declare e$,f&
    f&=Addr(t$)

    whileloop 0,Len(t$)-1

        e$=e$+Char$(f&,&Loop,1)+u$

    endwhile

    Return e$

Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
08/08/08  
 



Zerlege3 there already, How plenty Time needed your "Zerlege4" in the Ggs. to that Zerlege3 Jac?
 
08/08/08  
 



Nachtrag: @Jörg: have another idea which Perhaps faster is as any others recent here geposteten Algos.

whom String simply in a WideString konvertieren and by Translate The nobodies supplant...

accordingly would the Meiste on native Abarbeitung encamped, means very fix... - and one needed no Loop More.
 
08/08/08  
 




Jörg
Sellmeyer
Jacs Version is something faster as my both, but slower as The of David:
Z01 Z02 Z03 Z04

375 266 171 344

782 500 359 484

984 516 375 469

969 500 375 469

969 515 360 437

703 250 218 360

829 515 360 375

625 250 187 234

609 438 375 469

969 515 375 469


now I will yet The WideString-Variante testing.
can someone explain, Why the first Passage explicit faster is? this is too so, if I instead of PutClip, the each sowort on the screen bring. I had sooner expects, that it faster becomes.

Nachtrag:
super! MultiByteToWideChar is it:
Z01 Z02 Z03 Z04 Z05

375 250 203 266 15

265 250 297 469 0

516 500 375 468 0

516 500 375 469 15

515 500 391 469 0


supra in the first Posting have I any versions zusammengefaßt.
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/08/08  
 




Jac
de
Lad
@iF: has itself already Done.
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
08/08/08  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

5.309 Views

Untitledvor 0 min.
RudiB.04/26/22
Manfred Barei11/18/18
Heiko Dix11/13/12
Frank Vorholzer05/24/12

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