module for the choice of options in programs
#1
A small module for the choice of options in your programs (key+mouse ok, but mouse wheel not in action here).
Shy

Code: (Select All)
'Optionator ' by Euklides
'A little selector of options in programs using mouse & key...
'----------------------------------------
'     The menu  of your program
'----------------------------------------
RESTART: Color 7, 0: Cls:
HVV = 8: Locate HVV - 1, 1: VID$ = "    ": ima$ = ""

Color 0, 7: Print "{MENU} (choice with mouse or key)"
Color 14, 0: Print VID$; "0/ESC  stop"
Print VID$; "1 Doing something interesting here"
Print VID$; "2 Here, come here "
Print VID$; "3 Start a game, for instance"
Print VID$; "4 Do you want something ?"
Print VID$; "5 Access to many options "
Print VID$; "6 and so on number 6"
Print VID$; "7 doing this or that !"
Print VID$; "8 and so on number 8"
Print VID$; "9 and so on number 9"
MousyComeOn: Color 7, 0: Locate 22, 1: Print String$(79, 32);
GoSub souriskey
'----------------------------------------
'  Understanding your choice
'----------------------------------------

If clicko = 0 And z$ = "" Then GoTo MousyComeOn
If clicko = 0 Then numac = Val(z$): clicy = numac + HVV
If clicko > 0 Then numac = clicy - HVV

If human > 0 Then If z$ = Chr$(27) Then z$ = "0"
If numac < 0 Then Clear: GoTo RESTART


BB$ = "": For h = 1 To 75: BB$ = BB$ + Chr$(Screen(clicy, h)): Next h
BB$ = _Trim$(BB$): If BB$ = "" Then GoTo RESTART
Locate clicy, 1: Color 0, 5: Print VID$; BB$
If InStr(BB$, "{MENU}") > 0 Then GoTo RESTART:
showchoice: Locate 22, 1: Print BB$

'----------------------------------------
'  Here you write your modules
'----------------------------------------
'choice: O/ESC stop
If Val(BB$) = 0 Or BB$ = "0/ESC  stop" Then Cls: Print "Program stops now": Sleep: End

'case 1:
If Val(BB$) = 1 Or BB$ = "Doing something interesting here" Then
    Print "Here please write your program...."
End If

'----------------------------------------
'And so on here...
'----------------------------------------


Sleep:
Stop



'----------------------------------------
'  SP whith mouse or key working...
souriskey:
human = 0: clicko = 0: wheel = 0: OKDBLCLICK = 0
videx: If _MouseInput Then _Delay .01: GoTo videx
Souriskey2: z$ = InKey$: If z$ <> "" Then human = 1: Return
If _MouseInput Then
    If Not _MouseWheel Then
        xsouris = Int(_MouseX + .5): ysouris = Int(_MouseY + .5)
        MOUVSOURI$ = Right$(Str$(ysouris + 100), 2) + "s" + Right$(Str$(xsouris + 100), 2)
        If _MouseButton(1) Or _MouseButton(3) Then
            clicko = 1: human = 3: clicx = xsouris: clicy = ysouris
            'test double clic  6/10 seconde
            If Timer - timsouris < .6 Then
                If ysouris - msqv = NUMREPOsouris Then
                    If xsouris > BORDTABGAUCHE And xsouris < BORDTABDROIT And ysouris > BORDTABHAUT And ysouris < BORDTABBAS Then
                        OKDBLCLICK = 1
                    End If
                End If
            End If
            timsouris = Timer: NUMREPOsouris = ysouris - msqv:
        End If
    End If
    If _MouseWheel Then wheel = _MouseWheel: human = 3: clicko = 1
loopy: End If:
If human = 0 Then GoTo Souriskey2
Return
'----------------------------------------
Why not yes ?
Reply
#2
What does "RESTART" do? What is to be done with "MOUVSOURI$" value?
Reply
#3
* Restart: begings the program again. Only a label...
* 'Souriskey' is a sub I use in many time in my programs. I dit not change it especially here
So:
- "mouvsouri$" is not used in this program
- the variable"wheel" if not used too here...
Shy
Why not yes ?
Reply
#4
I didn't see "RESTART" in three other places in the program. My bad...

I tested this on Linux but when I try to use one of the arrow keys it has the same effect as pressing escape key. I looked into the subroutine code and discovered "human" variable is set to one when a key is pressed, but farther up it's checked to see if it's non-zero for a press of escape. I changed the line with "if human > 0" but got the same result.

Forgive me if this isn't finished.
Reply




Users browsing this thread: 2 Guest(s)