SPONSORS:






User Tag List

Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Jun 2000
    Location
    CA
    Posts
    56
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    is it possible to include \'optional\' record fields?

    here's the deal. i want to create a record data type which has four fields for example

    type InfoData is record
    string sFirstName
    string sLastName
    string sAddress
    string sTelNo
    string sEmail

    now i have the following functions that is called

    EnterData (STRING s1, string s2, strings3, string s4, string s5)

    EnterOptionalData (STRING s1, string s2, string s3, string s4, string s5 optional)

    now with the use of the record type how do i make pass the parameters on enteroptionaldata(...) , can i just pass a null string?

    thanks.



    ------------------

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Location
    Sunyyvale CA USA
    Posts
    422
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: is it possible to include \'optional\' record fields?

    U can pass null string. Catch it with a select case statement. if optional is not null do something else ignore it.

    ------------------
    Sree
    Sree

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: is it possible to include \'optional\' record fields?

    I think I have to answer your question thrice to save some bandwidth ... as I'm not sure whether your intention is to use the record contents as the source of the data for the functions, or whether your intent is to LOAD the record from the params to the function ...

    As input:

    type InfoData is record
    < your def >

    InfoData myInfoData = {...}
    < some data assignments >

    EnterOptionalData ( myInfoData.sFirstName, myInfoData.sLastName, myInfoData.sAddress, myInfoData.sTelNo, myInfoData.sEmail )

    Now -- here's the key ... if myInfoData.sEmail is NULL, then so too will the final param to EnterOptionalData. You should be able to test it with s5.IsNull(). I didn't test the code completely, but you might even be able to check s5.isSet() inside of the function in order to know whether there is data there.

    Now, if your question was how to "load" the record ...

    Inside of EnterOptionalData() you would do:

    myInfoData.sFirstName = s1
    myInfoData.sLastName = s2
    myInfoData.sAddress = s3
    myInfoData.sTelNo = s4
    myInfoData.sEmail = s5

    In this case, sEmail will either have a value or be NULL depending on how you called the function. If you want to be "tricky" you could first test s5.IsNull() as above, then do some conditional assignment to your record contents.

    Now, if all you're asking is how do code the call to EnterOptionalData() ... you can call it any of the following ways:

    1) as above with the entire record
    2) omit the final parameter completely
    3) pass NULL as the final parameter

    Does that answer your question?

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:53 PM.

Copyright BetaSoft Inc.