Alpha Video Training
Results 1 to 12 of 12

Thread: Calling conventions of dll's

  1. #1
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default Calling conventions of dll's

    Hi,

    What calling convention uses Alpha Five for external functions in DLL's. Is that cdelc or stdcall?

    Thanks for any help.

    Marcel

  2. #2
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default RE: Calling conventions of dll's

    Sorry, cdelc must be cdecl.

  3. #3
    Former Alpha Employee Edward Larrabee's Avatar
    Real Name
    Edward Larrabee
    Join Date
    Nov 2002
    Location
    New Hampshire
    Posts
    1,385

    Default RE: Calling conventions of dll's

    Have you taken a look at this topic in the web help?

    http://support.alphasoftware.com/xbasic_reference/language/declare.htm

  4. #4
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default RE: Calling conventions of dll's

    Hi Edward,

    Yes I did, but it is not the solution for me.

    I have a program language with which I can make my own dll. I can choose to make a dll with the calling convention "cdecl" or "stdcall". It has to do with the sequence of the parameters on the stack and who does the clean up of the stack.

    In this case I have to know how Alpha the parameters treats of the declare statement when they're put on the stack.

    Thanks for any help,

    Marcel

  5. #5
    John Panagia
    Guest

    Default RE: Calling conventions of dll's

    Marcel,

    I'm pretty sure it's STDCALL. I wrote a couple of functions in a delphi dll and they are "stdcall'.

    Good luck!
    John Panagia

  6. #6
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default RE: Calling conventions of dll's

    John, Thanks a lot.

    Marcel

  7. #7
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default RE: Calling conventions of dll's

    Hi John,

    Thanks, it's been succesful

    The next PureBasic external function is succesfull called from Alpha Five:

    ProcedureDLL EasyRequester(Message$)
    MessageRequester("EasyRequester !", Message$, #MB_ICONINFORMATION)
    EndProcedure

    With the following Alpha Code:

    'Date Created: 28-Jun-2003 10:15:17 PM
    'Last Updated: 01-Jul-2003 06:24:57 PM
    'Created By :M.Kollenaar
    'Updated By :

    declarestruct text C255text
    declare pb EasyRequester L(text)
    dim string as P
    string.text = "Hi"
    EasyRequester(string)

    Again, thanks a lot!

    Now I have a reference point to start with!

    Marcel

  8. #8
    John Panagia
    Guest

    Default RE: Calling conventions of dll's

    Marcel,

    Great, I'm glad it worked.

    Looking at your Alpha code confuses me. I've seen it before and it always makes me think to hard.

    Your decs:
    declarestruct text C255text
    declare pb EasyRequester L(text)
    dim string as P

    string is a pointer with a sub-field of "Text" or is it being type-cast as Text. How does A5 associate the string and the text declaration?

    Then you set a value and call you function:

    string.text = "Hi"
    EasyRequester(string)

    How does EasyRequester find the text field? Is it just looking at the beginning of the variable string?

    I realize this is an Alpha thing, I just have trouble grasping it.

    Thanks

  9. #9
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default RE: Calling conventions of dll's

    Hi John,

    Thanks for your reply. I will explain what and why I did what I did. I'm a novice in Alpha/XBasic so the confusion is not as rare as you think. I started last week with a piece of code from http://learnalpha.com/PieCharts/PieCharts.htm. Peter Wayne made an example analog at some visual basic code and made a translation to XBasic. I took this as an example.

  10. #10
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default RE: Calling conventions of dll's

    Is this a better approach?


    '--------------------------------------------
    'Date Created: 28-Jun-2003 10:15:17 PM
    'Last Updated: 01-Jul-2003 11:09:44 PM
    'Created By :M.Kollenaar
    'Updated By :

    declarestruct text C255text
    declare pb EasyRequester L(text)
    dim string as {text}
    string.text = "Hi, put some text here!"
    EasyRequester(string)
    '--------------------------------------------


    Marcel

  11. #11
    John Panagia
    Guest

    Default RE: Calling conventions of dll's

    Marcel,

    If that works it is much more understandable. I wasn't suggesting you change the code. I was trying to understand what seems to be a common enough coding practice using A5. For me the issue is the programmer must except something at face value that is not obvious. Any experienced programmer that has never used Alpha will look at this kind of thing and say, Ouch!

    Thanks for your explanation

    John

  12. #12
    "Certified" Alphaholic Marcel Kollenaar's Avatar
    Real Name
    Marcel
    Join Date
    Apr 2003
    Location
    Twente
    Posts
    1,514

    Default RE: Calling conventions of dll's

    Hi,

    Yes, I got it working. I wrote a piece of code in PureBasic, made a DLL of it and called it from Alpha Five. XBasic can't find files with attributes set to NORMAL. This one does!

    ; Information
    ; Name: pbAttrib.dll
    ; Synopsis: pbAttrib(Path.s,FileName.s,FileAttributes.s)
    ; Parameters: Path.s Path to the directory where files resides.
    ; FileName Filename or wildcards: *.txt, a*.?x?
    ; FileAttributes one of the collection AaRrSsHh
    ; Uppercase set an attribute, lowercase reset an attribute.
    ; Returns: nothing
    ; Globals: None
    ; Description: An alternative external function to set and reset file attributes
    ; for Alpha Five.

    ; File Attribute Constants
    ; #PB_FileSystem_Hidden: File is hidden
    ; #PB_FileSystem_Archive: File has been archived And not changed since the last time
    ; #PB_FileSystem_Compressed: File is compressed
    ; #PB_FileSystem_Normal: Normal attributes
    ; #PB_FileSystem_ReadOnly: File is in readonly mode
    ; #PB_FileSystem_System: File is a system file

    ProcedureDLL SetAttributes(Path.s, FileName.s, FileAttributesToChange.s)

    DefType.l FileAttributes, NewFileAttributes, pos
    DefType.s SingleAttribute

    If ExamineDirectory(0,Path,FileName)
    Repeat
    FileType = NextDirectoryEntry()
    ;
    ;-Existing Filetypes
    ; 0: no more entry in the directory
    ; 1: this entry is a file
    ; 2: this entry is a directory
    ;
    If FileType = 1
    FileName = DirectoryEntryName()
    MessageRequester("File: ",FileName,0)
    ;
    ; Process atributes
    ;
    FileAttributes = DirectoryEntryAttributes()

    For pos = 1 To Len(FileAttributesToChange)
    SingleAttribute = Mid(FileAttributesToChange,pos,1)
    Select SingleAttribute
    Case "a"
    If ((FileAttributes & #PB_FileSystem_Archive) = #PB_FileSystem_Archive)
    FileAttributes ! #PB_FileSystem_Archive ;XOR
    EndIf
    Case "A"
    If ((FileAttributes & #PB_FileSystem_Archive) = 0)
    FileAttributes | #PB_FileSystem_Archive ;OR
    EndIf
    Case "r"
    If ((FileAttributes & #PB_FileSystem_ReadOnly) = #PB_FileSystem_ReadOnly)
    FileAttributes ! #PB_FileSystem_ReadOnly ;XOR
    EndIf
    Case "R"
    If ((FileAttributes & #PB_FileSystem_ReadOnly) = 0)
    FileAttributes | #PB_FileSystem_ReadOnly ;OR
    EndIf
    Case "s"
    If ((FileAttributes & #PB_FileSystem_System) = #PB_FileSystem_System)
    FileAttributes ! #PB_FileSystem_System ;XOR
    EndIf
    Case "S"
    If ((FileAttributes & #PB_FileSystem_System) = 0)
    FileAttributes | #PB_FileSystem_System ;OR
    EndIf
    Case "h"
    If ((FileAttributes & #PB_FileSystem_Hidden) = #PB_FileSystem_Hidden)
    FileAttributes ! #PB_FileSystem_Hidden ;XOR
    EndIf
    Case "H"
    If ((FileAttributes & #PB_FileSystem_Hidden) = 0)
    FileAttributes | #PB_FileSystem_Hidden ;OR
    EndIf
    EndSelect
    Next pos
    MessageRequester("Debug","File: " + Path + FileName,0)
    If SetFileAttributes_(Path + FileName, FileAttributes) = 0
    MessageRequester("Setfileattributes","Failure",0)
    EndIf

    EndIf
    Until FileType = 0
    Else
    MessageRequester("Error","Can't examine this directory.",0)
    EndIf
    EndProcedure

    ;SetAttributes("C:\","*.txt","AR")

    End

    +++++++++++++++++ end of the PureBasic code +++++++++++++++

    The following Xbasic code calls the external function in the DLL. The function resets the attributes of *.txt files.

    ----------------- start of XBasic code --------------------
    'Date Created: 28-Jun-2003 10:15:17 PM
    'Last Updated: 04-Jul-2003 12:22:06 AM
    'Created By :M.Kollenaar
    'Updated By :

    declarestruct ptext C255ptext
    declarestruct ftext C255ftext
    declarestruct atext C255atext
    declare pbAttrib SetAttributes L(ptext)(ftext)(atext)

    ptemp.ptext="c:\\"
    ftemp.ftext="*.txt"
    atemp.atext="ar"

    result = SetAttributes(ptemp,ftemp,atemp)

    ---------------- end of XBasic code ------------------

    I want to thank all the users and Alpha people for the input.

    Marcel Kollenaar

Similar Threads

  1. Naming Conventions
    By Fletch in forum Alpha Five Version 5
    Replies: 7
    Last Post: 02-17-2007, 11:34 AM
  2. Generating error messages: conventions?
    By abackstrom in forum Alpha Five Version 6
    Replies: 2
    Last Post: 10-11-2005, 05:34 PM
  3. Naming conventions
    By Ohlen Cartmell in forum Alpha Five Version 5
    Replies: 9
    Last Post: 03-31-2004, 04:09 AM
  4. File Naming Conventions
    By kgilroy in forum Alpha Five Version 5
    Replies: 2
    Last Post: 10-10-2002, 10:42 AM
  5. Calling external DLL's/using activeX controls
    By Sue Piasecki in forum Alpha Five Version 4
    Replies: 6
    Last Post: 07-29-2000, 09:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •