Recent Posts

Pages: [1] 2 3 ... 10
1
Questions & Answers / Re: Line Input
« Last post by MrBcx on Today at 05:24:12 PM »
James,

(1) In your original post you wrote

LINE INPUT fp1, a$
translates to:
fgets(a, 1048576, fp1);
a only has room for 2048 bytes

So I pointed you to the Help File Topic
Be sure to dimension Buffer$ large enough to accommodate the longest line in the file that is to be input.

which was completely ON POINT.


(2) You next wrote
All the fgets "c" examples I've seen, the user supply's the maximum number of bytes to read, mostly with sizeof(the buffer)

BCX is not a program for making "C" examples - it's for BASIC programmers who want to generate a functionally equivalent program in "C".  Furthermore, I'd like to know your secret recipe for programmatically determining how large a dynamically dimensioned string is because SIZEOF aint gonna cut it.

(3) You probably know that fgets does not allocate any memory - users are responsible for supplying an adequately dimensioned string variable to receive the input.  BCX imposes an upper limit of 1 MB per line.   I cannot remember a time when any user ever asked for a larger buffer, so apparently your beef is that the 1 MB limit is too large (it isn't) and that you want maximum control over how many bytes will be read, to which I'd remind you that BCX gives you such a function -- its call GET$ and it too appears in the BCX HELP FILE. 
2
Questions & Answers / Re: Line Input
« Last post by Robert on Today at 05:06:57 PM »
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:
Code: [Select]
// *************************************************
//            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);
    }


Hi James:

The line you may want to modify (AT YOUR OWN RISK) in BCX 7.4.5 is at line 27541.

Code: [Select]

     FPRINT Outfile, Scoot$;"fgets(" ; Var$ ; ",";cMaxSrcLen;","; Clean$(Stk$[2]) ; ");"


 perhaps

Code: [Select]
   

    FPRINT Outfile, Scoot$;"fgets(" ; Var$ ; ", sizeof(" ; Var$ ; ")," ; Clean$(Stk$[2]) ; ");"


If you then get cryptic, indecipherable messages when translating then something maybe wrong.  :o
3
Questions & Answers / Re: Line Input
« Last post by jcfuller on Today at 01:50:40 PM »
Kevin,

Well I did RTFM but that is not the point.
All the fgets "c" examples I've seen, the user supply's the maximum number of bytes to read, mostly with sizeof(the buffer).
I tried to find a way to do this with bc9 but my knowledge of the inner workings of Bcx are poor at best.
I resorted to a LineInput routine using the Windows Api.

Not a big deal I guess but it just doesn't sit right with a 1 meg fixed buffer size:)

James
4
Questions & Answers / Re: Line Input
« Last post by MrBcx on Today at 10:54:12 AM »
I was tempted to reply "RTFM" but I'm in a good mood, so I'll suggest a more
useful research tool -- The BCX HELP FILE


LINE INPUT statement(from file)

Purpose: Reads a line of text data from a file.

 Syntax 1:


 LINE INPUT hFile, Buffer$

 Parameters:

    hFile Name of handle to file from which line of text is read. File must be opened using


     OPEN FileName$ FOR INPUT AS hFile

    syntax.
    Buffer$ String to receive line of text. Be sure to dimension Buffer$ large enough to accomodate the longest line in the file that is to be input.
5
Questions & Answers / Line Input
« Last post by jcfuller on Today at 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:
Code: [Select]
// *************************************************
//            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);
    }

6
User Contributions / SysAnimate32 Demo (PowerBasic and BCX versions)
« Last post by MrBcx on February 17, 2020, 09:59:15 AM »
Long time PowerBasic contributor Borje Hagsten uploaded the following sample today.

I thought it might interest some to see the same  program converted to BCX.  The BCX
version adds a little more functionality ( A Button,  ShowAnimations(), HideAnimations() )
that could be used in your own projects.

The attached zip contains the BCX version (Source, Exe, and Avi files)

PowerBasic Version

Code: [Select]
#COMPILE EXE  'AviTest.bas
#DIM ALL
'--------------------------------------------------------------------
#INCLUDE "WIN32API.INC"
#INCLUDE "COMMCTRL.INC"
'--------------------------------------------------------------------
%IDC_ANIMATE16  = 230
%IDC_ANIMATE32  = 231

'====================================================================
FUNCTION PBMAIN () AS LONG
  LOCAL hDlg AS DWORD

  DIALOG NEW PIXELS, 0, "Avi test",,, 140, 50, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
  '------------------------------------------------------------------
  InitCommonControls
  CONTROL ADD "SysAnimate32", hDlg, %IDC_ANIMATE16, "", 5, 5, 18, 18, _
            %WS_CHILD OR %WS_VISIBLE OR %ACS_TRANSPARENT OR %ACS_CENTER OR %ACS_AUTOPLAY
  CONTROL ADD "SysAnimate32", hDlg, %IDC_ANIMATE32, "", 28, 5, 32, 32, _
            %WS_CHILD OR %WS_VISIBLE OR %ACS_TRANSPARENT OR %ACS_CENTER OR %ACS_AUTOPLAY
  ' %ACS_AUTOPLAY - avi files starts playing when Animate_Open is called
  '-------------------------------------------------------------------
  DIALOG SHOW MODAL hDlg, CALL DlgProc

END FUNCTION

'======================================================================
CALLBACK FUNCTION DlgProc() AS LONG

  SELECT CASE CB.MSG
  CASE %WM_INITDIALOG
      STATIC hAnim16, hAnim32 AS DWORD
      CONTROL HANDLE CB.HNDL, %IDC_ANIMATE16 TO hAnim16
      CONTROL HANDLE CB.HNDL, %IDC_ANIMATE32 TO hAnim32
      Animate_Open(hAnim16, "Circle16.avi") ' if file is in same folder
      Animate_Open(hAnim32, "HourGlass32.avi")
      ' see also Animate_Play and Animate_Stop to control action
      ' SysAnimate32 can be shown/hidden with CONTROL SHOW STATE..
      ' Avi file can also be embedded as resource, but don't know
      ' how to do that with PB #RESOURCE statements.

  CASE %WM_DESTROY
      Animate_Close(hAnim16)
      Animate_Close(hAnim32)
  END SELECT

END FUNCTION



BCX Version

Code: [Select]

GUI "Avi test"


ENUM
   IDC_ANIMATE16  = WM_USER + 100
   IDC_ANIMATE32
   IDC_BTN1
END ENUM


SUB FORMLOAD
   GLOBAL Form AS HWND
   GLOBAL Ico1 AS HWND
   GLOBAL Ico2 AS HWND
   GLOBAL Btn1 AS HWND

   Form = BCX_FORM    ("Avi test", 0, 0, 140, 50, WS_CAPTION OR WS_SYSMENU)
   Btn1 = BCX_BUTTON  ("Hide Icons", Form, IDC_BTN1, 80, 5, 0, 0)

   Ico1 = BCX_CONTROL (ANIMATE_CLASS, Form, "", IDC_ANIMATE16, 5, 5, 18, 18, _
   WS_CHILD OR WS_VISIBLE OR ACS_TRANSPARENT OR ACS_CENTER OR ACS_AUTOPLAY)

   Ico2 = BCX_CONTROL (ANIMATE_CLASS, Form, "", IDC_ANIMATE32, 28, 5, 32, 32, _
   WS_CHILD OR WS_VISIBLE OR ACS_TRANSPARENT OR ACS_CENTER OR ACS_AUTOPLAY)

   CALL LoadAnimations
   CENTER(Form)
   SHOW(Form)
END SUB




BEGIN EVENTS
   DIM STATIC BtnToggle
   SELECT CASE CBMSG

      CASE WM_COMMAND
      SELECT CASE CBCTL
         CASE IDC_BTN1
         IF NOT BtnToggle THEN
            CALL HideAnimations
            BCX_SET_TEXT(Btn1,"Show Icons")
            BtnToggle = NOT BtnToggle
         ELSE
            CALL ShowAnimations
            BCX_SET_TEXT(Btn1,"Hide Icons")
            BtnToggle = NOT BtnToggle
         END IF
      END SELECT

      CASE WM_DESTROY
      Animate_Close(Ico1)
      Animate_Close(Ico2)

   END SELECT
END EVENTS



SUB LoadAnimations
   Animate_Open(Ico1, "Circle16.avi")      ' if file is in same folder
   Animate_Open(Ico2, "HourGlass32.avi")
END SUB


SUB ShowAnimations
   SHOW(Ico1)
   SHOW(Ico2)
END SUB



SUB HideAnimations
   HIDE (Ico1)
   HIDE (Ico2)
END SUB


7
Tips & Tricks / Re: Off Topic: B4A BASIC for Android
« Last post by MrBcx on February 17, 2020, 07:20:21 AM »
I purchased the B4A package about 7 years ago for a work-related project.  I had gotten much of the UI completed and most of the business logic but I hit a roadblock with our company network security group when I tried to get them to open a port in the network DMZ.  Without that client/server access, I could not exchange the data that was needed to run the app.  That was frustrating, the project was shelved, and I retired 2 years later.

Despite that limited experience, I thought that "Basic For Android" was a solid product that fit with my development sensibilities.  I may tinker with it on my Samsung Tablet, just to see how it has matured since I last used it.
8
Tips & Tricks / Off Topic: B4A BASIC for Android
« Last post by Robert on February 16, 2020, 11:28:00 PM »
I have seen mention in the past that some BCX programmers were also checking out B4A BASIC for Android.

B4A is now FREE!

I think it is a very well developed, updated and easy to use tool. Very active online community. I have been a licensed user for a couple of years.

Website at

https://www.b4x.com/
9
Announcements / BCX Help Version 7.4.5, February 16 2020
« Last post by Robert on February 16, 2020, 09:47:57 PM »
BCX Help Version 7.4.5, February 16 2020

is available as BCXHelp Version 7.4.5 20200216.zip
in the Announcements section of the BCX forum at

https://bcxbasiccoders.com/smf/index.php

Changes include
 
Kevin Diggins

... revised the example on the BCX_UPDOWN page.
10
User Contributions / Re: I Love BCX !
« Last post by Robert on February 16, 2020, 04:43:23 PM »
Gracias Amigo.

Font face and color picker next?  ;D
Pages: [1] 2 3 ... 10