[M3devel] humor: How to do "math" in quake (or at least add one).

Olaf Wagner wagner at elegosoft.com
Sun May 17 16:47:43 CEST 2009


I think we should just add a function for temporary filenames
and implement it in M3.

Olaf

Quoting Jay <jay.krell at cornell.edu>:

> You might find this amusing.
>
>
> Task:
> implement a counter, in order to give
> temp files somewhat unique but not excessively
> random names
>
>
> caveats:
> it can exhibit "wraparound" behavior, but
> it should provide more than just 0-9
>
>
> solution:
>
> m3cc_ResponseFileCounter0 = "0"
> m3cc_ResponseFileCounter1 = "0"
> m3cc_ResponseFileCounter2 = "0"
>
> local ShLeaf = "_m3" & m3cc_ResponseFileCounter0 &   
> m3cc_ResponseFileCounter1 & m3cc_ResponseFileCounter2 & ".sh"
>
>
> Inc is a table/map/hashtable.
> Left of colon is key, right of colon is value.
>
>
> local Inc = { "0":"1","1":"2","2":"3","3":"4","4":"5",
> "5":"6","6":"7","7":"8","8":"9","9":"0" }
> m3cc_ResponseFileCounter2 = Inc{m3cc_ResponseFileCounter2}
> if equal(m3cc_ResponseFileCounter2, "0")
> m3cc_ResponseFileCounter1 = Inc{m3cc_ResponseFileCounter1}
> if equal(m3cc_ResponseFileCounter1, "0")
> m3cc_ResponseFileCounter0 = Inc{m3cc_ResponseFileCounter0}
> end
> end
>
>
> - Jay



-- 
Olaf Wagner -- elego Software Solutions GmbH
                Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23 45 86 96  mobile: +49 177 2345 869  fax: +49 30 23 45 86 95
    http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194




More information about the M3devel mailing list