#2184 F4 using error

wmfan1 Wed 21 Aug 2013

I'm new to F4 ide and I want to use the util pod functions in my script. I have code like this in my script:

class GenCsv { using util

File randCsv := `RandomData.csv`.toFile
         ...
         ...
         ...    
static Void main(Str[] args)

{

genVal()        // generate random data value grid
writeFile()     // write header fields and data grid to output

}

Void genVal () {
   genTS()         // generate timestamp data
 numSrc := Random
  ...
  ...
  ...
   }  

I get an error saying the compiler was expecting a type name on the using statement. I included the util library in the build.fan as in other posts here to get rid of the undefined dependency error. How can I resolve this??

wmfan1 Wed 21 Aug 2013

never mind, I figured it out.

SlimerDude Wed 21 Aug 2013

Yeah, the using statements need to go at the top of the code:

using util

class GenCsv { 
  File randCsv := `RandomData.csv`.toFile
  
  static Void main(Str[] args) {
    genVal()        // generate random data value grid
    writeFile()     // write header fields and data grid to output
  }

  Void genVal () {
    genTS()         // generate timestamp data
    numSrc := Random
    ...
  }  
}

F4 needs your build.fan to be perfect (with no trailing commas in lists) and doesn't always tell you when it's wrong. This can be a hindrance when starting a new project, so now I cut'n'paste from a template I know works - like this build.fan.

Login or Signup to reply.