{{tag>category:"OpenInsight 32-Bit" author:"Martin Drenovac" author:"Bob Carten" author:"dbakke@srpcs.com's Don Bakke"}} [[https://www.revelation.com/the-works|Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community]] ==== IF ASSIGNED(X) ELSE X=" (OpenInsight 32-Bit) ==== === At 16 OCT 2008 11:02:23PM Martin Drenovac wrote: === I saw Mike demo an auto commuter module generator last Wed in Sydney, and he had code along the lines of If assigned(script) Else script=' If assigned(format) Else format=' Whilst not the world's greatest OI developer, we've moved to this, which is quicker and IMHO neater: check_assignments(script, format) where the code for check_assignments is: SUBROUTINE CHECK_ASSIGNMENTS(P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13) /* */ If Assigned(P1) else P1=" If Assigned(P2) else P2=" If Assigned(P3) else P3=" If Assigned(P4) else P4=" If Assigned(P5) else P5=" If Assigned(P6) else P6=" If Assigned(P7) else P7=" If Assigned(P8) else P8=" If Assigned(P9) else P9=" If Assigned(P10) else P10=" If Assigned(P11) else P11=" If Assigned(P12) else P12=" If Assigned(P13) else P13=" RETURN Makes it so simple to code, cut/paste your module signature and stick the call to check_assignments in front: Cheers ---- === At 17 OCT 2008 08:16AM Bob Carten wrote: === Hi Martin Nice work. It illustrates out the power of a consistent interface. When all commuter modules have the same calling convention you can make helper functions, implement a form of inheritance and have dynamic substition of functions, e.g. function specific_commuter(ctrlEntId, method, Param1, Param2, ...) ... retval=' begin case case method=local_method" GoSub local_branch case method1,'_'=SPECIAL' funcname=method:'_HELPER' retval=function(@funcname(ctrlEntId, method, Param1,Param2, ...) case otherwise$ retval=base_commuter((ctrlEntId, method, Param1,Param2, ...) end case if get_Status(err) then .... end return retval When passing parameters I have started to use two approaches: When it is acceptable to change the parameter (pass by reference) I use If Assigned(Param1) else Param1=" When it is not acceptable to change the parameter (pass by value) I use p1=if assigned(Param1) then Param1 else '' Inside the program I treat Param1 as off limits and only P1. If I need return through a parameter I deliberately set Param1, e.g. transfer P1 to Param1 - Bob ---- === At 17 OCT 2008 08:38AM Martin Drenovac wrote: === Cheers Bob - I'm just getting to understand your Promoted Events and working on just this approach of yours in my code. Thanks for your continuing sample code... ---- === At 17 OCT 2008 09:16AM dbakke@srpcs.com's Don Bakke wrote: === We tend to put the same type of functionality into an insert so the top portion of our code contains this: $insert [/color]EVENT_SETUP[/color][/color][/size] Then in addition to any common declares, our insert contains this: Compile insert [/color]EVENT_SETUP [/color] [/color]// Make sure any event parameters which have not been assigned are nulled. [/color]If [/color]Assigned(CtrlEntId) [/color]else [/color]CtrlEntId=[/color]"" [/color]If [/color]Assigned(Event) [/color]else [/color]Event=[/color]"" [/color]If [/color]Assigned(Param1) [/color]else [/color]Param1=[/color]"" [/color]If [/color]Assigned(Param2) [/color]else [/color]Param2=[/color]"" [/color]If [/color]Assigned(Param3) [/color]else [/color]Param3=[/color]"" [/color]If [/color]Assigned(Param4) [/color]else [/color]Param4=[/color]"" [/color]If [/color]Assigned(Param5) [/color]else [/color]Param5=[/color]"" [/color]If [/color]Assigned(Param6) [/color]else [/color]Param6=[/color]"" [/color]If [/color]Assigned(Param7) [/color]else [/color]Param7=[/color]"" [/color]If [/color]Assigned(Param8) [/color]else [/color]Param8=[/color]"" [/color]If [/color]Assigned(Param9) [/color]else [/color]Param9=[/color]"" [/color]If [/color]Assigned(Param10) else [/color]Param10=[/color]"" [/color]If [/color]Assigned(Param11) [/color]else [/color]Param11=[/color]"" [/color]If [/color]Assigned(Param12) [/color]else [/color]Param12=[/color]"" [/color]If [/color]Assigned(Param13) [/color]else [/color]Param13=[/color]"" [/color]If [/color]Assigned(Param14) [/color]else [/color]Param14=[/color]"" [/color]If [/color]Assigned(Param15) [/color]else [/color]Param15=[/color]""[/color][/color][/size] dbakke@srpcs.com [url=http://www.srpcs.com]SRP Computer Solutions, Inc.[/url] [img]http://www.srpcs.com/srpicon1.gif[/img] [[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=WORKS_READ&SUMMARY=1&KEY=C5D43E3A7D3E2F70852574E50010B2C9|View this thread on the Works forum...]]