Announcement

Collapse
No announcement yet.

Syntax question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Syntax question

    I'm trying to combine two strings to form a container name with the property geometry.text. How do I convert the combined string so it reads as a container?

    Example:

    dim NUM_1 as container = FindSubContainer("AB_NUM")

    dim contStr as String
    dim contName as container

    contStr = "NUM_" and CStr(i)
    contName = contStr -This is wrong
    contName.geometry.text = line[n]


    Thanks



  • #2
    What is the context, what is it for? Do you want to have a variable with a numeric value which is set into the Font geometry since you want to read that?
    You can extract the name of a container by something like FindSubContainer("AB_NUM").name which is silly since you already ask for that name in the FindSubvContainer part.
    By having the entire name being set by a ControlText and read that out contName.geometry.text
    What is the i and the n? where do they come from?

    Code:
    dim contStr as String 'this will be a string value, your contName is a Container and will not be a string.
    contStr = cStr("NUM_" & FindSubContainer("AB_NUM").geometry.text)
      println(14, contStr)   'this is to check if it is correct
    contName = contStr

    Comment


    • #3
      PHP Code:

      Dim cGroup 
      As Array[Container]
      cGroup.Push(FindSubContainer("A"))
      cGroup.Push(FindSubContainer("B"))
      cGroup.Push(FindSubContainer("C"))

      Dim line As Array[String]
      line.Push("line 1")
      line.Push("line 2")
      line.Push("line 3")

      For 
      0 To cGroup.Ubound
          cGroup
      [i].Geometry.Text line[i]
      Next 
      Last edited by mlynarik.jozef; 03-24-2020, 02:43 PM.

      Comment


      • #4
        I want to loop through a number of containers and assign strings from corresponding lines in a csv file.

        lines is an array of the source csv
        n is the data in each line I want to write to the font

        for i = lines.lbound to lines.ubound
        dim entry as string
        dim line as array[string]
        dim contStr as String
        dim contName as container
        'Split line and write to font
        entry = lines[i]
        entry.split(",",line)
        contStr = "NUM_" & CStr(i)
        contName = contStr
        contName.geometry.text = line[n]
        Next

        I want to loop through these rather than write each one.

        Thanks

        Comment


        • #5
          So I decided to number the containers and used:

          FindSubContainer("NUM_" & CStr(i)).geometry.text = line[n]

          This did what I needed and was easier to build the scene.

          Thanks again

          Comment

          Working...
          X