2 Replies Latest reply on Apr 18, 2012 12:05 PM by philmodjunk

    problem using "Set Field By Name" in script.

    FloydMcWilliams

      Title

      problem using "Set Field By Name" in script.

      Post

      I am trying to create a sports simulation.  I have created a DB with entities representing teams/schools, conferences, venues, coaches, etc.  In the script segment which I have pasted below I am trying to schedule games for a conference.  The fields are:

      leagues::lDateStart represents the first date for which games are scheduled for the given league (conference)

      $dateGame is a local variable which represents the date on which the game being created will be played; it is initialized from the preceding field

      $homeTeam and $visitors are local variables which are the keys for the two teams

      vID is the key for the venue (arena) in which the game will be played, for league games it is the same as the home team's key

      gDate, gHT, and gVT are fields in the game record corresponding to the local variables above.  "g" does not denote global, but rather that the field belongs to a game record

      gType is a field which tells what type of game is being scheduled -- in this case "L" means that it is a league game

       

      I trigger this script from another layout, representing the league being scheduled.  The game record is created, I see the appropriate layout with the field "gID' which is an auto-generated key & I also see "gType" which is auto-generated as "N" for non-league, non-tourney.  Both "gID" and "gType" have the correct values.  Next the "N" is replaced with an "L" and then the custom dialog

      At end(loop), game# is 2

      appears which proves that all the steps have been traversed, since the game number is initialized at 1, and the 3rd to last step increments $game, a local variable which will be used to control looping once I get this problem fixed.  All the fields which I have tried to fill using "Set Field By Name:" gDate, gVT, gHT, and vID remain blank.  What am I doing wrong that these steps do not fill the fields????

       

      These are the script steps I'm using:

      Set Variable [$dateGame; Value:leagues::lDateStart]

      Set Variable [$homeTeam; Value "12"]

      Set Variable [$visitors; Value "22"]

      Go to Layout ["games" (games)]

      New Record/Request

      Go to Record/Request/Page [Last]

      Set Variable [$game; Value: 1]

      Set Field By Name ["games::gDate"; $dateGame]

      Set Field By Name ["games::gVT"; $visitors]

      Set Field By Name ["games::gHT"; $homeTeam]

      Set Field By Name ["games::vID"; $homeTeam]

      Go to Field [games::gType]

      Insert Text [Select; "L"]

      Set Variable [$game; Value:$game + 1]

      Show Custom Dialog ["end o'loop"; "At end(loop), game# is " & $game]

      Exit Script []