Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
No. of people using a DBF
Message
 
To
31/03/2005 10:58:12
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Environment versions
Visual FoxPro:
FoxPro Dos
Miscellaneous
Thread ID:
00999886
Message ID:
01000520
Views:
47
Hi

>Can you post the code for intrandrange()

Sure, here is the whole lot which I finally got working. Please correct me where I am wrong.

for login
        PRIVATE ALL LIKE z*

        PUBLIC m._vsouserfilename, m._vsouserhandle


        *** seed and ignore the first returned value
        m.zfilename = intrandrange(00000000, 99999999, 87654321)


        FOR m.zusercount = 1 TO m._vsomaxuser
                *** get an integer for use as a filename
                m.zfilename = ALLTRIM(STR(intrandrange(00000000, 99999999))) + ".acu"

                IF _file(m.zfilename)
                        m.zfh = FOPEN(m.zfilename, 12)
                ELSE
                        m.zfh = 0
                ENDIF

                IF m.zfh > -1
                        IF m.zfh > 0
                                *** Person is no longer using the application and did not
                                *** log out properly
                                = FCLOSE(m.zfilename)
                        ENDIF

                        m.zfh = FCREATE(m.zfilename)

                        EXIT
                ENDIF
        ENDFOR


        m._vsouserfilename = m.zfilename
        m._vsouserhandle   = m.zfh


        IF (!m.nomore) AND (m._vsolan AND m.zusercount > m._vsomaxuser AND m._vsomaxusers > 0)
                * WARNING !!! Maximum
                * users Allowed; Close Idle Instances of this Applcation before
                * ReStarting; If a Node was Hanged or ReBooted Please ReStart ALL
                * Instances again

                m.nomore = .T.
        ENDIF
For logout
        IF m._vsouserhandle > 0
                = FCLOSE(m._vsouserhandle)

                = deletefile(m._vsouserfilename)
        ENDIF


        RELEASE m._vsouserfilename, m._vsouserhandle
function intrandrange
        PARAMETERS m.zfrom, m.zto, m.zseed


        PRIVATE ALL LIKE z*


        IF NOT EMPTY(m.zseed)
                m.zretval = int((m.zto - m.zfrom + 1) * RAND(m.zseed) + m.zfrom)
        ELSE
                m.zretval = int((m.zto - m.zfrom + 1) * RAND() + m.zfrom)
        ENDIF


        RETURN m.zretval
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Previous
Reply
Map
View

Click here to load this message in the networking platform