Hello world on a report

User avatar
grayghost4
Posts: 56
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Hello world on a report

Post by grayghost4 » Wednesday 22nd January 2020 4:18am

Can someone point me to a very simple report "Hello World" ?
No fancy data base or books .... just a simple one page Report with a line or two of text and a graphic

User avatar
cogier
Site Admin
Posts: 407
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Hello world on a report

Post by cogier » Wednesday 22nd January 2020 2:47pm

I have not played with gb.report2 before, in fact the documentation is so incomplete that even its purpose was a mystery to me.

This is how I got here: -

1/. Start a new Graphical Application
2/. Add the component gb.report2
3/. Right click on FMain > New > Report
4/. Delete FMain
5/. Make Report1 the startup class

You will then have a new Report Form to work with. I played with this to get: -
.... just a simple one page Report with a line or two of text and a graphic
No code needed to get this far. What do you want to do with it? I'd be interested to know how you get on.

Image
Report1.tar.gz
(34 KiB) Downloaded 5 times

User avatar
grayghost4
Posts: 56
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Re: Hello world on a report

Post by grayghost4 » Wednesday 22nd January 2020 3:45pm

Thank you , I think this is exactly what I am looking for. I am kinda new getting back to programming and am learning, I am thinking that it might be easer to do the following visually on a report, I will report back with my progress

Also should I be converting the String array "checkingaccountdata[ ]" to a class ?

The following will print 3 check on blank check paper.

Public Sub Printer1_Draw()

  Dim offset As Float
  
  For offset = 0 To dotsperinch * checkhight * 2 Step dotsperinch * checkhight  ' print 3 checks per page

    Paint.Font = Font["Aeral,12, Bold,italic"]
    Paint.DrawRichText("<Font Color= blue>" & checkingaccountdata[custname], 3400, 300 + offset)
    Paint.Font = Font["Aeral,12"]
    Paint.DrawRichText(checknumber, 8000, 300 + offset)
    Paint.Font = Font["Aeral, 10"]
    Paint.DrawText(checkingaccountdata[custaddress], 3400, 500 + offset)
    Paint.DrawText(checkingaccountdata[custaddress2], 3400, 700 + offset)
    Paint.DrawrichText("Date" & String$(22, "_"), 7000, 780 + offset)
    Paint.DrawrichText("<small>Pay to the<br> order of:</small>" & String$(52, "_"), 3000, 1100 + offset)
    Paint.DrawrichText("<h2>$</h2>", 7800, 1160 + offset)
    Paint.DrawrichText(String$(16, "_"), 8000, 1240 + offset)  ' dollar line
    Paint.DrawrichText(String$(72, "_") & "<small>Dollars</small>", 3000, 1650 + offset)
    Paint.DrawrichText("<small>Note</small>" & String$(22, "_"), 3000, 2400 + offset)
    Paint.DrawRichText(String$(35, "_"), 6300, 2400 + offset) ' signiture line 
    Paint.Font = Font["Aeral, 12, italic"]
    If checkingaccountdata[bankgraphic] <> "gambas.jpg" Then 
      Draw.Picture(PictureBox1.Picture, 3400, 1690 + offset, 2500, 500)
    Else
      Paint.DrawRichText(checkingaccountdata[bankname], 3400, 1900 + offset)
      Paint.Font = Font["Aeral, 10"]
      Paint.DrawRichText("< small >" & checkingaccountdata[bankinfo1] & "< / small >", 3400, 2100 + offset)
      Paint.DrawRichText("< small >" & checkingaccountdata[bankinfo2] & "< / small >", 3400, 2250 + offset)
   Endif
    Paint.Font = Font["MICR Encoding,20"]
    Paint.DrawText("a" & checkingaccountdata[routingnumber] & "a    " & checkingaccountdata[accountNumber] & "c   " & checknumber, 3100, 2960 + offset)
    
     checknumber -= numberofPages
  Next 
  checknumber += (numberofPages * 3) - 1
End 

User avatar
cogier
Site Admin
Posts: 407
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Hello world on a report

Post by cogier » Wednesday 22nd January 2020 5:55pm

I'm glad it helped.

The code you provided is not complete so I could not see exactly what you are trying to do. Have you spelt the font 'Aeral' correctly, should it not be 'Arial'?

I don't see why you have to make a class for an array but again if you could upload a program we can run, that would help.

User avatar
grayghost4
Posts: 56
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Re: Hello world on a report

Post by grayghost4 » Wednesday 22nd January 2020 10:07pm

You are correct ... spelling is not my best subject :lol:

I looks like the report module is not going to do what I wanted, but i will keep looking at it.

I would like feedback on my program, don't be afraid to insult me, I have a thick skin.

attached is the complete program
Attachments
checkstopost.tar.gz
(325.06 KiB) Downloaded 6 times

User avatar
cogier
Site Admin
Posts: 407
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Hello world on a report

Post by cogier » Thursday 23rd January 2020 1:14pm

Have a look at the changes I have made in the attached program.

Changes: -
Form now fully expandable
Values can now be changed by rotating the mouse wheel.
Picture works better (Suggest you don't use 'Stretch' but the 'Mode' option instead. I updated the help on this here)
'Quit' is not recommended see here. Use 'Me.Close' instead.
I was changing the TextBox text and moving to the next with the 'Tab' key. This meant the data was not updating as I did not use the enter key. It took me sometime to work this out. I have added a routine "Update" to update the array before saving.
I have made several changes to the Load and Save routines, your 'Home' may be "mhc" but mine is not. You need to use 'User.Home' to solve this issue.
There is no need to use 'Blah & "/" & Blah' use '&/' instead it will work out if you need a "/" or not.
I hope this all helps.

Image
checkstopost_CO.tar.gz
(326.38 KiB) Downloaded 5 times

User avatar
grayghost4
Posts: 56
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Re: Hello world on a report

Post by grayghost4 » Thursday 23rd January 2020 5:18pm

Thank You very much for you suggestion and changes, Many of them are things I was trying to find.
I now understand what the spring does :D
There is so much to learn between the system and the language that it is daunting for me.

I have been trying to grasp the concept of OOP ... I realize that Gambas is not a true OOP language But:
If I wanted to change the String[] array to an object or class, (as a learning experience) can you suggest how to do that and what is the syntax ?

User avatar
stevedee
Posts: 198
Joined: Monday 20th March 2017 6:06pm

Re: Hello world on a report

Post by stevedee » Friday 24th January 2020 1:48pm

grayghost4 wrote:
Thursday 23rd January 2020 5:18pm
...I have been trying to grasp the concept of OOP ... If I wanted to change the String[] array to an object or class, (as a learning experience) can you suggest how to do that and what is the syntax ?
I don't really understand your question regarding String[], so sorry if I misunderstand.

String[] is really already a class, which you can use to create a new instance of itself as an Object;
Public aSomeText As String[]

  aSomeText = New String[3]   'create an instance of the String[] class with 3 elements
So now that aSomeText is a new object based on the String[] class, you can use its properties:-

  aSomeText[0] = "BWM"
  aSomeText[1] = "Chevrolet"
  aSomeText[2] = "Jaguar"
  Me.Text = aSomeText.Count
...and you can use its Methods to do stuff like:-
  Me.Text &= aSomeText.First  'return the first item
  aSomeText.Shuffle           'shuffle the array
  Me.Text &= aSomeText.First
  aSomeText.Clear             'clear the array

User avatar
cogier
Site Admin
Posts: 407
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Hello world on a report

Post by cogier » Friday 24th January 2020 4:50pm

If I wanted to change the String[] array to an object or class, (as a learning experience) can you suggest how to do that and what is the syntax ?
I'm with Steve on this as well. The interesting thing about your array is that you don't need it. I have been messing again and reduced the code considerably.

The array was storing the data in your TextBoxes and SpinBoxes, however, the TextBoxes and SpinBoxes are already storing the data so in this version instead of referring to Array[9] I have just gone to the TextBox and got the information from there.

There is no need to check if the cheque number (Sorry UK spelling) is less that 1 as the SpinBox is set not to go less that 1 (less code)

As all the TextBoxes in this program are now in a VBox a simple 'For each...' loop will get the data from each TextBox to save.

I have also put the 'Graphics' in a ComboBox to make things easier.

NOTE. The order of the saved data is in a different order than your original, the cheque number is now last.

I have tested this code and it seems to work OK but please test it yourself before putting it into use.
checkstopost_CO.tar.gz
(325.12 KiB) Downloaded 5 times

User avatar
grayghost4
Posts: 56
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Re: Hello world on a report

Post by grayghost4 » Saturday 25th January 2020 2:42am

Thanks to both of you, I do appreciate the feedback and ideas.

Looks like lot of new techniques to learn, it is time to start over with this program from scratch.
If I just take your code and use it ... I have not learned anything ... I have to use your suggestion and implement them myself.
This is a good learning project to learn the language and GUI

Post Reply