Author Topic: Mastering InForm: Adding Controls to Existing Project  (Read 14638 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
Mastering InForm: Adding Controls to Existing Project
« on: August 17, 2018, 06:29:10 am »
And another thing...

Adding Controls to Existing Project

When adding a control to an existing project, I've noticed that the Event Procedure subroutines are not automatically updated.

Code: QB64: [Select]
  1. DIM SHARED ExecuteBT AS LONG

Execute Button  has just been added to a previously saved project.  Four existing controls were already in existence:

Code: QB64: [Select]
  1. DIM SHARED GravitationSimulation AS LONG
  2. DIM SHARED PictureBox1 AS LONG
  3. DIM SHARED ExitBT AS LONG
  4. DIM SHARED CauseBT AS LONG
  5. DIM SHARED ExecuteBT AS LONG

and your program automatically adds the new one to the DIM SHARED declarations.

Code: QB64: [Select]
  1. SUB __UI_Click (id AS LONG)
  2.     SELECT CASE id
  3.         CASE GravitationSimulation
  4.  
  5.         CASE ExitBT
  6.             SYSTEM
  7.         CASE CauseBT
  8.             IF Caption(CauseBT) = "Cause" THEN
  9.                 Caption(CauseBT) = "Effect"
  10.             ELSE
  11.                 Caption(CauseBT) = "Cause"
  12.             END IF
  13.  
  14.     END SELECT
  15.  

The UI_Click subroutine (along with all the relevant others) does not automatically get the new Control added.  Of course, I do not mind adding it myself if I require it to have a particular procedure - and I'm doing this manual code edit as I go along.  This is only trial code I'm working on at the moment.

Richard
« Last Edit: August 24, 2018, 10:44:59 am by odin »

FellippeHeitor

  • Guest
Re: Mastering InForm
« Reply #1 on: August 17, 2018, 07:09:34 am »
And another thing...

Adding Controls to Existing Project
(...) your program automatically adds the new one to the DIM SHARED declarations.

I've made a choice to not try to mess with user's custom code when editing an existing project.

You see, the SELECT CASE blocks added when a project is first saved isn't really required. The user can manipulate the id that is received by the event sub in a many other ways. I could have tried to scan the existing code for the proper spot and then inject the new control, but it didn't feel worth the hassle.

All that considered I hope the message below (consider only what's in quotes) did show up in your edited .bas file after saving, along with the new DIM SHARED line:

Code: QB64: [Select]
  1. IF PreserveBackup THEN
  2.             PRINT #TextFileNum, "REM NOTICE: THIS FORM HAS BEEN RECENTLY EDITED"
  3.             PRINT #TextFileNum, "'>> The controls in the list below may have been added or renamed,"
  4.             PRINT #TextFileNum, "'>> and previously existing controls may have been deleted since"
  5.             PRINT #TextFileNum, "'>> this program's structure was first generated."
  6.             PRINT #TextFileNum, "'>> Make sure to check your code in the events SUBs so that"
  7.             PRINT #TextFileNum, "'>> you can take your recent edits into consideration."
  8.             PRINT #TextFileNum, "': ---------------------------------------------------------------------------------"
  9.         END IF

If it didn't, that probably means you had previously removed the line that said:

Code: QB64: [Select]
  1. ': External modules: ---------------------------------------------------------------

And you can see how hard it'd be to predict how to alter someone else's code programmatically.
« Last Edit: August 17, 2018, 07:43:22 am by FellippeHeitor »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
Re: Mastering InForm
« Reply #2 on: August 17, 2018, 09:59:35 am »

I've made a choice to not try to mess with user's custom code when editing an existing project.

You see, the SELECT CASE blocks added when a project is first saved isn't really required. The user can manipulate the id that is received by the event sub in a many other ways. I could have tried to scan the existing code for the proper spot and then inject the new control, but it didn't feel worth the hassle.

All that considered I hope the message below (consider only what's in quotes) did show up in your edited .bas file after saving, along with the new DIM SHARED line:

Code: QB64: [Select]
  1. IF PreserveBackup THEN
  2.             PRINT #TextFileNum, "REM NOTICE: THIS FORM HAS BEEN RECENTLY EDITED"
  3.             PRINT #TextFileNum, "'>> The controls in the list below may have been added or renamed,"
  4.             PRINT #TextFileNum, "'>> and previously existing controls may have been deleted since"
  5.             PRINT #TextFileNum, "'>> this program's structure was first generated."
  6.             PRINT #TextFileNum, "'>> Make sure to check your code in the events SUBs so that"
  7.             PRINT #TextFileNum, "'>> you can take your recent edits into consideration."
  8.             PRINT #TextFileNum, "': ---------------------------------------------------------------------------------"
  9.         END IF

If it didn't, that probably means you had previously removed the line that said:

Code: QB64: [Select]
  1. ': External modules: ---------------------------------------------------------------

And you can see how hard it'd be to predict how to alter someone else's code programmatically.

Yes, it was an observation, not a criticism.  How would the updater know what to do exactly?  So, I will edit my .bas file as required.  That file does have the text lines you showed: I hadn't properly read them.

Ah, Fellippe, I think that I have managed to fall at the first hurdle.

The program which I am creating requires _MAPTRIANGLE (3D) - at least I had hoped to do it with _MAPTRIANGLE (3D).  But we found from Petr the other day that _MAPTRIANGLE (3D) requires hardware imaging.  And we found yesterday that InForm images into a PictureBox must be software.  I have verified this in my trial program: _MAPTRIANGLE (3D) does not work with InForm.

The program I'm creating is an updated version of an old SDL program of a general gravitation simulation.  In that original program, I used my own method to convert the 3D coordinates into the 2D screen dimensions.  It looks as if I'll have to use that method here - rather a pity as I had wanted to remove the conversion routine away from the calculations routine.

Your users always come up with impossible requirements.

Richard

A while back user Unseen Machine did some hacks to his local copy of InForm to be able to use OpenGL 3D statements in an InForm program. It was quite cool. I assume it could allow using hardware images as you need to.

It could also be something else entirely, and I'll be glad to investigate, but maybe he can come along and remind us what tweaks were required.

Yes, Unseen would know how to do it, I expect, though his work may be beyond my level of understanding.

Richard

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Mastering InForm: Adding Controls to Existing Project
« Reply #3 on: August 25, 2018, 10:39:14 am »
Hi Richard

about selfwriting code I want stress this point of view...
in an ideal writer of code (see VB, VC++,Delphi, VJ, C++Builder etc etc) that adds in each manager of event (SUB click or KeyDown or KeyUp or Doubleclick... etc etc) every new item (the most of them use a Select case /Switch constructor in which they add  also the ID of the new item in the list of value to test) How many unuseful lines of code  have been generated/written/compiled?
How much do you find easy to debug a so abundant code?

Also when I worked with RapidQ, I used to delete not useful code generated byself from IDE.
Surely this is not an universal choice to do, but I choose to cut if there is too code unused when I facing this issue. Clearing the forest.

Thanks to read
Programming isn't difficult, only it's  consuming time and coffee