Starting App from a netfolder

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

ROBROS
Posts: 149
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 47 times
Been thanked: 13 times

Starting App from a netfolder

Post by ROBROS » Sun Sep 16, 2018 6:25 pm

Hi friends,
there is a very useful function "IsAppRunning()" in hmg. It prevents me to launch an app, that's already running. But, it won't work on a netfolder, at least that is what I have experienced. If I am wrong, tell me and do not continue reading.
The reason why I came to hmg (thank you Roberto Lopez), was, I had some small apps with UI like "from date"-"to date" (mostly reports). I did them all with xbase++ in text mode and excel made them "good-looking". xbase++ is powerful, but I did never try to go GUI. Too difficult for a non professional like me.
In the meantime almost all my apps were rewritten to hmg (professional look and feel, people saying: "hey, he's gone windows"). But then I created an app, that really needs GUI. With the help from this forum it is done to 99%. For me 2 weeks are left to go up to 100%. I will. :lol:

This app is on a netfolder to which 3-4 users have access. To prevent, that more than 1 user can start the program I came to the following solution:
Any time the program is launched, the field "username" in a table is replaced by "GetComputerName()" and the program can not be started. When the program is finished, "username" is replaced with spaces.
Before I realize that, has anyone a better suggestion?

I'm looking forward to your suggestions.
Robert
Last edited by ROBROS on Mon Sep 17, 2018 5:38 pm, edited 1 time in total.

edk
Posts: 382
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 110 times
Been thanked: 278 times

Post by edk » Sun Sep 16, 2018 7:03 pm


ROBROS
Posts: 149
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 47 times
Been thanked: 13 times

Post by ROBROS » Sun Sep 16, 2018 7:13 pm

Ok,

sounds promising...
I will try.. At home I have no network environment.

Robert

edk
Posts: 382
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 110 times
Been thanked: 278 times

Post by edk » Sun Sep 16, 2018 8:07 pm

ROBROS wrote:
Sun Sep 16, 2018 6:25 pm
This app is on a netfolder to which 3-4 users have access. To prevent, that more than 1 user can start the program I came to the following solution:
Any time the program is launched, the field "username" in a table is replaced by "GetComputerName()" and the program can not be started. When the program is finished, "username" is replaced with spaces.
Before I realize that, has anyone a better suggestion?

I'm looking forward to your suggestions.
Robert
edk wrote:
Sun Sep 16, 2018 7:03 pm
Maybe try this: http://hmgforum.com/hmgdoc/data/setmultiple.htm
ROBROS wrote:
Sun Sep 16, 2018 7:13 pm
Ok,

sounds promising...
I will try.. At home I have no network environment.

Robert
I'm sorry, Robert, but I did not read your post until the end.
This "SET MULTIPLE ON | OFF [ WARNING ]" functionality does not allow twice running application for the same user, so there will be no solution for your problem.
If I understand correctly, do not you want the application to be able to run more than one user at the same time?
It seems to me that a better solution will be to open dummy dbf in exclusive mode. If you can not open dbf in this mode, it will mean that it is being used by another user.
Your solution has one drawback, when any error occurs in the program, you may find that the field with the computer name will not be changed to empty and then the application will be "blocked" and unavailable to anyone.
My solution is not burdened with this risk, because in case of error the exclusive mode will be automatically released.

Regards, Edward.

User avatar
apais
Posts: 286
Joined: Fri Aug 01, 2008 6:03 pm
Location: uruguay
Has thanked: 36 times
Been thanked: 22 times
Contact:

Post by apais » Sun Sep 16, 2018 11:20 pm

Hi ROBROS

Create a dummy dbf and open it exclusive or exit.
This way only 1 user can be logged in at a time.

HTH
Angel

PD: This is call "semaphore". Youcan use it to sync processes among multiple users, apps, threads, ...

User avatar
dragancesu
Posts: 579
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 15 times
Been thanked: 111 times

Post by dragancesu » Mon Sep 17, 2018 5:52 am

Or change database, move to MySQL

PeteWG
Posts: 126
Joined: Sun Mar 21, 2010 5:45 pm
Has thanked: 6 times
Been thanked: 36 times

Post by PeteWG » Mon Sep 17, 2018 10:06 am

Hi,
probably the most quick (and not dirty, I hope, yet quite strict and inflexible), might be this line of code alone:

Code: Select all

hb_vfOpen( hb_ProgName(), 16 )
Put it on top of your Main() procedure and let the OS be responsible
that only one user at a time will be able to run the program.

It's similar to "semaphore" proposition made by Angel, but it doesn't require
a dummy dfb or something. It's kind of a "self-semaphore-ization" ;)

Note: I have not tested it, but see no reason to not works as expected.
Warning: Be sure your users do not used to have a "two-three hours coffee break", leaving the program running! :-)



regards,
Pete

_____________________________________________________________________________
- “Sir, I exist!”
- “However”, replied the Universe, “the fact has not created in me a sense of obligation”.
(Stephen Crane)
Last edited by PeteWG on Mon Sep 17, 2018 10:27 am, edited 1 time in total.

User avatar
dragancesu
Posts: 579
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 15 times
Been thanked: 111 times

Post by dragancesu » Mon Sep 17, 2018 10:15 am

if you want to work with dbf, ensure that each application is unique, the users (and password) table, the login () function and the table where you keep track of who is logged in
You need to make sure you know who logged in

franco
Posts: 297
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 9 times

Post by franco » Mon Sep 17, 2018 3:23 pm

Another thought. if you have a table called ? check or something. It is a dummy table with 1 field. At start of program lock the table and
when closing the program unlock the table. If the table is locked make code that program in use, try later.
Franco
Franco Bushie
Canada

ROBROS
Posts: 149
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 47 times
Been thanked: 13 times

Post by ROBROS » Mon Sep 17, 2018 6:58 pm

Hi friends,
wow, how many replies and each one of quality. I am just glad to have access to hmg-forum. :D

Just keep in mind: I am not a professional programmer. :(

@Edward (edk): I am aware of the drawback, I would give a responsible person a possibility to empty that field. My intention to go this way is simply to avoid "error-handling", I have no experience with that. :cry:
@angel and pete: semaphore is new to me, thank you. hb_vfOpen() is a harbour function?
@dragancesu: can I create sql-apps with hmg?
@franco: thank you, is similar, yet not equal to what I had in mind.

Thank you very much.
Robert

Post Reply