SPONSORS:






User Tag List

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    May 2001
    Location
    San Francisco, CA, USA
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help converting string to record name

    Hello all,
    I'm trying use a String value as a record name. Anyone know how to do this?

    I'm working with a set of nested records. So I have Parent.Child.Child... I can have any number of children. I'm reading in the info for the records from a file (list of string). As I get each line and need to add it, I need to add it to the specific child level. So I build the name of the record being used as:

    sPosition = "Parent"
    for i = 1 to sLevel
    sPosition = sPosition + ".Child"
    ListAppend (@sPosition, {})

    However, when I run the code, I get an error that 'Variable Parent.Child is not defined'. I do have a record with the name Parent.Child, where Child is a list object. If I replace the referenced @sPosition with Parent.Child, it works fine.

    Anyone know how I can get Silk (5.3.2) to handle the string as if it were the record name? Or, do you have a better way to handle this?

    Thanks in advance,

    -Chris

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

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help converting string to record name

    Make sure your string is correct.

    I just tried your stuff, and it worked.

    print your string to double check your spelling.

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

  3. #3
    Junior Member
    Join Date
    Jun 2001
    Location
    Tampa, FL, USA
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help converting string to record name

    I've recently learned that there are a few limitations when working with the @ reference operator. If your passing a string called "parent.child" into a function or method then you might run into problems when trying to reference it with the @ operator. It doesn't know how to handle the "." in that case. what you can try doing is converting the string to a window. Here is some code to do so:
    WINDOW Str2Win (STRING sText)
    &nbsp int i = 1
    &nbsp string sTemp = GetField (sText, ".", i++)
    &nbsp window wReturnVal = @sTemp

    &nbsp while(sTemp != "")
    &nbsp &nbsp sTemp = GetField (s, ".", i++)
    &nbsp &nbsp if(sTemp != "")
    &nbsp &nbsp &nbsp wReturnVal = wReturnVal.@sTemp

    &nbsp return wReturnVal

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


    [This message has been edited by UsfJam (edited 06-13-2001).]

  4. #4
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help converting string to record name

    Mohneyman: Can you paste in your record type definition for us? I can't see exactly what you're trying to do from what you've written. Thanks.

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

 

 

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 10:55 PM.

Copyright BetaSoft Inc.