Skip to content

Error 3, two windows with forms using same database?

Forums Forums SIMPOL Programming Error 3, two windows with forms using same database?

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #103
    JD Kromkowski
    Participant

    Is there a trick involving locking or unlocking? It doesn’t seem possible to open two windows each with their own form, when the same table is used in each form. The error is 3 unable able to open whatever table is already opened and something link form not valid. I’m using “opendataform1” function main() //… basically the wxwindows2 example with for windows //… with the declaration dataform1 f,f2,f3,f4 // after wxwindow w is created f =@ FirstForm(iErrnum) f.setcontainer(w) f.selectfirst() // after wxwindow w2 is created f2 =@ SecondForm(iErrnum) f2.setcontainer(w2) f2.selectfirst() // after wxwindow w3 is created f3 =@ ThirdForm(iErrnum) f3.setcontainer(w3) f3.selectlast() end function function FirstForm(integer error) dataform1 f string filename; filename = “C:SIMPOLFormsTable1Form.sxf” string errtext; errtext = “” f =@ opendataform1(filename = filename, error=error, errortext=errtext) end function f function SecondForm(integer error) dataform1 f string filename; filename = “C:SIMPOLFormsTable2Form.sxf” string errtext; errtext = “” f =@ opendataform1(filename, error=error, errortext=errtext) end function f function ThirdForm(integer error) dataform1 f string filename; filename = “C:SIMPOLFormsTable1Form2.sxf” //this form uses Table1 same as firstform it is the same form. string errtext; errtext = “” // below is what throws the error 3 f =@ opendataform1(filename = filename, error=error, errortext=errtext) end function f

    #1646
    JD Kromkowski
    Participant

    sorry about the funky formatting.

    #1645
    Michael
    Keymaster

    Kromkowski wrote:
    > Is there a trick involving locking or unlocking?

    If you are opening a form and allowing it to open the tables, and if you
    are using the sbme1 method of opening them, then it will fail. The way
    around this is to open the tables first, and then pass in a valid dring
    of datasourceinfo objects, plus a valid array of tbinfo objects. This
    allows the form to use the existing tables and datasources rather than
    needing to open them again. This will be part of a more comprehensive
    example that I am currently working on.

    Ciao, Neil

    #1739
    JD Kromkowski
    Participant

    Neil Robinson wrote:

    > If you are opening a form and allowing it to open the tables, and if you
    > are using the sbme1 method of opening them, then it will fail. The way
    > around this is to open the tables first, and then pass in a valid dring
    > of datasourceinfo objects, plus a valid array of tbinfo objects. This
    > allows the form to use the existing tables and datasources rather than
    > needing to open them again. This will be part of a more comprehensive
    > example that I am currently working on.

    Well, I opening a form by using

    f =@ opendataform1(filename, error=e, errortext=errtext)

    What you are suggesting sounds so complicated.

    I should be able to open any form using opendataform1 and put it into any
    window that has been created, without all that rigamorale.

    Eg, if this can't work in a straightforward way then this really doesn't
    seem to be RAD. Here is about the simplest example I can think of to test
    whether this is working correctly. I've left out so tidying tests to see
    if form and or window was appropriately created.

    function main()
    // open four windows
    wxwindow w1,w2,w3,w4
    integer iErrnum; iErrnum = 0

    w1 =@ wxwindow.new(0, 0, 320, 240,
    captiontext="Main test window",
    error=iErrnum)

    w2 =@ wxwindow.new(320, 0, 320, 240,
    captiontext="Second test window",
    error=iErrnum,

    menubutton=.false,
    border="simple",
    backgroundrgb=0xFFFFFF,
    vscrollbar=.true,
    hscrollbar=.true)

    w3 =@ wxwindow.new(0, 240, 320, 240,
    captionbar=.false,
    error=iErrnum,
    vscrollbar=.true)

    w4 =@ wxwindow.new(320, 240, 320, 240,
    captiontext="Fourth test window",
    error=iErrnum,
    maxbutton=.false,
    backgroundrgb=0xC0C0C0)

    w1.onvisibilitychange.function =@ quit
    w2.onvisibilitychange.function =@ quit
    w3.onvisibilitychange.function =@ quit
    w4.onvisibilitychange.function =@ quit

    // open four forms
    // IT SHOULD NOT MATTER what forms you choose

    dataform1 f1,f2,f3,f4
    integer e; e = 0
    string cd, filename, result, errtext
    cd = getcurrentdirectory()
    filename = ""
    result = ""
    errtext =""

    wxfiledialog(.nul,
    "Pick a form to show",
    cd,
    "",
    "*.sxf",
    "open,mustexist",
    filename,
    result)
    f1 =@ opendataform1(filename, error=e, errortext=errtext)

    wxfiledialog(.nul,
    "Pick a form to show",
    cd,
    "",
    "*.sxf",
    "open,mustexist",
    filename,
    result)
    f2 =@ opendataform1(filename, error=e, errortext=errtext)

    wxfiledialog(.nul,
    "Pick a form to show",
    cd,
    "",
    "*.sxf",
    "open,mustexist",
    filename,
    result)
    f3 =@ opendataform1(filename, error=e, errortext=errtext)

    wxfiledialog(.nul,
    "Pick a form to show",
    cd,
    "",
    "*.sxf",
    "open,mustexist",
    filename,
    result)
    f4 =@ opendataform1(filename, error=e, errortext=errtext)

    // Put the forms into the windows

    f1.setcontainer(w1)
    f1.selectfirst()

    f2.setcontainer(w2)
    f2.selectfirst()

    f3.setcontainer(w3)
    f3.selectfirst()

    f4.setcontainer(w4)
    f4.selectfirst()

    // Wait for something to happen
    wxprocess(.inf)
    end function

    function quit(wxwindow me)
    // test for what window is being shut
    // Let me say here that I think wxprocess()
    // should be a method for a
    // particular window as in w1.wxprocess() and w1.wxbreak()

    wxbreak()
    end function

    As far as the "example you are working on", You should just make the
    personal code available. I'm really not sure what you are trying to
    protect. It seems like the short term over the long term.

    #1481
    Michael
    Keymaster

    JDK wrote:
    > Neil Robinson wrote:
    >
    >> If you are opening a form and allowing it to open the tables, and
    >> if you are using the sbme1 method of opening them, then it will
    >> fail. The way around this is to open the tables first, and then
    >> pass in a valid dring of datasourceinfo objects, plus a valid array
    >> of tbinfo objects. This allows the form to use the existing tables
    >> and datasources rather than needing to open them again. This will
    >> be part of a more comprehensive example that I am currently working
    >> on.
    >
    > Well, I opening a form by using f =@ opendataform1(filename, error=e,
    > errortext=errtext)
    >
    > What you are suggesting sounds so complicated.
    >
    > I should be able to open any form using opendataform1 and put it into
    > any window that has been created, without all that rigamorale.

    What you suggest will work fine, if you are using only PPCS data
    sources. If you are using SBME data sources, it won't work, since you
    cannot open the same file exclusively twice. SIMPOL Personal's API will
    provide these facilities for people who wish to deploy using the
    services that SIMPOL Personal will make available.

    > Eg, if this can't work in a straightforward way then this really
    > doesn't seem to be RAD. Here is about the simplest example I can
    > think of to test whether this is working correctly. I've left out so
    > tidying tests to see if form and or window was appropriately created.

    This has nothing to do with RAD, this has to do with an inability to
    open a database container exclusively in more than one place in the
    code. I grant you, that makes it more complicated to work with
    single-user databases, but we will provide the SIMPOL Personal API route
    to make that easier for those who wish to travel that direction.

    > // open four forms // IT SHOULD NOT MATTER what forms you choose

    This is a bit unrealistic. The form design assumes that it can open the
    data sources, but it can cater for not being able to do so. If you try
    to open the same database exclusively in two different view windows in
    Superbase it would also fail with the message that the file is already
    open for exclusive access.

    > As far as the "example you are working on", You should just make the
    > personal code available. I'm really not sure what you are trying to
    > protect. It seems like the short term over the long term.

    No, the company has a specific medium and long term product strategy.
    The examples I am working on are related to that strategy, as is the
    existence of SIMPOL Personal. There is a reason why the opendataform1()
    function takes as many potential parameters as it does, including a
    dring of datasourceinfo objects and an array of tbinfo objects. It
    allows the application to manage the data sources and the form to make
    use of already opened data sources and tables rather than trying to
    reopen them itself.

    Ciao, Neil

    #1744
    JD Kromkowski
    Participant

    OK, there are obviously things I didn't understand about the difference
    between SBME and PPCS data sources. And as I use SB2 rather than SB3, I
    also had some misunderstanding about what was already possible using MDI
    mode.

    1. I thought SBME was a multi-user datasource and the PPCS was a multiuser
    datasource that you use if you are creating internet application. So I
    didn't appreciate that when you open an SBME file (either directly or
    indirectly by opendataform1()that the file was being opened EXCLUSIVELY.
    I didn't think that was how SIMPOL was going to work. I thought
    everything was naturally opened in SHARE (not correct term I know) mode,
    and that you would have to LOCK a particular record if you were editing
    and storing. I am intending to recreate multi-user applications that I
    currently run in SB2. Should I be using PPCS instead of SBME?

    2. I don't use MDI mode (because I use SB2), but I was under the mistaken
    opinion that MDI mode allowed exactly what my example tries to do. (Of
    course, the only reason I am trying to do this because I am trying to do a
    work around to the lack of detailblocks more than one line and the fact
    that the data aware grid is fairly useless visually and because it is not
    sortable.

    In SB2 (or SB3), I can open up second instance of Superbase with a Form
    that uses a file(table) already being used by a Form in the first instance
    of Superbase.

    A. I only open files in share mode anyway.
    B. I equated the first instance of SB as wxwindow w1 and the second
    instance of SB as wxwindow w2.

    NR:
    > This has nothing to do with RAD, this has to do with an inability to
    > open a database container exclusively in more than one place in the
    > code.

    I am obviously not as clear as I intend. When I say your proposed
    solution is not RAD. I am making a philosophic statement not a technical
    one. I mean than it is not in keeping with principles of Rapid
    Application Development, which after all is the sine qua non of this
    product.

    NR:
    > I grant you, that makes it more complicated to work with
    > single-user databases, but we will provide the SIMPOL Personal API route
    > to make that easier for those who wish to travel that direction.

    Here again I am/was confused. I am not really interested per se in single
    user databases. I thought the difference was that
    PPCS == internet, and
    SBME == desktop application

    I presumed that both were multi-user. Is there someplace in the
    documentation that says this. I've reread all of PART IV and I don't see
    it. Am I looking at the wrong thing?

    Simpol Professional says:

    "# SIMPOL Micro Engine — single- and multi-user database engine"
    "# 3-user Server license for testing multi-user applications with the
    multi-user database engine"

    Isn't Simpol Micro Engine the same thing as SBME? But I see elsewhere when
    I search your site discussion of SDPT.

    So if I use PPCS rather than SBME then everything will be ok?

    NR:> This is a bit unrealistic. The form design assumes that it can open the
    > data sources, but it can cater for not being able to do so. If you try
    > to open the same database exclusively in two different view windows in
    > Superbase it would also fail with the message that the file is already
    > open for exclusive access.

    Of course, you have to be able to open the datasources. But here I was
    obviously confused about exclusive access. I presumed everything was
    shared access unless things were locked or during commit().

    JDK

    #1727
    Michael
    Keymaster

    JDK wrote:
    > OK, there are obviously things I didn't understand about the
    > difference between SBME and PPCS data sources. And as I use SB2
    > rather than SB3, I also had some misunderstanding about what was
    > already possible using MDI mode.

    I see the confusion. The sbme1 objects are used to create and manipulate
    database tables in the *.sbm format. They open the containers for
    exclusive access. Although the sbme1 types support locking, this is
    primarily only of interest if you are using a multi-threaded application
    where more than one thread might be trying to work with the same
    database table concurrently (but since this is possible, locking calls
    are required for various things in sbme1).

    For normal multi-user access, you need to use PPSR to share the database
    tables that are in the *.sbm containers, and use ppcstype1 objects to
    access those tables. The tricky part of this is doing database
    maintenance, which has to be done in exclusive mode, so that requires
    shutting down the PPSR server (or at least unsharing the requisite
    tables and container) so that the target table can be opened and
    reorganized or modified using the sbme1 access method.

    Ciao, Neil

    #1746
    JD Kromkowski
    Participant

    ok back to drawing board. is there a conversion app(in simpol or
    elsewhere) that converts sbme table to ppcs table?

    #1542
    Michael
    Keymaster

    JDK wrote:
    > ok back to drawing board. is there a conversion app(in simpol or
    > elsewhere) that converts sbme table to ppcs table?

    It's the same file. Just use the simpolserver.smp in
    (Utilitiessimpolserver). All you need is a config file (a sample is
    there to work from. See the readme.txt for details. Then just use the
    ppcstype1 objects. For most things not related to table creation and
    management, you can just switch the types from sbme1table to
    type(db1table) and then the code will work for both sbme1table and
    ppcstype1file.

    Ciao, Neil

    #1748
    JD Kromkowski
    Participant

    NR: If you have started it running as a server, then you can't open it as a
    file. You have to open it using the server address. In the config file
    it will tell you what the port number is (the default is port 4000). In
    Personal you switch to ppcs as the type, and in the box you would put
    127.0.0.1:4000.

    JDK: Well, now I get Error 10.

    This is what my sample.cfg looks like:

    [Server]
    port1=4000
    txfactor1=0
    port2=4001
    txfactor=6
    tcpport=24000
    logfilename=samplelog.txt

    [Files]
    1=C:simpolutilitiessimpolserveradrb.sbm,240000000
    2=C:SIMPOLDataPayroll.sbm,240000000
    3=C:SIMPOLDatawages.sbm,240000000

    ***************

    First, I really don't understand what txfactor1, txfactor, tcpport mean.

    Should I also have a line?

    port3=4003

    for the "wages.sbm

    And is this what the command line is supposed to look like:

    C:SIMPOLbinsmpw1_32.exe simpolserver.smp sample.cfg

    Or do I have to be more explicit about where simpolserver.smp and
    sample.cfg are located.

    Do I run this from windows RUN? Or do I run this from someplace in IDE?

    #1749
    JD Kromkowski
    Participant

    As to the second part of your post:

    Here is what I did:

    dataform1 f
    string filename
    filename = "C:SIMPOLFormsmyform.sxf"
    string errtext; errtext = ""
    f =@ opendataform1(filename,error=error,errortext=errtext)

    What you want me to do is

    A. open the datasource(s) and table(s) AND then
    B. pass in opendatform1(all of that other stuff like datasource and
    tables)

    I will acknowledge that in SB2 I do first open the databases(tables) I'll
    be using and then open the form.

    But I sort of feel like WHY? Once I've created a form in Personal and
    saved it as an .sxf shouldn't all of that stuff be accessible through f
    which is created via opendataform1.

    Wouldn't it be logical that

    form object f must already contain references to the datasource and the
    mastertable otherwise I would be able to open the doggone thing up and see
    the correct data.

    Why do I need to pass it when I am already passing it through the .sfx
    information?

    #1621
    JD Kromkowski
    Participant

    By the way what is the deal with formating in this forum.

    I seem to be losing my "line integrity".

    #1747
    JD Kromkowski
    Participant

    Unfortunately, I am a dingbat unable to follow the instructions in the
    readme.txt. I followed directions I think and then tried to open

    C:simpolutilitiessimpolserveradrb.sbm

    as ppcs type in "Personal" as a test. Error 48 getting tables.

    As to "just switching the types from sbme1table to type(db1table) and then
    the code will work for both sbme1table and ppcstype1file."

    I really don't know what that means in the context of what I am doing.

    At this stage of the game I am not doing anything. I am just opening up
    forms,
    e.g.:

    dataform1 f
    string filename
    filename = "C:SIMPOLFormsmyform.sxf"
    string errtext; errtext = ""
    f =@ opendataform1(filename,error=error,errortext=errtext)

    JDK

    > JDK wrote:
    >> ok back to drawing board. is there a conversion app(in simpol or
    >> elsewhere) that converts sbme table to ppcs table?

    Neil Robinson wrote:
    > It's the same file. Just use the simpolserver.smp in
    > (Utilitiessimpolserver). All you need is a config file (a sample is
    > there to work from. See the readme.txt for details. Then just use the
    > ppcstype1 objects. For most things not related to table creation and
    > management, you can just switch the types from sbme1table to
    > type(db1table) and then the code will work for both sbme1table and
    > ppcstype1file.
    > Ciao, Neil

    #1419
    Michael
    Keymaster

    JDK wrote:
    > Unfortunately, I am a dingbat unable to follow the instructions in
    > the readme.txt. I followed directions I think and then tried to open
    >
    >
    > C:simpolutilitiessimpolserveradrb.sbm
    >
    > as ppcs type in "Personal" as a test. Error 48 getting tables.

    If you have started it running as a server, then you can't open it as a
    file. You have to open it using the server address. In the config file
    it will tell you what the port number is (the default is port 4000). In
    Personal you switch to ppcs as the type, and in the box you would put
    127.0.0.1:4000.

    > As to "just switching the types from sbme1table to type(db1table) and
    > then the code will work for both sbme1table and ppcstype1file."
    >
    > I really don't know what that means in the context of what I am
    > doing.
    >
    > At this stage of the game I am not doing anything. I am just opening
    > up forms, e.g.:
    >
    > dataform1 f string filename filename = "C:SIMPOLFormsmyform.sxf"
    > string errtext; errtext = "" f =@
    > opendataform1(filename,error=error,errortext=errtext)

    OK. But if your form doesn't use adrb.sbm, then the server you are
    trying out won't matter unless it is also sharing the tables from your
    *.sbm. Not only that, but if you are just opening the form and it only
    contains information about the *.sbm, and if you don't open the data
    source first and pass the table and the datasources to the
    opendataform1() function, then it still won't know where to find the
    data and it won't be able to use the ones that you open yourself expressly.

    This is not very different from Superbase, really. In Superbase you can
    do this:

    OPEN FORM "FOO"

    Which opens the form called FOO.SBV from the current directory, and as
    long as the database files are in the current directory, or in the same
    location as they were when the form was created, it will open those
    database files that it needs.

    However, if the database files are in a separate directory, and that is
    not the same location as the files were in when the form was created,
    then you will get an error opening the database files and it will fail.

    If using a form in SBL that was stored using PPCS database sources, if
    you don't have the database tables already open when you open the form,
    it will fail (Superbase does not store enough information to reopen the
    tables for you using PPCS).

    So in Superbase, especially if you are using a program designed to run
    in teh runtime system, to make this work, you might do:

    Superbase.ErrorhandlingPush()
    SET ERROR OFF ALL
    CLEAR ERRNO
    OPEN FILE SHARE,0"..datafoobar"
    IF ERRNO <> 0 THEN
    ' Error
    ELSE
    OPEN FILE SHARE,0"..datafoo2"
    IF ERRNO <> 0 THEN
    ' Error
    ELSE
    OPEN FORM "FOO"
    END IF
    END IF
    Superbase.ErrorhandlingPop()

    In SIMPOL, you have more overhead, since the environment is not doing
    everything for you (but that is why you can also get away with shipping
    less, depending on your application). The program below requires the
    formlib.sml. If you were to expand this significantly, you would create
    an application object and put the datasources dring and the tables array
    into it as properties, as well as the ppcstype1, since there is no real
    need to have more than one, no matter how many tables from however many
    different sources you are opening.

    function main()
    ppcstype1file foobar, foo2
    ppcstype1 ppcs
    integer e
    dring datasources
    datasourceinfo dsinfo
    array tables
    tbinfo tinfo
    dataform1 f

    e = 0
    ppcs =@ ppcstype1.new(udpport=.nul, error=e)
    if ppcs =@= .nul
    // Error
    else
    foobar =@ ppcs.openudpfile("127.0.0.1:4000", "FOOBAR", error=e)
    if foobar =@= .nul
    // error
    else
    datasources =@ dring.new()
    dsinfo =@ datasourceinfo.new(datasources, ppcstype1,
    "127.0.0.1:4000", ppcs, error=e)
    datasources.add(dsinfo.appnode)
    tinfo =@ tbinfo.new()
    tinfo.source =@ dsinfo
    tinfo.table =@ foobar
    tables =@ array.new()
    tables[1] =@ tinfo
    f =@ opendataform1("myform.sxf", datasources=datasources,
    tables=tables, error=e, errortext=errtext)
    if f =@= .nul
    // error
    else
    // continue from here
    end if
    end if
    end if
    end function

    Ciao, Neil

    #1619
    Michael
    Keymaster

    JDK wrote:
    > By the way what is the deal with formating in this forum.
    >
    > I seem to be losing my "line integrity".

    I am not quite sure what you mean. I use this from the news server and
    Thunderbird myself, but I just checked and everything looks okay on the
    forum too.

    Ciao, Neil

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.