SELECT CASES ???
#32
Quote:SMcNeill - Because FUNCTIONS *have* to be returned to a variable or used in conjecture with a SUB style command such as PRINT.

You're right! - I are gone through everything(?) what crossed my mind of now, but the damn picture just won't show. Look at Case 3 Maybe that's not possible. . . Maybe no new console can be opened from a program? That would be practically two.

The sub routine is this program that works. https://staging.qb64phoenix.com/showthre...39#pid7939
And both are in the same directory. The image can be found as basic, but if a new output console cannot be opened, it is of no use.

Code: (Select All)
$Console:Only

Option _Explicit

'Definition der Datenstruktur - Direktzugriff
Type MotorradModell
  Modell As String * 20
  Farbe As String * 10
  Hubraum As String * 10
  Kilowatt As String * 10
  Fahrgewicht As String * 10
  Preis As Double
End Type

'Global zur Verfuegung stellen, sonst wird es
'wirklich kompliziert
Dim Shared Motorrad As MotorradModell

Declare Sub Eingabe()
Declare Sub Lesen()
Declare Sub Bildzeigen(SatzNummer as Integer)
Declare Function SatzLesen()

Dim As Integer auswahl, SatzNummer

Nochmal:
Cls
auswahl = 0
Locate 3, 4
Print "Waehlen Sie das gewuenschte Programm."
Locate 6, 10
Print "In Datei schreiben    -> 1"
Locate 7, 10
Print "Datei lesen           -> 2"
Locate 8, 10
Print "Bestimmten Satz lesen -> 3"
Locate 9, 10
Print "Programm beenden      -> 4"

Locate 11, 4
Input "Ihre Wahl bitte: ", auswahl
Print

Select Case auswahl
  Case 1
    Call Eingabe
  Case 2
    Call Lesen
  Case 3
    'SatzNummer = SatzLesen
    'Call Bildzeigen(SatzNummer)
    Call Bildzeigen(SatzLesen)
  Case 4
    End
  Case Else
    Beep: Locate 12, 4
    Print "Falsche Eingabe!"
    Sleep 1
    GoTo Nochmal
End Select

End 'Hauptprogramm

'Neue Datei erstellen und Daten einlesen
Sub Eingabe

  Dim As Integer SatzNummer
  Dim As String Antwort

  Open "Motorrad.Dat" For Random As #1 Len = Len(Motorrad)

  SatzNummer = LOF(1) \ Len(Motorrad)

  'Neue Datensaetze hinzufuegen
  Do
    Input "Modell     : ", Motorrad.Modell
    Input "Farbe      : ", Motorrad.Farbe
    Input "Hubraum    : ", Motorrad.Hubraum
    Input "Kilowatt   : ", Motorrad.Kilowatt
    Input "Fahrgewicht: ", Motorrad.Fahrgewicht
    Input "Preis      : ", Motorrad.Preis

    SatzNummer = SatzNummer + 1

    'Datensatz in Datei schreiben
    Put #1, SatzNummer, Motorrad

    'Sollen weitere Daten eingegeben werden?
    Input "Weiter J/N: ", Antwort$
  Loop Until UCase$(Antwort$) = "N"

  Close 1#
End Sub

'Datensaetze sequentiell auslesen (alle)
Sub Lesen

  Dim As Integer AnzahlSaetze, SatzNummer

  Open "Motorrad.Dat" For Random As #1 Len = Len(Motorrad)

  'Anzahl der Datensaetze berechnen
  AnzahlSaetze = LOF(1) \ Len(Motorrad)

  'Datensaetze lesen und anzeigen
  For SatzNummer = 1 To AnzahlSaetze
    Get #1, SatzNummer, Motorrad

    'Daten anzeigen
    Print Tab(4); "Modell     : ", Motorrad.Modell
    Print Tab(4); "Farbe      : ", Motorrad.Farbe
    Print Tab(4); "Hubraum    : ", Motorrad.Hubraum
    Print Tab(4); "Kilowatt   : ", Motorrad.Kilowatt
    Print Tab(4); "Fahrgewicht: ", Motorrad.Fahrgewicht
    Print Tab(4); Using "Preis      : #####.##"; Motorrad.Preis
    Print
    Print Tab(4); "---------------------------------"
    Print
  Next

  Close 1#
End Sub

Function SatzLesen ()

  Const Falsch = 0, Wahr = Not Falsch
  Dim As Integer AnzahlSaetze, BestimmterSatz, SatzNummer

  Open "Motorrad.Dat" For Random As #1 Len = Len(Motorrad)

  'Anzahl der Datensaetze berechnen
  AnzahlSaetze = LOF(1) \ Len(Motorrad)
  BestimmterSatz = Wahr

  Do
    Print
    Print Tab(4); "Satznummer: ";
    Print "(Null zum Beenden): ";
    Input " ", SatzNummer

    'Warum "AnzahlSaetze + 1"? War intuitiv!
    If SatzNummer > 0 And SatzNummer < AnzahlSaetze + 1 Then
      Get #1, SatzNummer, Motorrad

      'Bestimmten Datenssatz anzeigen
      Print
      Print Tab(4); "Modell     : ", Motorrad.Modell
      Print Tab(4); "Farbe      : ", Motorrad.Farbe
      Print Tab(4); "Hubraum    : ", Motorrad.Hubraum
      Print Tab(4); "Kilowatt   : ", Motorrad.Kilowatt
      Print Tab(4); "Fahrgewicht: ", Motorrad.Fahrgewicht
      Print Tab(4); Using "Preis      : #####.##"; Motorrad.Preis
    ElseIf SatzNummer = 0 Then
      AnzahlSaetze = Falsch
    Else
      Print: Print: Beep: Print Tab(4); "Satznummer ausserhalb des Bereichs!"
    End If
  Loop While BestimmterSatz = 0
  SatzLesen = SatzNummer
End Function

Sub Bildzeigen (SatzNummer As Integer)
  'Bild in neuem Fenster aufrufen

  Dim Bild As Long, myFont As Long
  Dim Text As String
  ', Text2 As String


  'Input "Satznummer: ", SatzNummer

  If SatzNummer = 1 Then
    Screen _NewImage(800, 600, 32)
    Cls
    'Neue Farbe setzen
    Color _RGB32(255, 165, 0), _RGB32(0, 0, 0)

    Bild = _LoadImage("..\Bilder\Yamaha-250-1965.jpg")

    'Neues Fenster - Bildgroesse fuer mittig
    _PutImage (((800 - 689) / 2), 15), Bild

    Text = "Die Yamaha als Zweitakter mit 250 ccm - 1965"
    'Text2 = " and leaves before she is left."
    myFont = _LoadFont("C:\Windows\Fonts\Tahoma.ttf", 25, "")
    _Font myFont

    'Zeile, Spalte und die Bildhoehe(!) beruecksichtigen
    _PrintString (135, 490), Text
    '_PrintString (256, 537), Text2

    'Farbe und Schrift zuruecksetzen
    Color _RGB32(255), _RGB32(0, 0, 0)
    _Font 16
    _FreeFont myFont

  End If
End Sub
Reply


Messages In This Thread
SELECT CASES ??? - by Pete - 10-16-2022, 07:55 PM
RE: SELECT CASES ??? - by SMcNeill - 10-16-2022, 08:48 PM
RE: SELECT CASES ??? - by mnrvovrfc - 10-17-2022, 07:40 AM
RE: SELECT CASES ??? - by James D Jarvis - 10-16-2022, 08:49 PM
RE: SELECT CASES ??? - by SMcNeill - 10-16-2022, 09:07 PM
RE: SELECT CASES ??? - by Pete - 10-16-2022, 09:01 PM
RE: SELECT CASES ??? - by Pete - 10-16-2022, 09:12 PM
RE: SELECT CASES ??? - by SMcNeill - 10-16-2022, 09:23 PM
RE: SELECT CASES ??? - by Kernelpanic - 10-16-2022, 09:35 PM
RE: SELECT CASES ??? - by SMcNeill - 10-16-2022, 09:57 PM
RE: SELECT CASES ??? - by Pete - 10-16-2022, 10:28 PM
RE: SELECT CASES ??? - by Kernelpanic - 10-16-2022, 10:44 PM
RE: SELECT CASES ??? - by SpriggsySpriggs - 10-16-2022, 11:06 PM
RE: SELECT CASES ??? - by Pete - 10-16-2022, 11:42 PM
RE: SELECT CASES ??? - by SMcNeill - 10-17-2022, 01:34 AM
RE: SELECT CASES ??? - by Pete - 10-17-2022, 02:04 AM
RE: SELECT CASES ??? - by SpriggsySpriggs - 10-17-2022, 02:46 AM
RE: SELECT CASES ??? - by mnrvovrfc - 10-17-2022, 07:48 AM
RE: SELECT CASES ??? - by dbox - 10-17-2022, 03:46 AM
RE: SELECT CASES ??? - by SMcNeill - 10-17-2022, 05:21 AM
RE: SELECT CASES ??? - by DSMan195276 - 10-17-2022, 06:32 AM
RE: SELECT CASES ??? - by Pete - 10-17-2022, 06:41 AM
RE: SELECT CASES ??? - by DSMan195276 - 10-17-2022, 07:34 PM
RE: SELECT CASES ??? - by Pete - 10-17-2022, 08:28 AM
RE: SELECT CASES ??? - by RhoSigma - 10-17-2022, 09:29 AM
RE: SELECT CASES ??? - by Pete - 10-17-2022, 07:00 PM
RE: SELECT CASES ??? - by Kernelpanic - 10-17-2022, 08:15 PM
RE: SELECT CASES ??? - by SMcNeill - 10-17-2022, 09:44 PM
RE: SELECT CASES ??? - by Pete - 10-17-2022, 09:45 PM
RE: SELECT CASES ??? - by SMcNeill - 10-17-2022, 09:50 PM
RE: SELECT CASES ??? - by Pete - 10-17-2022, 10:05 PM
RE: SELECT CASES ??? - by Kernelpanic - 10-18-2022, 08:07 PM
RE: SELECT CASES ??? - by Pete - 10-18-2022, 08:38 PM
RE: SELECT CASES ??? - by Kernelpanic - 10-18-2022, 08:49 PM
RE: SELECT CASES ??? - by Pete - 10-18-2022, 09:33 PM
RE: SELECT CASES ??? - by Kernelpanic - 10-19-2022, 06:32 PM
RE: SELECT CASES ??? - by Pete - 10-19-2022, 06:39 PM



Users browsing this thread: 1 Guest(s)