Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - jcfuller

#101
Bug Reports / mid$ statement
February 29, 2020, 08:52:00 AM

  This is probably a bit anal but the mid$ statement accepts a literal as the mainstring$.
There is no way a compiler can detect an issue so it has to be done with the translator. I am not very good when it comes to following the Stk$[], Ndx code.
  I know it's not a big concern but my ocd tells me a procedure should not get a literal when it wants a char*

James



 
#102
Questions & Answers / compiler usage
February 24, 2020, 04:10:09 AM
Kevin,
  Just a bit curious.
I notice in many cases on listing compilers for testing a bit of source VC is missing.
Also you do list MinGw on many "c" examples. Do you compile as c++ or do you use Mike's InsertOptArgs utility?

James
#103
Questions & Answers / EOF
February 24, 2020, 03:59:18 AM
Kevin,
My poor "c" education may be showing here but:
Why was the Bcx EOF function created instead of using the C library function feof?

James
#104
Questions & Answers / _msize discussion
February 21, 2020, 04:58:56 PM
Kevin,
  Why would _msize not work for dynamic allocated strings.
James


$NOMAIN
$NOINI
$ONEXIT "VSC.BAT $FILE$ -m64 con"


Function main() As Integer
Dim A$ * 2048
Dim B$
If sizeof(A$) = 8 Then
? _msize(A$)
End If
? sizeof(B$)
Pause
End Function

#105
Questions & Answers / Line Input
February 18, 2020, 09:08:16 AM
The history Bcx_Revision.txt does not give any information on Line Input from a file.
I may have asked this in the distant past on Yahoo but just too much under the bridge since then.
LINE INPUT fp1, a$
translates to:
fgets(a, 1048576, fp1);
a only has room for 2048 bytes
I remember sometime in the very distant past one of the compilers balked at the fgets line.

James

Partial translation:

// *************************************************
//            System Defined Constants
// *************************************************

#define BcxStrSize 2048

// *************************************************
//            User Global Variables
// *************************************************

static int     z;
static FILE   *fp1;
static char    a[BcxStrSize];



    while(!EoF(fp1))
    {
        a[0] = 0;
        fgets(a, 1048576, fp1);
        if(a[strlen(a) - 1] == 10)a[strlen(a) - 1] = 0;
        printf("%s\n", a);
    }

#106
Wish List / min/max
February 13, 2020, 08:16:30 AM
Kevin,
  Would you do the same for lowercase min/max as you did for true/false and leave them be in c++.
Thank you for your consideration.

James
#107
Wish List / add tchar.h
February 11, 2020, 11:49:04 AM
Kevin,
  For unicode we need tchar.h added to the list of #includes.

James
#108
Bug Reports / ?/print issue
February 11, 2020, 10:18:23 AM
Kevin,
  This was just the first ref test. I have not done much with it. It is primarily for classes but this code does reflect another item that I believe I fixed with bc9 after the fact in my docppfixups function.
Spaces after the % in the printf lines.

James



$CPP
$NOMAIN
$NOINI
$ONEXIT "ASTYLE -pn $FILE$.CPP"
$ONEXIT "VSCPP.BAT $FILE$ -m64 con"

TYPE test
    S$[32] As char
    I As Integer
    D As float
End Type
'==============================================================================
Sub Test( J As test Ref)
    ? J.S$
    ? J.I
    ? J.D!
End Sub
'==============================================================================
Function main() as Integer
   
    Dim x As test
   
    Dim i As Integer
    x.S$ = "James"
    x.I = 234
    x.D = 12.56
    Test(x)
   
   
    ? "Hello"
    Pause
   
End Function

c++ code

...snip
// *************************************************
//            System Defined Constants
// *************************************************

#define BcxStrSize 2048

// *************************************************
//             User Defined Constants
// *************************************************

#define TEST_CLASS struct _TEST*

// *************************************************
//               Standard Prototypes
// *************************************************

void    Pause (void);
// *************************************************
//          User Defined Types And Unions
// *************************************************


typedef struct _test
{
  char     S[32];
  int      I;
  float    D;
}test, *LPTEST;



// *************************************************
//               User Prototypes
// *************************************************

void    Test (test&);
int     main (void);

// *************************************************
//            User Global Initialized Arrays
// *************************************************



// *************************************************
//                 Runtime Functions
// *************************************************

void Pause(void)
{
  printf("\n%s\n","Press any key to continue . . .");
  _getch();
}



// ************************************
//       User Subs and Functions
// ************************************

void Test (test&  J)
{
  printf("%s\n",J.S);
  printf("% d\n",(int)J.I);
  printf("% .7G\n",(float)J.D);
}


int main ()
{
  struct _test     x={0};
  int      i={0};
  strcpy(x.S,"James");
  x.I= 234;
  x.D= 12.56;
  Test(x);
  printf("%s\n","Hello");
  Pause();
  return 0;
}

#109
Questions & Answers / optional parameters
February 10, 2020, 08:15:01 AM
Kevin/Robert
  I did not notice any mention that PellesC is the only "C" compiler that can with 100% accuracy compile Bcx translated "c" code. It was one of the reasons I started the bc9 fork, only to be informed by Mr Bcx there was a utility to do just that. Oh well :). I actually did not get all the runtime libraries converted so I always run InsertOptArg before compiling. And now I cannot remember who the author is. It's not in the source I have.

James


#110
Bug Reports / const char* issue??
February 09, 2020, 02:37:25 PM

This appears to be a const char* issue


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'my bcx.ini has the iMatch macros
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$NOMAIN
$ONEXIT "VSCPP.BAT $FILE$ -m64 con "

$HEADER
    #define overloaded
    #include <iostream>
    #include <string>
    typedef std::string stdstr;
$HEADER


Function main()
    Raw As stdstr s1
    s1 = "$IFUSE USE_CScrollWindow"
    'If LEFTSTR(s1.c_str(),"$IFUSE") Then
    '    std::cout << "LEFTSTR" << std::endl
    'End If
    'If Left$(s1.c_str(),6) = "$IFUSE" Then
    '    std::cout << "Left$" << std::endl
    'End If
    If iMatchLft(s1.c_str(),"$IFUSE") Then
        std::cout << "iMatchLft" << std::endl
    End If
    Pause
End Function


My bcx.ini

'***********************
'  Bracket Handling
'***********************

CONST c_SglQt = 39
CONST c_DblQt = 34
CONST c_LPar  = 40
CONST c_RPar  = 41
CONST c_Komma = 44
CONST c_LtBkt = 91
CONST c_RtBkt = 93


CONST iMatchLft(A,B) = iMatch(A,B,0)
CONST iMatchWrd(A,B) = iMatch(A,B,1)
CONST iMatchRgt(A,B) = iMatch(A,B,2)




FUNCTION iMatch(Arg As const char Ptr, MatchStr As const char Ptr, mt)

  IF mt = 2 THEN
    DIM RAW L1, L2
    L1 = LEN(Arg$) : L2 = LEN(MatchStr$)
    IF L1 < L2 THEN FUNCTION = FALSE
    Arg = (Arg + L1) - L2
  END IF

  WHILE *MatchStr
    'If we run out string to match against then return no match
    IF *Arg = 0 THEN FUNCTION = FALSE
    'bit ORing a character with 0x20 produces the lower case of it
    IF (*Arg BOR 32) <> (*MatchStr BOR 32) THEN FUNCTION = FALSE
    INCR Arg
    INCR MatchStr
  WEND
  IF mt AND *Arg <> 0 THEN FUNCTION = FALSE
  FUNCTION = TRUE
END FUNCTION

'==============================================================================

'------------------------------------------------------------------------------
FUNCTION iMatchNQ(Arg As const char Ptr, MatchStr As const char Ptr)
  Dim As Int mi
  DIM AS PCHAR  a = (char Ptr)Arg


  WHILE MatchStr[mi]
    IF *a = c_DblQt THEN
      mi=0
      WHILE *(++a) <> c_DblQt
        IF *a = 0 THEN FUNCTION = 0
      WEND
    END IF

    IF a[mi] = 0 THEN FUNCTION = 0
    'If we run out string to match against then return no match
    'bit ORing a character with 0x20 produces the lower case of it
    IF (a[mi] BOR 32) <> (MatchStr[mi] BOR 32) THEN
      INCR a : mi= -1
    END IF
    INCR mi
  WEND
  FUNCTION = (a-Arg) + 1  ' We have a match
END FUNCTION



#111
Wish List / c++ reference
February 09, 2020, 11:15:26 AM
Kevin,
  I know this is c++ stuff but:
Add  REF to compliment PTR
If you pass a type/class pointer to a function  you need to use -> to reference the members
With REF you can use the dot "."
PTR = *
REF = &

James
#112
Bug Reports / Pause
February 09, 2020, 09:01:52 AM
Kevin,
  I forgot to mention it before but getchar() needs a return/enter where _getch() does not.
You need to update the Prompt to "Press return/enter" or revert back to to the old keypress routine if you do not want to use _getch().

James

#113
Questions & Answers / chicken or egg
February 09, 2020, 08:14:10 AM
Kevin,
  Great job on the new version. Wow lot's of good stuff.

How do You compile new versions.
It appears we have a situation with which came first chicken/egg.
I tried compiling 7.4.2 with 7.4.1 and get a lot of
'LEFTSTR': identifier not found

I can always use the 7.4.2 exe to compile 7.4.2 bas ( I want my own VSCPP version)

James
#114
Wish List / FbEdit hack
February 06, 2020, 02:41:34 PM
Kevin,
  Something to chew on.
I have been using RadAsm3 as my bcx ide and it has issues.
It dawned on me I'll just use the hacked FbEdit I use for bc9.
Not so fast..
FbEdit sends options first then  quoted basic file and finally quoted rc file.

Any chance .... ???
James
#115
Wish List / $IFUSE
February 04, 2020, 07:23:11 AM

just an idea not really  a wish

One item I added to bc9 was the $IFUSE / $ENDUSE ,$USE directives.
These made library source files more manageable by only including the source I wanted
Every item in my bc9Lib.bi was flanked with
$IFUSE USE_XXXXX
    ....basic lib code
$ENDUSE
and in the main source
$USE USE_XXXX USE_YYYYY

Why you might ask?
Without it, and just including a VERY large library source file, all the code would be translated and added to the c/c++ source file. It is no big deal exe size wise with MSVC ( only code used/called is added to the exe. This is because all code is in one single c/c++ file. not the case if #includes are used)
MinGW can do this too I think, not sure about Pelles?
This was pretty easy to add to bc9 because it is a c++ app and I used vectors and range based for loops.

Not sure if something like this could (easily? probably not) incorporated into Bcx??

It makes looking for an error or something in the translated source a lot easier if you don't have to sort through a lot of code.

James


#116
Questions & Answers / Pause()
February 04, 2020, 05:21:28 AM
Kevin,
  Why do you use the keypress routine for Pause() ?

  This is my bc9 Pause:

void Pause(void)
{
    printf("\n%s\n", "Press any key to continue...");
    _getch();
}



James
#118
Questions & Answers / TRUE <> true
February 02, 2020, 11:58:05 AM
I know this has been discussed somewhere before but I'm not sure of the outcome or the  bcx, bc9 differences.

BOOL <> bool
TRUE <> true
FALSE <> false

upper case is Windows
lower case is c++

both are valid in different situations
The translator will always translate to upper case

I decided to use _bool _true _false for the c++ versions in bc9

#define _bool bool
#define _true   true
#define _false false

Any discussion?

James


#119
Questions & Answers / single quotes
February 02, 2020, 11:23:37 AM
I know this is out of context but I don't have an environment ready to post for anyone to try yet.

I remember having difficulty in passing or using single quoted items -> ','

I don't remember how I came up with this in bc9 but it translated:
iParseCount = s1.ParseCount(E"','")
To
iParseCount = s1.ParseCount(',');

where this is bcx.
iParseCount = s1.ParseCount("','");

It could be I have code to handle "' and '" buried in bc9 ?????

Is there bcx basic code to produce single quoted items ??


James
#120
Tips & Tricks / c++ format issue
February 01, 2020, 06:48:52 AM

This not really a bug so I post it here. It is related to the format of the translated c++ code where Ian's ULEX utility cannot parse ir correctly

I'm not sure if Robert tried to chase this down in the past or not?
I know I had no success so I reverted to an easy HACK with bc9.
I call "astyle -p" to format the cpp file.
https://sourceforge.net/projects/astyle/files/astyle/astyle%203.1/AStyle_3.1_windows.zip/download
For Bcx we can do the same thing this way
==============================================================================
This is Chaper 26 from the bcx741 help file on c++

$CPP
$NOMAIN
$ONEXIT "ASTYLE.EXE -p $FILE$.CPP"
'$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"

$ONEXIT "VSCPP.BAT $FILE$ -m64 con"
 
#include <iostream>
#include <tchar.h>
 
CLASS bcx_vector
   PUBLIC:
   
   RAW AS double x
   RAW AS double y
   
   CONSTRUCTOR bcx_vector (a = 0 AS double, b = 0 AS double)
     x = a
     y = b
   END CONSTRUCTOR
   
   FUNCTION module() AS double
     FUNCTION = sqrt (x*x + y*y)
   END FUNCTION
   
   FUNCTION surface() AS double
     FUNCTION = x * y
   END FUNCTION
END CLASS
   
CLASS trivector USING public bcx_vector    ' trivector is derived from bcx_vector
   PUBLIC:
   RAW AS double z       ' added to x and y from bcx_vector
   
   CONSTRUCTOR trivector (m=0 AS double, n=0 AS double, p=0 AS double) USING bcx_vector (m, n)
     z = p               ' bcx_vector constructor will
   END CONSTRUCTOR       ' be called before trivector
   ' constructor, with parameters
   ' m and n.
   
   CONSTRUCTOR trivector (a AS bcx_vector) ' What to do if a bcx_vector is cast to a trivector
     x = a.x
     y = a.y
     z = 0
   END CONSTRUCTOR
   
   FUNCTION module () AS double      ' define module() for trivector
     FUNCTION = sqrt (x*x + y*y + z*z)
   END FUNCTION
   
   FUNCTION volume () AS double
     FUNCTION = this->surface() * z    ' or x * y * z
   END FUNCTION
END CLASS
   
FUNCTION main ()
 
   RAW AS bcx_vector a (4, 5)
   RAW AS trivector b (1, 2, 3)
   
   std::cout << "a (4, 5)    b (1, 2, 3)    *r = b" << std::endl << std::endl
   
   std::cout << "Surface of a: " << a.surface() << std::endl
   std::cout << "Volume of b: " << b.volume() << std::endl
   std::cout << "Surface of base of b: " << b.surface() << std::endl
   
   std::cout << "Module of a: " << a.module() << std::endl
   std::cout << "Module of b: " << b.module() << std::endl
   std::cout << "Module of base of b: " << b.bcx_vector::module() << std::endl
   
   RAW AS trivector k
   k = a                 ' thanks to trivector(bcx_vector) definition
   ' copy of x and y,       k.z = 0
   RAW AS bcx_vector j
   j = b                 ' copy of x and y.       b.z left out
   
   RAW AS bcx_vector PTR r
   r = &b
   
   std::cout << "Surface of r: " << r->surface() << std::endl
   std::cout << "Module of r: " << r->module() << std::endl
   PAUSE
END FUNCTION


This is main translated with bc741 without astyle.

int main ()
{
  bcx_vector  a(4,5);
  trivector  b(1,2,3);
  std::cout<<"a (4, 5)    b (1, 2, 3)    *r = b"<<std::endl<<std::endl;
  std::cout<<"Surface of a: "<<a.surface()<<std::endl;
  std::cout<<"Volume of b: "<<b.volume()<<std::endl;
  std::cout<<"Surface of base of b: "<<b.surface()<<std::endl;
  std::cout<<"Module of a: "<<a.module()<<std::endl;
  std::cout<<"Module of b: "<<b.module()<<std::endl;
  std::cout<<"Module of base of b: "<<b.bcx_vector::module()<<std::endl;
  trivector  k;
  k= a;
  bcx_vector  j;
  j= b;
  bcx_vector*  r;
  r=  &b;
  std::cout<<"Surface of r: "<<r->surface()<<std::endl;
  std::cout<<"Module of r: "<<r->module()<<std::endl;
  Pause();
  return 0;
}


And After using astyle

int main ()
{
    bcx_vector  a(4, 5);
    trivector  b(1, 2, 3);
    std::cout << "a (4, 5)    b (1, 2, 3)    *r = b" << std::endl << std::endl;
    std::cout << "Surface of a: " << a.surface() << std::endl;
    std::cout << "Volume of b: " << b.volume() << std::endl;
    std::cout << "Surface of base of b: " << b.surface() << std::endl;
    std::cout << "Module of a: " << a.module() << std::endl;
    std::cout << "Module of b: " << b.module() << std::endl;
    std::cout << "Module of base of b: " << b.bcx_vector::module() << std::endl;
    trivector  k;
    k = a;
    bcx_vector  j;
    j = b;
    bcx_vector*  r;
    r =  &b;
    std::cout << "Surface of r: " << r->surface() << std::endl;
    std::cout << "Module of r: " << r->module() << std::endl;
    Pause();
    return 0;
}

With out the spaces around "<<" Ian's ULEX will not parse correctly.

And this is the unicode version after running ULEX

int _tmain ()
{
    bcx_vector  a(4, 5);
    trivector  b(1, 2, 3);
    std::wcout << _T("a (4, 5)    b (1, 2, 3)    *r = b") << std::endl << std::endl;
    std::wcout << _T("Surface of a: ") << a.surface() << std::endl;
    std::wcout << _T("Volume of b: ") << b.volume() << std::endl;
    std::wcout << _T("Surface of base of b: ") << b.surface() << std::endl;
    std::wcout << _T("Module of a: ") << a.module() << std::endl;
    std::wcout << _T("Module of b: ") << b.module() << std::endl;
    std::wcout << _T("Module of base of b: ") << b.bcx_vector::module() << std::endl;
    trivector  k;
    k = a;
    bcx_vector  j;
    j = b;
    bcx_vector*  r;
    r =  &b;
    std::wcout << _T("Surface of r: ") << r->surface() << std::endl;
    std::wcout << _T("Module of r: ") << r->module() << std::endl;
    Pause();
    return 0;
}



I tweaked Ian's code a bit but it was a long time ago so I'll attach both the source and exe along with my VC++ batch file.
I also use separate format files for VCPP and MinGW which I don't remember why?

James