• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Pb keywords port

Started by James C. Fuller, February 26, 2017, 07:39:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

I really mean no disrespect to PowerBASIC by this post. I am only trying to show that c++ is not the bloated beast many would have you believe, and it can also perform quite admirably.
This is a 64bit unicode application.

Appsize: 11,776 bytes
Timing: .15625

James


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'I was surprised that IDictionary was slower than Borje's implementation over
'on the PowerBASIC forum. I decided to try a bc9Basic/TCLib version using an
'IDictionary class wrapper I wrote. This is smaller than any of the PB implementations
'and only slower than Hutch's pure asm app.
'------------------------------------------------------------------------------
'Note: this is a 64bit unicde application
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$NOMAIN
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "TCLIB.BAT $FILE$"
$HEADER
    #pragma comment(lib,"ole32.lib")
    #pragma comment(lib,"OleAut32.lib")
$HEADER
'==============================================================================
$USE USE_BcxDict
$Include <bc9Lib.bi>
'==============================================================================
Function IsReservedWord(oDic As cBcxDic Ref, sWord As const char Ptr) As Integer
    Static Loaded As Integer
    Dim As Integer i
    If Loaded = 0 Then
        While DATA$[i] <> "EOD"
            oDic.Add((char*)DATA$[i],"")
            Incr i
        Wend
        Loaded = 1
    End If
     If oDic.Exists(UCase$(sWord)) Then
         Function = 1
     EndIf
    Function = 0
    DATA "IF","THEN","ELSE","TRY","CATCH","END","SELECT","CASE","FUNCTION","SUB","ITERATE","FOR","NEXT","WHILE","UNTIL","DO","LOOP","WEND","STEP"
    DATA "EXIT","REGISTER","LOCAL","GLOBAL","STATIC","INCR","DECR","BY","DATA","OPT","OPTIONAL","CONST","SLEEP","RESOURCE","OBJECT","IMAGE","SWAP"
    DATA "AS","TO","GOTO","STDOUT","PRINT","PRINTR","PRINTBR","ECHO","DIM","REDIM","BYVAL","BYREF","BYCOPY","TYPE","TABLE","ENTRY","LANGUAGE","NAME"
    DATA "MACRO","EXPORT","REPLACE","WITH","IN","GOSUB","RETURN","ENDIF","MACROTEMP","ELSEIF","YES","NO","ON","OFF","REGISTER","SYSTEM","ARR","INFINITE"
    DATA "ASCEND","DESCEND","TAGARRAY","COLLATE","FROM","SCAN","INSERT","DELETE","VARIANT","TCP","PORT","AT","SEND","RECV","TIMEOUT","ALIAS","LIB"
    DATA "DECLARE","DEF","ERRORS","PLURIBASIC","WARNINGS","NOTICES","DEPRECATED","PARSES","ALL","NONE","ANY","EXACT","ITERATE","PHP","HTML","START"
    DATA "MYSQL","LOAD","SAVE","DELETE","WHERE","LIMITUDT","PBCC","PBWIN","USEUNICODE","CRACKERS","SESSTART","EXCLUSIVE","AUTO","OPEN","CLOSE","CLOSED"
    DATA "APPEND","INPUT","OUTPUT","SETEOF","SEEK","GET","PUT","PRINT","FOREACH","ACCESS","READ","WRITE","SHARED","LOCK","SEEK","LINE","CALL","BITWISE"
    DATA "LOGICAL","UDT","QUIT","ABORT","TERMINATE","DECLARE","CLASS","METHOD","PROPERTY","CREATE","DESTROY","INSTANCE","GET","SET","INTERFACE","LET"
    DATA "CREATE","DESTROY","WAITKEY$","RESET","RESERVE","DEFBYT","DEFDWD","DEFINT","DEFLNG","DEFSNG","DEFSTR","DEFWRD","DEFASC","BINARY"
    DATA "ISCOND","NOTNULL","AUTOINC","PRIMARY","ON","OFF","YES","NO","EXE","PHP","DLL","SLL","CONSOLE","EXCLUDE","INCLUDE","RAW"
    ' SPECIAL CASES
    DATA "VARPTR","LBOUND","UBOUND", "SYS_ARR","SYS_IMG"
    DATA "IIF","CHOOSE","CHOOSES","CHOOSEI","CHOOSED","CHOOSEF","CHOOSEB", "USING","EOD"
   
End Function
'==============================================================================
Function main() As Integer
    Raw As cBcxDic Ptr oDic
    Dim As int RetVal ,i
    Dim As DOUBLE t

    OleInitialize(NULL)
    oDic = new cBcxDic   

    If Not oDic Then
        ? "No oDic allocation"
        Pause
        Function = EXIT_FAILURE
    End if

    t = TIMER

    For i = 1 To 1000000
        RetVal = IsReservedWord(*oDic,"waitkey$")   
    Next
    t = TIMER - t

    delete oDic

    OleUninitialize()

    print "t = " ;t
    print "RetVal = ";RetVal
    Pause
    Function = RetVal
End Function



Frederick J. Harris

Hi Jim!

     Was wondering what you've been up to.  As for me, Windows Mobile has been eating me alive!

There are all kinds of misconceptions out there.  For example, COM is slow and bloated.  As Jose said many times - not true.  And then there's the C++ falicies.  Sorry about the spelling.  I think I've proved that isn't true.  Thing with C++ though is the libraries.  I'm not sure many have the appreciation that with C++ - unlike PowerBASIC and many other languages, there is a distinction between the core language and the standard libraries. 

I think just about everybody that uses C++ buys into the belief that they can't live without C++ Exception Handling.  That is necessary, I believe, for the compilation and linkage of everything I know of in the C++ Standard library.  If you can live without that and fall back on good old reliable C error handling techniques, i.e., always checking return values and not using NULL pointers, you can accomplish anything.  I'm probably just beating a dead horse!