10-30-2023, 09:57 PM
Can one also integrate the declaration of a library into a function?
The reason for the question is that I wrote a small program that allows one to use the tenary operator from C. If you could put the whole thing into a function, it might be useful for Basic. Maybe.
The Basic-Program:
The C part:
The reason for the question is that I wrote a small program that allows one to use the tenary operator from C. If you could put the whole thing into a function, it might be useful for Basic. Maybe.
The Basic-Program:
Code: (Select All)
'Aufruf des tenaeren Operators in C - 30. Okt. 2023
Option _Explicit
'In QB64 mit "Declare Library" wie angegeben
Declare Library "D:\Lab\QuickBasic64\Extern-nicht-Basic\C-Aufruf\tenaerOp"
Function tenaerOp& (ByVal N As Long, Byval X As Long)
End Declare
Dim As Long N, X
X = 77
Locate 3, 3
Input "Zahl: ", N
Locate 5, 3
Print Using "Ausgabe: ###"; tenaerOp&(N&, X&)
End
The C part:
Code: (Select All)
//TenaerenOperator von Basic aufrufen - 30. Okt. 2023
#include <stdio.h>
#include <stdlib.h>
long tenaerOp(long eingabe, long x)
{
long ausgabe;
ausgabe = x > eingabe ? 100 : 200;
return(ausgabe);
}