CHAIN command not working
#4
It works for me anyway. "Shared" must be used when transferring to an external function in the called program. Otherwise not necessary.

Program 1
Code: (Select All)
'Beispiel fuer Chain. - 8. Juli 2022
'Aufruf einer externen Funktion die
'den GGT berechnet

Common Shared Zahl1, Zahl2 As Long

Print
Print "Berechnet den GGT zweier Zahlen"
Print

Input "Zahl 1: ", Zahl1
Input "Zahl 2: ", Zahl2

'Ruft externes Programm auf das mit
'den Zahlen den GGT berechnet
Chain "GGT-externe-Funktion"

End

Program 2 (Will be called.)
Code: (Select All)
'Wird von "Aufruf-externe-FunktionGGT" aufgerufen - 8. Juli 2022
'Berechnet mit den uebergebenen Zahlen
'den GGT

'Geht nur mit dem Schluesselwort "Shared"
Declare Function ggt(zahl1, zahl2 as Long) as Long

Common Shared Zahl1, Zahl2 As Long

Print: Print
Print Using "Der gemeinsame Teiler von ##### und ##### ist: ####"; Zahl1, Zahl2, ggt(Zahl1, Zahl2)

End 'Externes Hauptprogramm

Function ggt (zahl1, zahl2 As Long)

  Dim temp As Long

  While (zahl1 > 0)
    If (zahl1 < zahl2) Then
      temp = zahl1: zahl1 = zahl2: zahl2 = temp
    End If
    zahl1 = zahl1 - zahl2
  Wend
  ggt = zahl2

End Function

[Image: Extern-GGT2022-08-08.jpg]
Reply


Messages In This Thread
CHAIN command not working - by TerryRitchie - 08-08-2022, 04:02 AM
RE: CHAIN command not working - by bplus - 08-08-2022, 03:00 PM
RE: CHAIN command not working - by mdijkens - 08-08-2022, 03:28 PM
RE: CHAIN command not working - by mnrvovrfc - 08-08-2022, 10:47 PM
RE: CHAIN command not working - by Kernelpanic - 08-08-2022, 04:04 PM
RE: CHAIN command not working - by TerryRitchie - 08-08-2022, 08:07 PM
RE: CHAIN command not working - by Kernelpanic - 08-08-2022, 08:56 PM
RE: CHAIN command not working - by TerryRitchie - 08-08-2022, 09:25 PM
RE: CHAIN command not working - by SMcNeill - 08-08-2022, 11:34 PM
RE: CHAIN command not working - by Pete - 08-09-2022, 06:09 AM
RE: CHAIN command not working - by TempodiBasic - 08-12-2022, 05:35 PM
RE: CHAIN command not working - by TempodiBasic - 09-01-2022, 12:13 AM
RE: CHAIN command not working - by Udix - 11-01-2022, 01:31 PM



Users browsing this thread: 8 Guest(s)