AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Powerbasic 1 zeilen problem

Ein Thema von EWeiss · begonnen am 6. Jun 2008 · letzter Beitrag vom 8. Jun 2008
Antwort Antwort
Seite 1 von 2  1 2      
EWeiss
(Gast)

n/a Beiträge
 
#1

Powerbasic 1 zeilen problem

  Alt 6. Jun 2008, 19:28
habe ein problem mit einer zeile in dieser Funktion
wenn jemand sich in PB auskennt ..

Wie muss ich die in Delphi interpretieren.

Code:
'// Send/recept message to/from plugin
Function BBP_Plugin(ByRef BBP As BBPLUGIN) As Long
    LOCAL hProc AS DWORD, nRet AS LONG
    nRet = %BBP_ERROR
    If glRC Then
       hProc = BBP_ProcHandle(0, 0): IF hProc THEN CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet
    End If
    FUNCTION = nRet
End Function
um diese zeile geht es
Code:
BBP_ProcHandle(0, 0): IF hProc THEN CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet
gruss Emil
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#2

Re: Powerbasic 1 zeilen problem

  Alt 6. Jun 2008, 19:56
Hallo Emil,

irritiert dich der Doppelpunkt?

In PowerBasic (u.a.) können mehrere Statements in eine Zeile geschrieben werden, wenn man sie mit dem Statement Separator (Doppelpunkt) voneinander trennt.

Freundliche Grüße
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#3

Re: Powerbasic 1 zeilen problem

  Alt 6. Jun 2008, 20:06
Zitat von marabu:
Hallo Emil,

irritiert dich der Doppelpunkt?

In PowerBasic (u.a.) können mehrere Statements in eine Zeile geschrieben werden, wenn man sie mit dem Statement Separator (Doppelpunkt) voneinander trennt.

Freundliche Grüße
Hi
Nein eigentlich nicht denn das ist mir unter VB bekannt
Was mich irritiert ist diese zeile (sorry) -->

Delphi-Quellcode:
glRC : HGLRC;
hProc : LongInt;

BBP_ProcHandle ist ne Function stellt kein problem dar.
BBP_Plugin(BBP) das auch nicht.
Code:
    If glRC <> 0 Then
       hProc := BBP_ProcHandle(0, 0);
       if hProc <> 0 then
         --> CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet

CALL DWORD hProc USING und das ganze nach nRet
das irritiert mich.

Meine vermutung! Führe BBP_Plugin(BBP) oder nRet aus
Wenn dann in welchen zusammen hang wie wird geprüft ob nun die Funktion oder aber nRet
maßgeblich ist.

EDIT:
Auch ist die Schnittstelle etwas unverständlich..
Habe mich in dem Forum angemeldet allerdings kann mir da wegen meinen schlechten Englisch kaum jemand helfen..


Code:
//Yes, BassBox has a plugin interface, and you can find the full history of the project there:
//http://www.jose.it-berater.org/smfforum/index.php?topic=1364.0
 
//Each of the BassBox plugin in an independant plain Win32 DLL that does use one single exported function,
//that works like a standard SDK Window Proc.
 
'// The main exported plugin's function would be bbProc, like this:
FUNCTION BBProc ALIAS "BBProc" (BYREF BBP AS BBPLUGIN) EXPORT AS LONG
    LOCAL nRet AS LONG
    nRet = %BBP_SUCCESS
    SELECT CASE LONG BBP.Msg
    CASE %BBP_RENDER
         '// Draw the scene using BBP.LeftPeak and BBP.RightPeak
    CASE %BBP_CREATE
         '// Retrieve plugin details
         BBP.Title   = "My BB plugin"
         BBP.Author  = "My Name"
         BBP.Version = MAKDWD(1, 0) '// Version 1.0"
         BBP.RenderTo = %BBP_OPENGL   '// or %BBP_GDIPLUS, or %BBP_DIRECTX
    CASE %BBP_INIT
         '// Do your code initialisation there
    CASE %BBP_SIZE
         '// The size of the view port has changed.
    CASE %BBP_KEYBOARD
         '// Handle all Windows keyboard messages there
         Msg = BBP.WinMsg
         wParam = BBP.wParam
         lParam = BBP.lParam
    CASE %BBP_MOUSE
         '// Handle all Windows mouse messages there
         Msg = BBP.WinMsg
         wParam = BBP.wParam
         lParam = BBP.lParam
    CASE %BBP_DESTROY
         '// Free up your resources there
    CASE ELSE
        nRet = %BBP_ERROR
    END SELECT
    FUNCTION = nRet
END FUNCTION

//And to communicate with the plugin.dll, the main EXE uses this structure type:
 
TYPE BBPLUGIN                  '// 256 bytes
    Msg         AS LONG       '// The plugin's message (see above constant list).
    ParentWindow AS LONG       '// The parent window handle.
    DC          AS LONG       '// The parent window DC (while in play mode).
    RC          AS LONG       '// The parent OpenGL RC (while in play mode).
    Lpeak       AS WORD       '// The left audio channel peak value (while in play mode).
    Rpeak       AS WORD       '// The right audio channel peak value (while in play mode).
    Title       AS ASCIIZ * 32 '// Plugin's name or title.
    Author      AS ASCIIZ * 64 '// Plugin's author name.
    Version     AS DWORD      '// LOWRD major, HIWRD minor.
    RenderTo    AS LONG       '// %BBP_GDIPLUS, %BBP_OPENGL, %BBP_DIRECTX.
    BackARGB    AS LONG       '// Default ARGB color background.
    FFTdata     AS DWORD      '// DWORD pointer to the FFT() AS SINGLE array.
    FFTsize     AS WORD       '// Size of the FFT array.
 
    WinMsg      AS LONG       '// True Windows message.
    wParam      AS LONG       '// wParam
    lParam      AS LONG       '// lParam
   
    WIMdata     AS DWORD      '// DWORD pointer to the wave MM_WIM_DATA.
    MediaLength AS DWORD      '// Media length.
    MediaPos    AS DWORD      '// Media pos.
 
    Reserved    AS ASCIIZ * 98 '// Reserved for future extension.
END TYPE
 
//The name of the procedure being used in the main EXE to communicate with the active plugin is BBP_Plugin (BYREF BBP AS BBBPLUGIN)
 
//In BassBox, all the plugins are closely tied to the BassChannelGetLevel API to perform real time audio visualization.
Übersetzung ansicht kein problem (soweit fertig)
Nur wo gehts nach außen und wo wird was empfangen...(von der Winproc abgesehen)

gruss Emil
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#4

Re: Powerbasic 1 zeilen problem

  Alt 6. Jun 2008, 21:17
Code:
--> CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet
So wird in PowerBasic eine DLL-Funktion dynamisch aufgerufen. in hProc steht die Adresse (GetProcAddress()) der Funktion, BBP_Plugin ist der function prototype und BBP soll als Argument übergeben werden. Der Rückgabewert der Funktion soll in nRet gespeichert werden.
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#5

Re: Powerbasic 1 zeilen problem

  Alt 6. Jun 2008, 21:26
Zitat von marabu:
Code:
--> CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet
So wird in PowerBasic eine DLL-Funktion dynamisch aufgerufen. in hProc steht die Adresse (GetProcAddress()) der Funktion, BBP_Plugin ist der function prototype und BBP soll als Argument übergeben werden. Der Rückgabewert der Funktion soll in nRet gespeichert werden.
Danke werd es mal umsetzen

gruss Emil
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#6

Re: Powerbasic 1 zeilen problem

  Alt 7. Jun 2008, 14:54
Komme trotzdem irgenwie nicht klar

BBP zeigt auf die Struct(record) PBBPlugin
Das handle ist ja bekannt kann es also direkt übergeben.

function BBP_Plugin(BBP : PBBPLUGIN; handle: HVIS): LongInt;
Ich übergebe jetzt der BBP.MSG den wert BBP_CREATE
Zitat:
BBP_CREATE = 2; // Retrieve Title, Name, Version, Render mode.
BassBoxInfo.Msg := BBP_CREATE; weiss nun nicht wie ich BBP_Plugin(BBP) innerhalb BBP_Plugin aufrufen soll das hätte doch einen loop zur folge.
Es sollte doch zumindest ein export oder ein cdecl vorhanden sein oder ?

Schon ein bißchen unverständlich das ganze.
Was mir also fehlt ist die ein und ausgabe, kommunikation mit der DLL
Das andere werde ich auf die reihe bekommen da PowerBasik doch VB sehr ähnlich ist.

Auch ist mir unverständlich wie die neuen Daten des records von der DLL übergeben werden also Titel, name, Version .. usw.
In nRet steht ja dann nur ob der aufruf erfolgreich war BBP_SUCCESS = 0 oder BBP_ERROR = -1

gruss Emil
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#7

Re: Powerbasic 1 zeilen problem

  Alt 7. Jun 2008, 20:38
Hallo Emil,

ich weiß nicht wo du einen rekursiven Aufruf von BBP_Plugin() siehst.

Irgendwo musst du etwas ähnliches wie das hier gemacht haben:

Delphi-Quellcode:
const
  LIB_NAME = '?';

type
  TBbpPluginRec = record
    Msg: Integer;
    ParentWindow: Integer;
    DC: Integer;
    // ...
  end;

  TBbpPluginFunc = function (var bbp: TBbpPluginRec): Integer;

var
  BbpPluginFunc: TBbpPluginFunc;
  hLib: THandle;

begin
  // hLib := LoadLibrary(LIB_NAME);
  // error check ...
  @BbpPluginFunc := GetProcAddress(hLib, 'BBP_Plugin');
  // ...
end
Der Code aus deinem Beitrag #1 kapselt einfach den dynamischen Aufruf der DLL-Funktion:

Delphi-Quellcode:
function BBP_Plugin(var bbp: TBbpPluginRec): Integer;
begin
  // ...
  Result := BbpPluginFunc(bbp);
end;
Die Werte für Author, Title etc. werden im Record bbp zurückgegeben.

Gute Nacht
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#8

Re: Powerbasic 1 zeilen problem

  Alt 7. Jun 2008, 22:19
Jo so habe ich es gemacht

TBbpPluginFunc = function (var bbp: TBbpPluginRec): Integer; andere namen aber egal...

Der unterschied bei mir kein "var" vor bbp(deshalb keine rückgabe) und ein angehängtes stdcall
TBbpPluginFunc = function (var bbp: TBbpPluginRec): Integer; stdcall; ohne stdcall bekomme ich ein BBP_ERROR = -1;
mit bekomme ich als rückgabe BBP_SUCCESS = 0;

sobald aber BBP_Plugin verlassen wird kracht es muss noch nachsehn warum

EDIT:
Sieht danach aus das der im record definierte
Titel und Author das problem verursacht

ursprünglich definiert
Delphi-Quellcode:
Title AS ASCIIZ * 32 '// Plugin's name or title.
Author AS ASCIIZ * 64 '// Plugin's author name.
habe an stelle dessen string[32] genommen dann kracht es
nehme ich PChar dann läuft es durch der text ist dann aber "nil" steht nix drin.
Muss noch schaun was ich bei den nullterminierten ASCIIZ in Delphi nehmen kann

EDIT2:
verbunden bin ich jetzt aber die strings machen immer noch probleme
weiss nicht was ich da nehmen soll.

aktuelle abfrage
Delphi-Quellcode:
function BASS_BASSBOXVIS_GetName(handle: HVIS): PChar; stdcall;
var
  nRet : Integer;

begin
  Result := nil;
  // Initialize BassBoxInfo
  BassBoxInfo := PBbpPluginRec(handle);

  // check is valid handle
  if (not BB_ValidHandle(handle)) then
  begin
    BassFuncs^.SetError(BASS_ERROR_HANDLE);
    Exit;
  end;

  // send BBP_CREATE Retrieve Title, Name, Version, Render mode.
  BassBoxInfo.Msg := BBP_CREATE;

  nRet := BBP_Plugin(BassBoxInfo^);
  if nRet = BBP_ERROR then
    begin
      FreeLibrary(handle);
      FreeMem(BassBoxInfo);

      BassFuncs^.SetError(BASS_ERROR_START);
      Exit;
    end else

  BassFuncs^.SetError(BASS_OK);
  Result := PChar(Length(BassBoxInfo^.Title));

end;
Siehe Pic ..

gruss Emil
Miniaturansicht angehängter Grafiken
ss_164.jpg  
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#9

Re: Powerbasic 1 zeilen problem

  Alt 8. Jun 2008, 08:21
Moin Emil,

ob stdcall oder nicht, das kannst nur du wissen, da ich die DLL nicht kenne.

Bei den Strings musst du wissen, dass "Title AS ASCIIZ * 32" in Delphi weder mit string noch mit string[32] identisch ist. Es ist einfach ein "Title: Array [0..31] of Char", auf den du mit String(Title) zugreifst.

Schönen Sonntag
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#10

Re: Powerbasic 1 zeilen problem

  Alt 8. Jun 2008, 08:35
Zitat von marabu:
Moin Emil,

ob stdcall oder nicht, das kannst nur du wissen, da ich die DLL nicht kenne.
Schönen Sonntag
Ja das ist klar .. kannst du nicht wissen

Zitat:
Bei den Strings musst du wissen, dass "Title AS ASCIIZ * 32" in Delphi weder mit string noch mit string[32] identisch ist. Es ist einfach ein "Title: Array [0..31] of Char", auf den du mit String(Title) zugreifst.
Danke ist schon verflixt wenn man nicht weis welche variablen in Delphi verwendet werden.

Auch dir einen schönen Sonntag
gruss Emil
PS: Dann doch was länger als nur eine Zeile ups..
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:08 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz