Thanks!

On Thu, Jun 29, 2017 at 12:54 PM, Aparajita Fishman <[email protected]
> wrote:

> I'm sure I must have written it at one point, it was pretty simple to
> rewrite:
>
> /***********************************************************
> ************************
>         parseConfig
>
>         $inPathOrDocRef         ->      File to parse
>         $inEOL                          ->      EOL used by config file
>         RESULT                          <-      Collection with key/value
> pairs read from file
> ************************************************************
> ***********************/
>
> method "parseConfig"($inPathOrDocRef; $inEOL = "\n")
>
>         $config := new collection
>         c_time($doc)
>
>         if (type($inPathOrDocRef) = is text)
>                 $doc := open document($inPathOrDocRef)
>         else
>                 $doc := $inPathOrDocRef
>         end if
>
>         if ($doc # ?00:00:00?)
>                 c_text($text)
>                 receive packet($doc; $text; maxlong)
>
>                 if (type($inPathOrDocRef) = is text)
>                         close document($doc)
>                 end if
>
>                 array text($lines; 0)
>                 split string($text; $inEOL; $lines; false)
>                 array text($matches; 0)
>
>                 for each ($lines; $line)
>                         if (left trim($line) # "//@")
>                                 if (regex match("/^(.+?)=(.*)$/"; $line;
> $matches))
>                                         $key := trim($matches{1})
>
>                                         if ($key)
>                                                 $config{$key} :=
> trim($matches{2})
>                                         end if
>                                 end if
>                         end if
>                 end for each
>
>         end if
>
>         return ($config)
>
> end method
>
> This is exactly as documented with the exception that the old style 4D
> comments are not recognized, only // comments.
>
> > On Jun 29, 2017, at 6:59 AM, Doug Hall <[email protected]> wrote:
> >
> > No problem. I think it's a good idea to have, so that you can have a text
> > file outside of source control, that maintains different settings between
> > your test and production servers. Right now, I'm doing a very hackish
> > condition on the current machine name.
> >
> > Doug
> >
> > On Tue, Jun 27, 2017 at 3:16 PM, Aparajita Fishman <
> [email protected]>
> > wrote:
> >
> >> The error message is exactly correct; a4d.utils.parseConfig doesn't
> exist!
> >> In fact, I can't find any trace of it in the source code. I have no idea
> >> what happened to it, or why I so thoroughly documented something that
> >> doesn't exist. My apologies!
> >>
> >>> On Jun 26, 2017, at 2:26 PM, Doug Hall <[email protected]> wrote:
> >>>
> >>> I thought I had already posted this email, but apparently it didn't go
> >>> through. :-/
> >>>
> >>> I'm trying to read a config file, as shown in the documentation, within
> >>> Active4D's "On Application Start" method:
> >>>
> >>> $path := join paths(default directory(*); "mail.ini")
> >>> if(file exists($path))
> >>>  $config := a4d.utils.parseConfig($path)
> >>>  globals{"mail.host"}:=$config{"host"}
> >>>  log message("email host: "+$config{"host"})
> >>>  // a4d.utils.setSMTPHost($config{"host"})
> >>>  // log message('SMTP host set to $config{"host"}')
> >>>  globals{"mail.to"} := $config{"to"}
> >>>  log message("Mail.ini full path: "+$path)
> >>> else
> >>>  log message('The email config file: $path does not exist.';true)
> >>> end if
> >>>
> >>> This didn't work. It errors out saying:
> >>>
> >>> Active4D: [error] The specified method does not exist:
> >>> /Users/dhall/Documents/AIDTdb/Active4D/Active4D.a4l, method
> "Active4D.On
> >>> Application Start", line 43
> >>>
> >>> Even if I refactor the above part into a Library method
> >>> (main.read_email_config) and call that from within On Application
> Start,
> >> it
> >>> gives a similar error:
> >>>
> >>> Active4D: [error] The specified method does not exist:
> >>> /Users/dhall/Documents/AIDTdb/weblib/main.a4l, method
> >>> "main.read_email_config", line 438
> >>>
> >>> Any help would be appreciated,
> >>> Doug Hall
> >>> _______________________________________________
> >>> Active4D-dev mailing list
> >>> [email protected]
> >>> http://list.aparajitaworld.com/listinfo/active4d-dev
> >>> Archives: http://active4d-nabble.aparajitaworld.com/
> >>
> >> _______________________________________________
> >> Active4D-dev mailing list
> >> [email protected]
> >> http://list.aparajitaworld.com/listinfo/active4d-dev
> >> Archives: http://active4d-nabble.aparajitaworld.com/
> >>
> > _______________________________________________
> > Active4D-dev mailing list
> > [email protected]
> > http://list.aparajitaworld.com/listinfo/active4d-dev
> > Archives: http://active4d-nabble.aparajitaworld.com/
>
> _______________________________________________
> Active4D-dev mailing list
> [email protected]
> http://list.aparajitaworld.com/listinfo/active4d-dev
> Archives: http://active4d-nabble.aparajitaworld.com/
>
_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to