any suggestions for saving file procedure in my app - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

any suggestions for saving file procedure in my app

m4Rk0m4Rk0 Posts: 5Member

I'm a beginner in VB programming so I apologize if my questions are not appropriate (stupid, in other words:) ).

I'm making some kind of flowchart program. Each box is an image control. They are connected with lines drawn by line method. All of these 'objects' are clickable, and on user click the dialog box appears to get some user input that defines the 'object'.
The question at last, what is the best way to save this to a file? I've tried with making binary file that has some application recognizable extension, but the problem is how to put the data about the type of the image, its position, picture etc. in it.
I was hoping that simple code like:

For i = 0 To NoOfImages
Put #nFileNum, , Image1(i)
Next i

would work, but I get an error, can't put an object reference variable.


Any suggestion are welcome,
thanks

Comments

  • infidelinfidel Posts: 2,900Member
    :
    : I'm a beginner in VB programming so I apologize if my questions are not appropriate (stupid, in other words:) ).
    :
    : I'm making some kind of flowchart program. Each box is an image control. They are connected with lines drawn by line method. All of these 'objects' are clickable, and on user click the dialog box appears to get some user input that defines the 'object'.
    : The question at last, what is the best way to save this to a file? I've tried with making binary file that has some application recognizable extension, but the problem is how to put the data about the type of the image, its position, picture etc. in it.
    : I was hoping that simple code like:
    :
    : For i = 0 To NoOfImages
    : Put #nFileNum, , Image1(i)
    : Next i
    :
    : would work, but I get an error, can't put an object reference variable.

    The Image1 array is just an array of Image controls. If you want to store the actual pictures in your file then you'll have to open the image files and copy their contents to your file, but that seems like a lot of extra work to do for very little benefit. The way you save your data should be (IMO) independent of how you present it. What if you update your program with fancier images? What if you want to output it in a text-only form? Personally I would use XML, but you could certainly use any format you like. Something like this might be useful:

    [code]
    <?xml version="1.0"?>









    [/code]

    Using XML means you'll never have to worry about losing your data in a binary format you've forgotten. You can read it yourself an get an idea about what it represents. You can also use XSLT, for example, to transform the above XML file into an SVG image or something else.

    Your program itself, as the presentation layer, is the part responsible for displaying the appropriate image for each item.

    Something I just thought of too, the hypothetical data as I've represented it above is a classic graph data type (a set of nodes and a set of arcs), meaning you could potentially utilize graph algorithms to analyze whatever flows might be represented to find the shortest paths, or weighted averages, etc. That might be interesting or not, just thought I'd mention it.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

  • HackmanCHackmanC Posts: 441Member
    Simple but extended ....

    For i = 0 To NoOfImages
    Put #nFileNum, , Image1(i).Width
    Put #nFileNum, , Image1(i).Height
    Put #nFileNum, , Image1(i).etc....
    Next i

    Then read all the properties... read width, read height, ... the only problems is to write some properties like images.

    You could write a Serializable method of the class of your control to write to a stream of data (open file in vb6) ... and in the future it will work with .NET (with some modifications).

    -------
    : :
    : : I'm a beginner in VB programming so I apologize if my questions are not appropriate (stupid, in other words:) ).
    : :
    : : I'm making some kind of flowchart program. Each box is an image control. They are connected with lines drawn by line method. All of these 'objects' are clickable, and on user click the dialog box appears to get some user input that defines the 'object'.
    : : The question at last, what is the best way to save this to a file? I've tried with making binary file that has some application recognizable extension, but the problem is how to put the data about the type of the image, its position, picture etc. in it.
    : : I was hoping that simple code like:
    : :
    : : For i = 0 To NoOfImages
    : : Put #nFileNum, , Image1(i)
    : : Next i
    : :
    : : would work, but I get an error, can't put an object reference variable.
    :
    : The Image1 array is just an array of Image controls. If you want to store the actual pictures in your file then you'll have to open the image files and copy their contents to your file, but that seems like a lot of extra work to do for very little benefit. The way you save your data should be (IMO) independent of how you present it. What if you update your program with fancier images? What if you want to output it in a text-only form? Personally I would use XML, but you could certainly use any format you like. Something like this might be useful:
    :
    : [code]
    : <?xml version="1.0"?>
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : [/code]
    :
    : Using XML means you'll never have to worry about losing your data in a binary format you've forgotten. You can read it yourself an get an idea about what it represents. You can also use XSLT, for example, to transform the above XML file into an SVG image or something else.
    :
    : Your program itself, as the presentation layer, is the part responsible for displaying the appropriate image for each item.
    :
    : Something I just thought of too, the hypothetical data as I've represented it above is a classic graph data type (a set of nodes and a set of arcs), meaning you could potentially utilize graph algorithms to analyze whatever flows might be represented to find the shortest paths, or weighted averages, etc. That might be interesting or not, just thought I'd mention it.
    :
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    : [code]
    : $ select * from users where clue > 0
    : no rows returned
    : [/code]
    :
    :

    [red]Good luck![/red]
    [blue]Hackman[/blue]

  • m4Rk0m4Rk0 Posts: 5Member

    Thanks to both of you. The idea with XML is great, but I must admit that I have never worked with it. Obviously it's time to learn it :)
    For now I'll have to stick with VB6 only, so HackmanC gave me an idea how to solve my problem fairly easy. I'll put in binary file all the data I can, for image controls that will be position and one variable for 'picture recognition'. Then, in load file procedure I'll load appropriate picture in image control based on my 'picture recognition' variable. It is far from XML elegance, but i hope it'll work :)

    Thanks again to both of you


Sign In or Register to comment.