PlanetSquires Forums

Support Forums => WinFBE - Code Editor and Visual Designer => Topic started by: raymw on September 28, 2019, 09:25:04 AM

Title: find and replace
Post by: raymw on September 28, 2019, 09:25:04 AM
Not sure if there is a simple solution, but if you have, say, characters such as  'xs.text' in your code, and you need to replace it with 'form1.xs.text' then if you search for 'xs' and replace with 'form1.xs' it goes on, and on and on. :D

Came across this in converting a c# program to fb, not sure if discussing how to do that somewhere?
Title: Re: find and replace
Post by: raymw on September 29, 2019, 01:53:23 PM
Has folding been completely abandoned in winfbe editor? If not, remind me if/how to create fold points (I know it used to be on sub/end sub, etc., and that it wasn't high priority).
Title: Re: find and replace - F8
Post by: SeaVipe on September 29, 2019, 02:48:10 PM
Hi Ray,
Have a look at Menu item View/F8. I don't think Folding is quite ready for prime time. If I use folding too many times it stops working. Also, I don't use fold, but I can see its advantages.
Title: Re: find and replace
Post by: raymw on September 29, 2019, 07:58:49 PM
Hi Clive, none of it works for me. From a previous thread iirc, it was a bit irregular. If I try to fold anything it stays as it is. It's not a deal breaker, but it would have been handy, to save my rsi with trackball. Does the key words, function, end, etc have to be in a specific column, or can you add fold points where you wish.
Title: Re: find and replace
Post by: SeaVipe on September 29, 2019, 09:04:30 PM
BTW I'm using WinFBE 1.9.2.
Title: Re: find and replace
Post by: SeaVipe on September 29, 2019, 09:09:22 PM
Folding is likely a work-in-progress.
Title: Re: find and replace
Post by: Paul Squires on September 29, 2019, 09:14:14 PM
Folding is a pain in the butt because the logic is built directly into the scintilla editing dll and is written in C++. I have to modify that source and then re-compile the 32 and 64 bit dll's. I don't love folding that much!  hahaha

BTW, you have to ensure that the Folding Margin is enabled in order to use folding.
Environment Options... Code Editor... Show fold margin
Title: Re: find and replace
Post by: Josť Roca on September 29, 2019, 09:44:43 PM
> I don't love folding that much!

I never use it. Neither autocomplete nor codetips. I code faster without these gimmicks.

Title: Re: find and replace
Post by: raymw on September 30, 2019, 07:51:24 AM
Thanks, I'd forgot you had to set the fold margin. As long as it doesn't lose code when folding/unfolding, it'll do. I find it useful some times, but not a major issue. Maybe the menu item could be greyed out if folding not enabled?
Title: Re: find and replace
Post by: raymw on September 30, 2019, 01:51:47 PM
Still relating to the c# conversion, the nuts and bolts are working fine, but I was dreading the graphics, however for this particular program, it is merely plotting lines between a list of xy coordinates. I found Jose's code
Code: [Select]
########################################################################################
' Microsoft Windows
' File: DrawLine.bas
' Contents: GDI+ - DrawLine example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2017 Josť Roca. Freeware. Use at your own risk.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################

#define UNICODE
#INCLUDE ONCE "Afx/CGdiPlus/CGdiPlus.inc"
#INCLUDE ONCE "Afx/CGraphCtx.inc"
USING Afx

CONST IDC_GRCTX = 1001

DECLARE FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                          BYVAL hPrevInstance AS HINSTANCE, _
                          BYVAL szCmdLine AS ZSTRING PTR, _
                          BYVAL nCmdShow AS LONG) AS LONG

   END WinMain(GetModuleHandleW(NULL), NULL, COMMAND(), SW_NORMAL)

' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

' ========================================================================================
' The following example draws a line.
' ========================================================================================
SUB Example_DrawLine (BYVAL hdc AS HDC)

   ' // Create a graphics object from the window device context
   DIM graphics AS CGpGraphics = hdc
   ' // Get the DPI scaling ratios
   DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
   DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
   ' // Set the scale transform
   graphics.ScaleTransform(rxRatio, ryRatio)

   ' // Draw the line
   DIM blackPen AS CGpPen = CGpPen(GDIP_ARGB(255, 0, 0, 0), 3)
   graphics.DrawLine(@blackPen, 100.0, 100.0, 500.0, 100.0)

END SUB
' ========================================================================================

' ========================================================================================
' Main
' ========================================================================================
FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                  BYVAL hPrevInstance AS HINSTANCE, _
                  BYVAL szCmdLine AS ZSTRING PTR, _
                  BYVAL nCmdShow AS LONG) AS LONG

   ' // Set process DPI aware
   ' // The recommended way is to use a manifest file
   AfxSetProcessDPIAware

   ' // Create the main window
   DIM pWindow AS CWindow
   ' -or- DIM pWindow AS CWindow = "MyClassName" (use the name that you wish)
   pWindow.Create(NULL, "GDI+ DrawLine", @WndProc)
   ' // Change the window style
   pWindow.WindowStyle = WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU
   ' // Size it by setting the wanted width and height of its client area
   pWindow.SetClientSize(600, 250)
   ' // Center the window
   pWindow.Center

   ' // Add a graphic control
   DIM pGraphCtx AS CGraphCtx = CGraphCtx(@pWindow, IDC_GRCTX, "", 0, 0, pWindow.ClientWidth, pWindow.ClientHeight)
   pGraphCtx.Clear BGR(255, 255, 255)
   ' // Get the memory device context of the graphic control
   DIM hdc AS HDC = pGraphCtx.GetMemDc
   ' // Draw the graphics
   Example_DrawLine(hdc)

   ' // Displays the window and dispatches the Windows messages
   FUNCTION = pWindow.DoEvents(nCmdShow)

END FUNCTION
' ========================================================================================

' ========================================================================================
' Main window procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

   SELECT CASE uMsg

      CASE WM_COMMAND
         SELECT CASE GET_WM_COMMAND_ID(wParam, lParam)
            CASE IDCANCEL
               ' // If ESC key pressed, close the application by sending an WM_CLOSE message
               IF GET_WM_COMMAND_CMD(wParam, lParam) = BN_CLICKED THEN
                  SendMessageW hwnd, WM_CLOSE, 0, 0
                  EXIT FUNCTION
               END IF
         END SELECT

    CASE WM_DESTROY
         ' // Ends the application by sending a WM_QUIT message
         PostQuitMessage(0)
         EXIT FUNCTION

   END SELECT

   ' // Default processing of Windows messages
   FUNCTION = DefWindowProcW(hwnd, uMsg, wParam, lParam)

END FUNCTION
' ========================================================================================

and it works fine, and thanks to the comments, I more or less understand what each line is for. However, I am struggling in merging it with my existing code, which is based on Paul's Winfbe form designer, so much of the form information is hidden. It would help me, if someone more knowledgeable (most likely that's all of you) could use the graphics designer, create a form therein with a button, to generate one of Jose's graphic forms with a line on it, e.g. interface the drawline.bas code with that produced by the winfbe graphics designer.

Thanks,

Ray
Title: Re: find and replace
Post by: SeaVipe on September 30, 2019, 03:27:31 PM

Quote
interface the drawline.bas code with that produced by the winfbe graphics designer.
I too would like to know how to do that as I very much want to place a James Klutho GRID onto a WinFBE form.
Title: Re: find and replace
Post by: Paul Squires on September 30, 2019, 07:23:55 PM
Here you go.... :-)

Create a Project and a main form called frmMain.
The example uses GDI+ so that will take some time for you to learn but it is a little better than regular GDI.

Code: [Select]
#INCLUDE ONCE "Afx/CGdiPlus/CGdiPlus.inc"
#INCLUDE ONCE "Afx/CGraphCtx.inc"

''
''  Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(frmMain)

dim shared pGraphCtx AS CGraphCtx ptr

const IDC_GRCTX = 2000


' ========================================================================================
' The following example draws a line.
' ========================================================================================
SUB Example_DrawLine (BYVAL hdc AS HDC)

   ' // Create a graphics object from the window device context
   DIM graphics AS CGpGraphics = hdc
   
   ' // Get the DPI scaling ratios
   DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
   DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
   
   ' // Set the scale transform
   graphics.ScaleTransform(rxRatio, ryRatio)

   ' // Draw the line
   DIM blackPen AS CGpPen = CGpPen(GDIP_ARGB(255, 0, 0, 0), 3)
   graphics.DrawLine(@blackPen, 100.0, 100.0, 500.0, 100.0)

END SUB
' ========================================================================================


''
''
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   ' // Add a graphic control
   pGraphCtx = new CGraphCtx( sender.pWindow, _
                              IDC_GRCTX, "", _
                              0, 0, _
                              sender.ClientSize.Width, _
                              sender.ClientSize.Height)
   pGraphCtx->Clear BGR(255, 255, 255)
   
   ' // Get the memory device context of the graphic control
   DIM hdc AS HDC = pGraphCtx->GetMemDc
   
   ' // Draw the graphics
   Example_DrawLine(hdc)
   
   function = 0
End Function


''
''
Function frmMain_FormClosed( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   if pGraphCtx then Delete pGraphCtx
   Function = 0
End Function

Title: Re: find and replace
Post by: raymw on September 30, 2019, 07:33:07 PM
thanks, I'll let you know.
Not working for me, it opens the form, but no graphics drawing on it, Also, altering the values in  pGraphCtx->Clear BGR(255, 255, 255) does not change the background colour, so I guess the graphics is not being set up. Also trying to use console printing for debugging does not seem to show either., maybe the graphics is overwriting that? I've tried both 32 bit and 64 bit versions of winfbe. If it works for you, then maybe the default window properties are different.
Title: Re: find and replace
Post by: raymw on October 01, 2019, 07:36:30 AM
Clive,

 Can you try Paul's code above, see if it works for you. Thanks

Ray

(anyone else, join in, of course)
( will the new version suite winfbe 1.93 (just released) solve it, I'm running 1.92)
Title: Re: find and replace
Post by: SeaVipe on October 01, 2019, 12:01:03 PM
I had no luck last night, Ray, I'll try again this morning.
Title: Re: find and replace
Post by: SeaVipe on October 01, 2019, 01:18:25 PM
Hi Ray,
Here are the results after a bit of fiddling...


I changed the thickness of the line from 3 to 1.


Note that the caption for frmMain is "XfrmMain" but only the "X" is displayed.
frmMain Events: Load, FormClosed
Also, 6 compiler Warnings that with a little research I should be able to get rid of.
Here are the compiler switches I have set: -g -exx -w Pedantic -w Escape -w Next -w 0 -w All (probably not the best way to set compiler switches)
Title: Re: find and replace
Post by: raymw on October 01, 2019, 03:07:45 PM
Thanks Clive,
I'll poke at it some more. Presumably you didn't test on 1.93? . Not sure whether that may help, because I guess Paul tests on whatever version of winfbe he is developing at the time, and he's just released another one..
Title: Re: find and replace
Post by: SeaVipe on October 01, 2019, 03:20:21 PM
Hi Ray, I used 1.9.3 (the most recent - C:\WinFBE_Suite\FreeBASIC-1.07.1-gcc-5.2\fbc64.exe), 64Bit, Win64 Console (debug).
Successfully compilled using WinFBE 1.9.2 although it thew 2 more compiler warnings.
Title: Re: find and replace
Post by: raymw on October 03, 2019, 07:26:48 PM
What you got to do, a duh moment, pointed out to me by Paul - is you have to set the form properties to load and close. So flipping obvious when you know.

Thanks Paul, again  :D
Title: Re: find and replace
Post by: raymw on October 03, 2019, 09:04:54 PM
Right, almost there, but I'm finding that often the border styles for the forms or list boxes appear to randomly change to a non-valid type for that particular control. I reset it in the designer properties, it then compiles, until the next time, it is happening rather frequently.
Title: Re: find and replace
Post by: Paul Squires on October 04, 2019, 06:33:52 AM
Right, almost there, but I'm finding that often the border styles for the forms or list boxes appear to randomly change to a non-valid type for that particular control. I reset it in the designer properties, it then compiles, until the next time, it is happening rather frequently.
Interesting that you'd say that because eary in the visual designer development I would notice this as well. I implemented a fix and it seemed to had worked, but if you're seeing it then I better investigate more. It is related to a got/lost focus issue when the user moves from control to control.
Title: Re: find and replace
Post by: raymw on October 04, 2019, 10:11:25 AM
Hi Paul,

I just thought I'd show some of the effects I get with my programmatically generated spiral g-code. This is not what it is about, but the results are sort of pretty, if you like spikey things. A week or two ago, I was running the 2D gcode produced by my c# program, (written about 4 years ago) through a fb file, to pull it apart and add in the z coordinates. Now, I've translated the c# into fb, and added in my 3d stuff. The pictures are not 3d, merely varied the black pen colour values as each line drawn. I'm well pleased. Flying through rocks comes later.

(btw, found another very minor issue, easily solved - labels in designer. In the designer, all the characters show, but if nearly filling the label box, it is truncated in the label when form is loaded e.g. 'number points', originally, but truncated to 'number' .It seems the label size varies between design and run - simple enough to drag it a bit bigger in the designer.)

Thanks for your patience.



Title: Re: find and replace
Post by: Paul Squires on October 04, 2019, 03:02:29 PM
The truncation could be due to having another control overlapping the end of the label? The zorder could be different between designer view and runtime depending on the order in which the controls are created.
Title: Re: find and replace
Post by: raymw on October 04, 2019, 03:28:48 PM
I don't think it is to do with overlapping, Text is left aligned, and I drag to the right. If it overlapped, the text to right would be obscured, I think. Plenty of space around the labels in designer.
Another puzzling fundamental question for me - Is it possible to send data between forms without writing via textboxes/list/boxes, other elements?  Something like form1.double1 = form2.double2. I can't get variables in a form recognised outside of the form, there is bound to be a simple answer that I can't think of.
Title: Re: find and replace
Post by: SeaVipe on October 04, 2019, 04:20:36 PM
Quote
Something like form1.double1 = form2.double2.


Like a shared variable?
Title: Re: find and replace
Post by: raymw on October 04, 2019, 05:48:36 PM
Maybe, . at the moment, I'm using the 'graphics' form (frmmain)to get values from my  spiralform fields. e.g. with code in frmmain like x1 = val(spiralform.xs.SelectedItem.text ) *scale   +xoff
But, I would prefer values to be 'pushed', instead of pulled to the graphics form. Obviously, I can create list boxes on the graphics form, but I'd rather have the graphic's form be more generic, e.g, be able to set something like this in my spiralform code  - frmmain.x1 =  val(spiralform.xs.SelectedItem.text ) *scale  +xoff (and since I'm using in the spiralform xs1 = val(spiralform.xs.selecteditem) then it would make sense after that conversion, to send the value to frmmain as frmmain.xs= spiralform.xs1*scale+xoff. maybe needs to be a set/get or similar.

The intention is to have frmmain (which I will eventually rename - maybe 'plotme') as a standard sort of graphic routine to plot lines. I do not want to alter its code whenever  it needs  values from different forms.

Any help appreciated.
Title: Re: find and replace
Post by: SeaVipe on October 04, 2019, 06:05:02 PM
I sometimes use the Form's Tag property. If I need the Tag string value to be numeric (like a double) then, like your sample code, I use Val().
Title: Re: find and replace
Post by: raymw on October 04, 2019, 06:35:20 PM
Thanks Clive. I've used textboxes (hidden) but to my mind that is an unnecessary overhead. Still, moving things around as strings will have to do until something more succinct comes to mind.
I thought I could have a shared text box,(dtr.text, say) that the the two forms could access. Looking at it from a master slave communications situation, that the master sends values, the slave sets dtr.text to "stop" the master stops sending, slave processes the data it has received, sets dtr.text to "go", master sends some more. It may work, but not so far. I'll sleep on it.
Title: Re: find and replace
Post by: SeaVipe on October 04, 2019, 08:44:53 PM

Sample of The control's TAG propertyIn frmSettings:
Code: [Select]

Function frmSettings_btnTest_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
   
    Dim as string s = "frmMain.Tag set in frmMain = " + frmMain.Tag + CRLF
    frmMain.Tag = "123"
    s += "frmMain.Tag set in frmSettings = " + frmMain.Tag + CRLF
    s += "frmSettings.Tag set in frmMain = " + str(val(frmSettings.Tag )) + CRLF
    Dim as double d = val(frmSettings.Tag )
    s += "Sqr of frmSettings.Tag = " + Str( sqr(d) )
   
    frmSettings.lblTagDisplay.text = s
   
    Function = 0
End Function

in frmMain:
Code: [Select]
Function frmMain_btnSettings_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
   
    frmSettings.Tag = "54321.1234"   
    frmMain.Tag = "987"
    frmSettings.ShowDialog( frmMain ) ' Modal
    ? "-"; frmMain.Tag
       
    Function = 0
End Function


Output in image:
Title: Re: find and replace
Post by: raymw on October 05, 2019, 01:29:54 PM
The graphics part is just to give a clue as to what the final machined object will look like. I've created a couple of hidden listboxes in the graphics form, and push the values from my main form to there. It works OK, but I may work on it some more. I'm not sure if I want to print or save the drawing as a separate entity, as opposed to saving the G-code and making the thing. Thought you may be interested.  Machined out of resin for  prototyping. Works OK. A couple of quick phone snaps.
Title: Re: find and replace
Post by: Paul Squires on October 05, 2019, 02:39:59 PM
... I've created a couple of hidden listboxes in the graphics form, and push the values from my main form to there. It works OK, but I may work on it some more.
That seems like a lot of hassle when you could simply have a global variable referencing a TYPE structure that contains all of the data you need.

TYPE MyGlobalType
   MyString As String
   MyLong As Long
   MySingle As Single
   ' etc...
END TYPE

DIM SHARED gMyType AS MyGlobalType
Title: Re: find and replace
Post by: Paul Squires on October 05, 2019, 03:38:07 PM
Right, almost there, but I'm finding that often the border styles for the forms or list boxes appear to randomly change to a non-valid type for that particular control. I reset it in the designer properties, it then compiles, until the next time, it is happening rather frequently.
Interesting that you'd say that because eary in the visual designer development I would notice this as well. I implemented a fix and it seemed to had worked, but if you're seeing it then I better investigate more. It is related to a got/lost focus issue when the user moves from control to control.

I did notice (and fixed) the situation where you have a dropdown combobox open for a particular control property but then switch to another control and that dropdown remains open for the newly selected control's property. This "may" be related to the problem that we're seeing. You'll be able to test it when I release the next version.
Title: Re: find and replace
Post by: SeaVipe on October 05, 2019, 03:59:20 PM
Ray, are the 2 forms to do with a CNC machine? Is there operator interaction with the 2 forms? It seems to me that a few shared variables or, as Paul suggests, a global type, would be a much simpler approach. (Unless the forms are required for other things.)
Title: Re: find and replace
Post by: raymw on October 05, 2019, 07:55:44 PM
Hi Clive,

Not much operator interaction, mainly change a tool size,  centre the workpiece. I want to keep the graphics form as a separate inc file, I will modify it to read in the gcode directly, useful for quick checks. It just generates code for machining objects. No real purpose, maybe jelly moulds? just sort of interesting. Instead of using cad, it is easier to enter a few values. The only operator is me, and possibly one or two other interested folk. I started programmatically generating  Gcode back in dos days, (using visual basic for dos - Microsoft denied producing it when I queried if it was still around). Converted the spaghetti to c#, adding to it, machining flanges, drill holes on grid patterns, etc. added in code for 3d printing, then a few years ago, I thought, as a separate item, spirals could be interesting, so wrote a c# program to draw spirals, and engrave spirals. A few weeks ago, I was chatting to a friend who does woodturning, I said I could most likely cnc mill bowl shapes, shapes he could not cut on a normal wood turning lathe, and I revisited the spiral program, took the g-code output, parsed it using winfbe added in the third axis, and wrote the 3d code. But, since the milling cutters have a short cutting length, and no reduced shank, it means that on my machine, each cut depth can not be much more than 10mm for a 6mm router. So, every so often, as the cut goes down, it has to plane off the rest of the surface, That was easier to do by porting the c# code to fb, and adding in the planing code. fwiw, the first attempt, without the planing, the shank of the cutter, rotating at 24000rpm, set fire to the resin swarf. Not serious, but smelled a bit.

I find I only get one chance of doing the graphics. If I close the graphics form, and change some values in the main form, and try to draw it again, it opens the graphics form, but draws nothing. I can restart the application, and it will draw whatever I want, but only once.

Just for the sake of it, I may attempt to port my far more complex c# software to freebasic.  Search and replace is quite powerful.

Hi Paul,
I didn't know about global types in free basic. I could most likely more directly translated the c# code, if I'd known. Anyway, if you maintain the winfbx help file, then I think there's a typo in the
AddEllipse (CGpGraphicsPath)  parameter list  along the lines of yyur,yyub,icuryy4me   :D
Title: Re: find and replace
Post by: Josť Roca on October 05, 2019, 08:21:42 PM
The error is that this line must be removed.

y The width of the bounding rectangle for the ellipse.

Thanks for reporting it.
Title: Re: find and replace
Post by: SeaVipe on October 05, 2019, 09:58:24 PM
Hi Ray, I use global types a lot (my programs tend to be data-intensive). For me, accessing old data files created with VB, UDTs are invaluable. You can do so much with them.

Each time I create a UDT I try to learn a bit more. Here is my most recent attempt (hardly touching the surface):

Code: [Select]

Type xmlSMS


    Declare Sub get_xml()
    Declare Sub get_sms_count( ByVal in_str as String )
    Declare Sub set_ab( _
                        ByVal in_str as String, _
                        ByVal s_search1 as String, _
                        ByVal s_search2 as String, _
                        ByRef a as Integer, _
                        ByRef b as Integer _
                       )   

Declare Function get_readable_date( ByVal in_str as String ) as String
Declare Function get_contact_name ( ByVal in_str as String ) as String
Declare Function get_number       ( ByVal in_str as String ) as String
        Declare Function get_body         ( ByVal in_str as String ) as String
        Declare Function get_SMS_type     ( ByVal in_str as String ) as String

        readable_date( Any )    as String
contact_name ( Any )    as String
        call_number  ( Any )    as String
        body         ( Any )    as String
SMS_type     ( Any )    as String

file_name               as String = ""
        SMS_count            as Integer = 0
MMS_count As Integer = 0

End Type

Within the body of the include file are routines such as this that match the Declares above:

Code: [Select]

Sub xmlSMS.get_xml()   


On Local Error Goto xmlError


    Dim As Integer iCounter = 0 
    Dim As Long     f        = Freefile
    Dim As Long o = Open( file_name For Binary Access Read As #f )
    Dim As Integer i = 0
Dim As Integer  x = 0

    If o = 0 Then


        Dim As String s = ""
           
        ? "SMS Good Open"

        Do Until Eof( f )               
           
If Eof( f ) Then Exit Do

            DoEvents()
           
            Line Input #f, s               '' read a line of text ...

If Instr( 1, s, "mms date" ) > 0 Then


i = 0
'' Inceriment count
MMS_count += 1

ElseIf Instr( 1, s, "sms protocol" ) > 0 Then

i = 2
'' Increment count
SMS_count += 1

End If
           
If i = 1 Then

iCounter += 1
ReDim Preserve readable_date( iCounter )
ReDim Preserve contact_name ( iCounter )
ReDim Preserve call_number  ( iCounter )
ReDim Preserve body         ( iCounter )
ReDim Preserve SMS_type     ( iCounter )

readable_date   ( iCounter ) = get_readable_date( s )
                contact_name    ( iCounter ) = get_contact_name( s )


End If

            If i = 2 Then


iCounter += 1
ReDim Preserve readable_date( iCounter )
ReDim Preserve contact_name ( iCounter )
ReDim Preserve call_number  ( iCounter )
ReDim Preserve body         ( iCounter )
ReDim Preserve SMS_type     ( iCounter )
               
call_number     ( iCounter ) = get_number( s )
                body            ( iCounter ) = get_body( s )
                SMS_type ( iCounter ) = get_SMS_type( s )
readable_date   ( iCounter ) = get_readable_date( s )
                contact_name    ( iCounter ) = get_contact_name( s )


            End If
         
        Loop
       
        Close #f

? "SMS_Count = "; SMS_count

    Else
       
        ? "SMS Open Error: " , Err
       
    End If

Exit Sub

xmlError:


? Error code here...

End Sub

It works perfectly so "if it ain't broke, don't fix it"
Sometimes I almost feel like I know what I'm doing!
Title: Re: find and replace
Post by: raymw on October 06, 2019, 11:13:52 AM
Thanks Clive.
Although i was not going to bother with printing or saving the graphics, the c# code was fairly straightforward
Code: [Select]
    ' save drawing
'          '  if (myBitmap == null) MessageBox.Show("empty bitmap")
             
'                try
'                 if (myBitmap != null)  then
                   
'                        myBitmap.Save("s:\\test2.png")
'                        myBitmap.Save("s:\\test.jpg", System.Drawing.Imaging.ImageForrmat.Jpeg)
'                        buttonSave.Text = "Saved file."
'                    end if
                 
'                catch (Exception)
                 
'                    MessageBox.Show("There was a problem saving the file." +
'                        "Check the file permissions.")

and

Code: [Select]
private void button2_Click(object sender, EventArgs e)
       
'            PrintDialog printDialog1 = new PrintDialog()
'            'if (printDialog1.ShowDialog() == printDialog1.
'            '  { printDialog1.   PrintVisual(_PrintCanvas, "My Canvas")  }
'            printDialog1.ShowDialog()
'            if (printDialog1.ShowDialog() == DialogResult.OK)
'            {
'                ' myBitmapb.ToString().Print()
'            }

and looking through the winfbx help, it looks like if I use CMemBmp Class that there is save and print in there. I wonder how many lines of code that will take to get it working. Let's see. Who knows, i may even attempt 3d rendering... I wonder if I could graphically create anaglyphs?
Title: Re: find and replace
Post by: raymw on October 08, 2019, 10:31:16 AM
I'm struggling a bit, confused with other graphic systems I may have used in the past, and not understanding how it fits together in fb. I would like to be able to resize the drawing area on the fly. Dragging the form borders, I could resize the graphics area before drawing to it, but only before the graphic area was created. The other problem, is that it is relatively straightforward to plot lines from a previously constructed list of coordinates, but I'm not sure if I can use path.addline as in the gdiplus examples, and to be able to add lines one by one, as they are generated on another form, so I need to be able to call the graphic area and drawing routines from other forms, and iirc, some of the parameters I tried to share did not seem to be shareable. The winfbx library help is quite good, with examples of the various components, but I believe I need a more comprehensive overview, that explains to me just the fundamental structure, that I do not understand...
I thought I would return to the more inbuilt fb graphics, but  that is not capable of producing the sort of effect I want, unless I go down to the pixel level- no brushes, unless I build them.
At this rate, I'll have to go back to gardening..
Title: Re: find and replace
Post by: raymw on October 09, 2019, 01:33:32 PM
Right, almost there, but I'm finding that often the border styles for the forms or list boxes appear to randomly change to a non-valid type for that particular control. I reset it in the designer properties, it then compiles, until the next time, it is happening rather frequently.
Interesting that you'd say that because eary in the visual designer development I would notice this as well. I implemented a fix and it seemed to had worked, but if you're seeing it then I better investigate more. It is related to a got/lost focus issue when the user moves from control to control.

I did notice (and fixed) the situation where you have a dropdown combobox open for a particular control property but then switch to another control and that dropdown remains open for the newly selected control's property. This "may" be related to the problem that we're seeing. You'll be able to test it when I release the next version.

Hi Paul, another manifestation of the border problem - If I create forms, it seems that any border style I select, does not compile - error is saying ' error 99: No matching overloaded function,ACCCEPTBUTTON()  and similar for CANCELBUTTON()  Loading in a basic program that ran yesterday,  the exe. ran fine, but looking in designer view of form, it shows no entry (blank) in border style in properties. The menu items appear when I click there, as normal, but any selection, it does not compile. This means that I can not reliably edit any programs. I don't know if that helps you in narrowing down the problem area

edit to add here's a couple of parts of what is generated for two different forms, but similar in simplicity - just a form with a button, maybe a couple of text boxes.

Code: [Select]
function firstType.FormInitializeComponent( byval pForm as firstType ptr ) as LRESULT
   dim as long nClientOffset

   pForm->Text = "Form1"
   pForm->SetBounds(10,10,500,300)
   pForm->OnLoad = @first_Load
   pForm->OnClick = @first_Click
   pForm->Button1.Parent = pForm
   pForm->Button1.Text = "Button1"
   pForm->Button1.SetBounds(126,53-nClientOffset,76,29)
   pForm->Button1.OnClick = @first_Button1_Click
   pForm->Text1.Parent = pForm
   pForm->Text1.Text = "Text1"



function masterformType.FormInitializeComponent( byval pForm as masterformType ptr ) as LRESULT
   dim as long nClientOffset

   pForm->Text = "master form"
   pForm->BorderStyle = FormBorderStyle.FixedSingle
   pForm->AcceptButton = @pForm->y
   pForm->CancelButton = @pForm->y
   pForm->SetBounds(10,10,500,300)
   pForm->Button1.Parent = pForm
   pForm->Button1.Text = "Button1"
   pForm->Button1.SetBounds(146,45-nClientOffset,116,34)
   pForm->Button1.OnClick = @masterform_Button1_Click
   pForm->x.Parent = pForm
   pForm->x.Text = "x"
Title: Re: find and replace
Post by: raymw on October 12, 2019, 01:19:30 PM
Not a problem, but I needed to know, after some poking around, I found that when a form is loaded, it does a resize and a move. If when it loads, it has a form.visible=false, then it does a resize only.