English
Source / code snippets

abc2nr Buchstabenreihe Konvertieren Nr2abc transfiguring numbers count - 3

 
Related: zaehlen discretionary letters zaehler  [...] 

Jörg Sellmeyer (23.10.11)
it has me no silence let what about me Have yet weitergetüftelt. now Have ich's out and its letztlich more simply as initially expects.
CompileMarkSeparation
'and inverse
'Jörg Selllmeyer 2011
'to disengaged usage
'here get one very well declared, How the converting of numbers in a others Base functions:
'https://www.arndt-bruenner.de/maths/scripts/Zahlensysteme.htm
'The problem hierbei, is the fehlende zero. any Nullstellen must abgefangen go, The
'actually place circa one verringert and the following place ditto circa one verringert go.
'The worth A000 becomes then means without nobodies To YYZ. C000 becomes BYYZ

Proc Nr2ABC

    Parameters number!
    Declare worth$,remainder%

    While number! > 0

        remainder% = number! Mod 26
        number! = number! \ 26

        If remainder% = 0

            'here go The Nullstellen abgefangen and transformed
            number! = number! -1
            remainder% = 26

        EndIf

        Case remainder% > 0:worth$ = Chr$(remainder% + 64) + worth$

    Wend

    Return worth$

ENDPROC

Proc ABC2Nr

    Parameters Text$
    Declare number!,amount!,B$
    Text$ = Upper $(Text$)

    WhileLoop Len(Text$),1,-1

        B$ = SubStr$(Text$,-&Loop)
        number! = (Ord(B$)-64) * 26^(&Loop-1)
        amount! = amount! + number!

    Wend

    Return Int(amount!)

ENDPROC

Cls
Window Title "Zahlen in letters transfiguring and umgekehrt"
Print "LQSVOFKGQM =", ABC2Nr("LQSVOFKGQM")
Print "AAAAAA =", ABC2Nr("AAAAAA")
Print "ABCDEFGH =", ABC2Nr("ABCDEFGH")
Print
Print "XPROFAN power joke =", ABC2Nr("XPROFAN"),ABC2Nr("macht"),ABC2Nr("Spass")
Print
Declare s$
Randomize

WhileLoop 10

    s$ = Chr$(Rnd(26) + 65) + s$

Wend

Print s$ + " =",ABC2Nr(s$)
WaitInput
Cls
Randomize

WhileLoop 0,780,1

    Print Nr2ABC(&Loop),

Wend

WaitInput
Cls

WhileLoop 00,480,1

    Print Nr2ABC(&Loop + Rnd(345676)),

Wend

WaitInput

here's another small Program, with the one one little herumexperimentieren can:
CompileMarkSeparation
 $H windows.ph
Def DelLast(2) Mid$(@$(1),1,(Len(@$(1)) - @&(2)))
'here can beautiful nachlesen, How so a Umrechnung functions:
'https://www.arndt-bruenner.de/maths/scripts/Zahlensysteme.htm

Proc Nr2ABC

    Parameters number!
    Declare worth$,remainder%

    While number! > 0

        remainder% = number! Mod 26
        number! = number! \ 26

        If remainder% = 0

            number! = number! -1
            remainder% = 26

        EndIf

        Case remainder% > 0:worth$ = Chr$(remainder% + 64) + worth$

    Wend

    Return worth$

ENDPROC

Proc ABC2Nr

    Parameters Text$
    Declare number!,amount!,B$

    WhileLoop Len(Text$),1,-1

        B$ = SubStr$(Text$,&Loop)
        number! = Chr$(B$) * 26^(&Loop-1)
        amount! = amount! + number!

    Wend

    Return amount!

ENDPROC

SubProc Create.TextR

    Return @Control("STATIC",@$(2),$50000002,@%(3),@%(4), \
    @%(5),@%(6),@%(1),101, %hInstance)

ENDPROC

Proc Text_setzen

    Parameters cb&,txt&,txt1&
    Declare Text$,Result!
    Text$ = GetText$(txt&)
    SetText txt1&,Str $((GetCurSel(cb&)) * Val(Text$))
    Clear Text$

    WhileLoop 0,to put%-1

        Result! = Val(GetText$(txt1&[&Loop])) + Result!
        Text$ = Text$ + GetText$(cb&[&Loop])

    Wend

    SetText txt_Ergebnis&,Str $(Result!)
    SetText txt_Alphabet&,Text$
    SetText txt_Nr2ABC&,Nr2ABC(Result!)

ENDPROC

Proc Button_Aktion

    Parameters btn&

    If GetText$(btn&) = "Null setzen"

        SendMessage(cb&[focus%],$014E,0,0)
        Text_setzen(cb&[focus%],txt&[focus%],txt1&[focus%])
        SetText btn&,"Zufall"

    Else

        SendMessage(cb&[focus%],$014E,Rnd(26),0)
        Text_setzen(cb&[focus%],txt&[focus%],txt1&[focus%])
        SetText btn&,"Null setzen"

    EndIf

ENDPROC

Proc Alle_Null

    Parameters btn&

    If GetText$(btn&) = "alle zero setzen"

        WhileLoop 0,to put%-1

            SendMessage(cb&[&Loop],$014E,0,0)
            Text_setzen(cb&[&Loop],txt&[&Loop],txt1&[&Loop])
            SetText btn&[&Loop],"Zufall"

        Wend

        SetText btn&,"alle Zufall"

    Else

        WhileLoop 0,to put%-1

            SendMessage(cb&[&Loop],$014E,Rnd(26),0)
            Text_setzen(cb&[&Loop],txt&[&Loop],txt1&[&Loop])
            SetText btn&[&Loop],"Null setzen"

        Wend

        SetText btn&,"alle zero setzen"

    EndIf

ENDPROC

Declare to put%
Stellen% = 10
Declare cb&[to put%],txt&[to put%],txt1&[to put%],A$,x%,b%,focushdl&,focus%,Ergebnis&
Declare btn&[to put% + 1]
b% = 118
x% = 120
Window Style 8 | 24 | 512
Window to put% * (b% + 24),300
SetDialogFont ~GetStockObject($11)

WhileLoop 26

    a$ = a$ + Chr$(64 + &loop) + "|"

Wend

a$ = " |" + DelLast(a$,1)
MoveStrToList(a$,"|")

WhileLoop 0,to put%-1

    cb&[&Loop] = Create("ChoiceBox",%hwnd,0,5 + &Loop * x%,40,b%,160)
    Create("Tooltip",%hwnd,cb&[&Loop],"26^" + Str $(to put%-1 - &Loop))
    MoveListToHandle(cb&[&Loop])
    SendMessage(cb&[&Loop],$014E,0,0)
    txt&[&Loop] = Create("TextR",%hwnd,"",5 + &Loop * x%,10,b%,20)
    txt1&[&Loop] = Create("TextR",%hwnd,"",5 + &Loop * x%,80,b%,20)
    btn&[&Loop] = Create("Button",%hwnd,"Zufall",5 + &Loop * x%,110,b%,20)
    Case &Loop = to put% - 1:btn&[&Loop + 1] = Create("Button",%hwnd,"Zufall",5 + (&Loop + 1) * x%,110,b%,20)

Wend

Var txt_Alphabet& = Create("TextR",%hwnd,"",5 + to put% * x%,40,b% + to put%,20)
Var txt_Ergebnis& = Create("TextR",%hwnd,"",5 + to put% * x%,80,b%,20)
Var txt_Nr2ABC& = Create("TextR",%hwnd,"",5 + to put% * x%,140,b%,20)
Set("Decimals",0)

WhileLoop 0,to put%-1

    SetText txt&[to put%-1 - &Loop],Str $(26^&Loop)

Wend

Randomize

While 1

    WaitInput
    focushdl& = %getfocus

    WhileLoop 0,to put%-1

        Case focushdl& = cb&[&Loop]:focus% = &Loop

        If focushdl& = btn&[&Loop]

            focus% = &Loop

        EndIf

    Wend

    If %key = 2

        Break

    ElseIf GetFocus(cb&[focus%])

        Case GetCurSel(cb&[focus%]) > -1:Text_setzen(cb&[focus%],txt&[focus%],txt1&[focus%])

    ElseIf Clicked(btn&[focus%])

        Button_Aktion(btn&[focus%])

    ElseIf Clicked(btn&[to put%])

        Alle_Null(btn&[to put%])

    ElseIf %mousepressed = 2

        CreateMenu
        AppendMenu 100,"Summe kopieren"
        AppendMenu 101,"Buchstaben kopieren"
        TrackMenu %mousex,%mousey

        If MenuItem(100)

            ClearClip
            PutClip GetText$(txt_Ergebnis&)

        ElseIf MenuItem(101)

            ClearClip
            PutClip GetText$(txt_Alphabet&)

        EndIf

    EndIf

Wend


here's another List:
CompileMarkSeparation
Proc Nr2ABC

    Parameters number!
    Declare worth$,remainder%

    While number! > 0

        remainder% = number! Mod 26
        number! = number! \ 26

        If remainder% = 0

            number! = number! -1
            remainder% = 26

        EndIf

        Case remainder% > 0:worth$ = Chr$(remainder% + 64) + worth$

    Wend

    Return worth$

ENDPROC

Cls
ShowMax
Declare to put%[6],worth$[6],n%,a$,b$,OrdNr&,Header$,s$
Clear to put%[]
OrdNr& = 1
Var b% = %maxx \ 27 -1

WhileLoop 26

    s$ = s$ + Chr$(64 + &loop) + ";1;" + Str $(b%) + ";"

Wend

s$ = ";0;" + Str $(b%) + ";" + s$
Var l& = Create("GridBox",%hwnd,s$,0,2,2,Width(%hwnd)-4,Height(%hwnd)-4)

WhileLoop 26^2

    WhileLoop 26

        B$ = B$ + Nr2ABC(OrdNr&) + "|"
        Inc OrdNr&

    Wend

    AddStrings(l&,Str $(OrdNr&-26) + "|" + b$)
    Clear b$
    Window Title Str $(OrdNr&) + " patience - It's all right To 26^3 (" + Str $(Int(26^3)) + ")"

Wend

Window Title Str $(OrdNr&) + " patience - It's all right To 26^3 (" + Str $(Int(26^3)) + ") ready!"

While 1

    WaitInput

Wend


 
10/23/11  
 



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.311 Views

Themeninformationen

this Topic has 1 subscriber:

iF (1x)


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