New Users Questions.

Everything else that doesn't fall into one of the other PB categories.
swhite
Addict
Addict
Posts: 808
Joined: Thu May 21, 2009 6:56 pm

New Users Questions.

Post by swhite »

Hi

I downloaded some zip files from the PureArea.net website and they contained normal ".pb" files but several had files with no extensions and I wondered what to do with them. Several of the zip files included source code files with names that matched the files with no extension. When I looked at the source code they contained code for creating a DLL. So being relatively new to PB I wonder what to do with the files so I can use them. Any explanation about how this should work would be appreciated.

Secondly when compiling some code from one of these downloads I got a message saying that "Invalid name: same as external command" however, I cannot find the any reference to an external command. CreateObject was one name that cause this error. So what is the problem here?

Thirdly the complier complained about a deprecated function "SetErrorNumber()" is there a replacement for this function?

Fourthly it mentioned that the Purelibrary StringExtension is missing however I cannot find any reference to this in the source code so I want to know what this is about.

Thanks,
Simon
Simon White
dCipher Computing
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: New Users Questions.

Post by moogle »

Not sure about the no extension files, maybe the creator made them that way to be used in the PB code or something.

As for the error "Invalid name: same as external command", that just means that the procedure or macro in the code has the same name as a PureBasic command. So in that code find the offending procedure/macro and either rename it or hide it if it does what the PureBasic version does.

For deprecated functions search the helpfile and look at the History and Changes page. It should tell you what it's replacement is or if you no longer need it.


Not sure about the last problem.

Post the code or a link to what you downloaded so maybe others can see and help you with your problem.
Image
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: New Users Questions.

Post by IdeasVacuum »

Hi Simon, I think you are going to need to take one step at a time (= 1 add-on at a time). So, tell us about the one that's most important to you, then we can also download it and help you through the issues.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
swhite
Addict
Addict
Posts: 808
Joined: Thu May 21, 2009 6:56 pm

Re: New Users Questions.

Post by swhite »

This is the offending code. It is from the COMLIB_PB4.zip which also includes the extensionless files as well.

Code: Select all


Enumeration
  #CLSCTX_INPROC_SERVER  = 1
  #CLSCTX_INPROC_HANDLER = 2
  #CLSCTX_LOCAL_SERVER   = 4
  #CLSCTX_REMOTE_SERVER  = 16
  #CLSCTX_SERVER = (#CLSCTX_INPROC_SERVER | #CLSCTX_LOCAL_SERVER | #CLSCTX_REMOTE_SERVER)
EndEnumeration

Structure TYPEATTR
  guid.GUID
  lcid.l
  dwReserved.l
  memidConstructor.l
  memidDestructor.l
  lpstrSchema.l
  cbSizeInstance.l
  typekind.l
  cFuncs.w
  cVars.w
  cImplTypes.w
  cbSizeVft.w
  cbAlignment.w
  wTypeFlags.w
  wMajorVerNum.w
  wMinorVerNum.w
  tdescAlias.l
  idldescType.l
EndStructure

ProcedureDLL.l CreateObject(ProgID.s) ; Creates COM object from ProgID
  Protected ProgID_Unicode.s = Space(Len(ProgID) * 2)
  Protected err.l, lcid.l, aTypeAttributes.l, IID_OBJECT.l, object.l
  Protected CLSID.GUID
  Protected oDispatch.IDispatch
  Protected oDispTypeInfo.ITypeInfo
  Protected *oTypeAttributes.TYPEATTR

  PokeS(@ProgID_Unicode, ProgID, #PB_Any, #PB_Unicode)

  err.l = CLSIDFromProgID_(@ProgID_Unicode, @CLSID.GUID)
  If err <> #S_OK
    SetErrorNumber(err)
    ProcedureReturn #False
  EndIf

  err.l = CoCreateInstance_(CLSID,0,#CLSCTX_SERVER,?IID_IDispatch,@oDispatch.IDispatch)
  If err <> #S_OK
    SetErrorNumber(err)
    ProcedureReturn #False
  EndIf

  If oDispatch\GetTypeInfo(0,lcid,@oDispTypeInfo.ITypeInfo) = #S_OK
    If oDispTypeInfo\GetTypeAttr(@aTypeAttributes.l) = #S_OK
      *oTypeAttributes.TYPEATTR=aTypeAttributes
      IID_OBJECT = *oTypeAttributes\guid
      oDispTypeInfo\ReleaseTypeAttr(aTypeAttributes)
    EndIf
    oDispTypeInfo\Release()
  EndIf

  err.l = oDispatch\QueryInterface(IID_OBJECT,@object.l)
  If err <> #S_OK
    oDispatch\Release()
    SetErrorNumber(err)
    ProcedureReturn #False
  EndIf
  oDispatch\Release()

  ProcedureReturn object
EndProcedure

ProcedureDLL.l CreateObject_Unicode(ProgID.s)
  Protected ProgID2.s = PeekS(@ProgID, #PB_Any, #PB_Unicode)
  ProgID = ProgID2
  ProcedureReturn CreateObject(ProgID)
EndProcedure

ProcedureDLL ReleaseObject(*object.IUnknown) ; Releases Object from memory
  If *object
    *object\Release()
  EndIf
EndProcedure

ProcedureDLL COMLIB_PB4_Init()
  CoInitialize_(#Null)
EndProcedure

ProcedureDLL COMLIB_PB4_End()
  CoUninitialize_()
EndProcedure

DataSection
  IID_IDispatch:
  Data.l $00020400
  Data.w $0000, $0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection

DataSection
  IID_IUnknown:
  Data.l $00000000
  Data.w $0000, $0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection

Simon White
dCipher Computing
swhite
Addict
Addict
Posts: 808
Joined: Thu May 21, 2009 6:56 pm

Re: New Users Questions.

Post by swhite »

moogle wrote:Not sure about the no extension files, maybe the creator made them that way to be used in the PB code or something.

As for the error "Invalid name: same as external command", that just means that the procedure or macro in the code has the same name as a PureBasic command. So in that code find the offending procedure/macro and either rename it or hide it if it does what the PureBasic version does.

For deprecated functions search the helpfile and look at the History and Changes page. It should tell you what it's replacement is or if you no longer need it.


Not sure about the last problem.

Post the code or a link to what you downloaded so maybe others can see and help you with your problem.
I realized that it meant the name matched a PB reserved word except for the fact that I cannot find "CreatObject" anywhere in the documentation to know that it is a reserved word and yes I did rename it before I made my post and that did get past that error. However that resulted in the other errors I listed. I am just wondering where to find "CreateObject" as a reserved word.

Thanks,
Simon
Simon White
dCipher Computing
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: New Users Questions.

Post by c4s »

This looks like a plain UserLib to me. Put it in #PB_Compiler_Home + "\PureLibraries\UserLibraries\" and see if it works. Some error message like "missing StringExtension" often means that the UserLib is outdated and can't be used with that version of PureBasic...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Zach
Addict
Addict
Posts: 1678
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: New Users Questions.

Post by Zach »

For deprecated functions, there is not necesarilly a "replacement".. You just have to figure out what the function was used for in the code, and write your own Procedure that does what it was doing, if necesarry.. You should still be able to run such a program using a deprecated function, however.. I have come across this issue before when running example code that uses stuff like GadgetList(), which is no longer used. But the program still runs.

For the StringExtension thing, this is sadly part of the problem with compiled User Libraries that fall out of use or are no longer maintained by their Authors (disinterested, not here anymore, etc)

The only way to run a User Library like that, is to find out the specific version of PB it was coded for / compiled with, and download that version of PB from the PureBasic Archive on the main site. It is possible to run multiple versions of Purebasic on the same machine, using stuff like the /portable switch. It will create user config files etc. in the directory that PB is currently running from.
swhite
Addict
Addict
Posts: 808
Joined: Thu May 21, 2009 6:56 pm

Re: New Users Questions.

Post by swhite »

c4s wrote:This looks like a plain UserLib to me. Put it in #PB_Compiler_Home + "\PureLibraries\UserLibraries\" and see if it works. Some error message like "missing StringExtension" often means that the UserLib is outdated and can't be used with that version of PureBasic...
So the UserLibraries can contain ".pb" files and does this mean the compiler automatically looks for files in the folder or do I have to use "IncludeFile" to use them?

Thanks,
Simon
Simon White
dCipher Computing
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: New Users Questions.

Post by c4s »

Unfortunately you can't get the actual code behind UserLibraries, there are more like compiled executables.
Once you have put it there PureBasic will automatically give you the included functions, so you can use them as every other function. IncludeFile isn't needed and it wouldn't work either because you can't include a binary file.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
PureLeo
Enthusiast
Enthusiast
Posts: 221
Joined: Fri Jan 29, 2010 1:05 pm
Location: Brazil

Re: New Users Questions.

Post by PureLeo »

@swhite :
userlibraries (files with no extension) go to their path in the Purelibraries directory, the something.pb files usually are just examples of codes using those libraries

usually an userlib comes with information about how to make it work, or at least with its folder structure so you just need to paste them in the Purebasic's directory (when it comes like "Purelibraries/Userlibraries/file")

Example:
The library PureCOLOR...
It comes with lots of files like "PureCOLOR_TEST.pb", which I have in my Purebasic/Examples folder...
And some files like "PureCOLOR", "PureCOLOR-Buttons" (no extension) which I have in my Purebasic/PureLibraries/Userlibraries folder...

Now I run PureCOLOR_TEST.pb in Purebasic, and everything works fine.

But you might get some errors even when installing purelibraries the right way when they are very old.

ps: I tried COMLib and PBOSL4 and they dont work for me, guess they are outdated
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: New Users Questions.

Post by ts-soft »

It is a userlib for PB4.0!

I have updated it to use with PB4.51 x86 or x64, Source code included.
Come a new Version of PB, please tailbite it by yourself.

Greetings - Thomas

Download
Last edited by ts-soft on Tue Mar 01, 2011 8:25 pm, edited 1 time in total.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
swhite
Addict
Addict
Posts: 808
Joined: Thu May 21, 2009 6:56 pm

Re: New Users Questions.

Post by swhite »

ts-soft wrote:It is a userlib for PB4.0!

I have updated it to use with PB4.51 x86 or x64, Source code included.
Come a new Version of PB, please tailbite it by yourself.

Greetings - Thomas

Download

Thanks it compiles now but I still cannot make the COM dll work.
Simon White
dCipher Computing
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: New Users Questions.

Post by ts-soft »

This packages doesn't include any DLL!
You have to unzip the whole zip to purebasic!

On PureArea.net a Notes for installing of user-libs.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
swhite
Addict
Addict
Posts: 808
Joined: Thu May 21, 2009 6:56 pm

Re: New Users Questions.

Post by swhite »

ts-soft wrote:This packages doesn't include any DLL!
You have to unzip the whole zip to purebasic!

On PureArea.net a Notes for installing of user-libs.
Sorry I did not explain myself correctly. The COMLib worked just fine but I was using it to do COM automation with a dll created in Visual FoxPro. The part that is not working is the calling of the method in the Visual FoxPro dll. The Visual FoxPro method is never executed when called from PureBasic and I do not yet know why. I have tried the same functionality in PowerBasic and it works but for some reason it does not work in PureBasic.

Simon
Simon White
dCipher Computing
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: New Users Questions.

Post by IdeasVacuum »

Hi Simon

What does the specific FoxPro function do? Is it handling strings? FoxPro may be using a different type of string to that of PB. PB uses a 'C' type null-terminated string, I'm thinking maybe FoxPro uses a Microsoft type of string, such as LPTSTR, ASCIIZ or a-n-other.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply