home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Raytracing / Raytracer / LW5VT09.LHA / Toaster / Arexx_examples / Lwe / Manual.lwm < prev    next >
Encoding:
Text File  |  1996-06-10  |  12.9 KB  |  515 lines

  1.  /*************************************************************\
  2. /                                                               \                              
  3.                Manual V1.0, by Reinhard Grams © 1994
  4. \                                                               / 
  5.  \*************************************************************/
  6.  
  7. macro_name="Manual V1.0"
  8. macro_path="/MANU"
  9.  
  10. /**************************************************************/
  11. call InitVariables()
  12. /**************************************************************/
  13.  
  14.     MAX_LINES=14
  15.  
  16.     text_path="TOASTER:LWE/MANUAL"
  17.     item=1
  18.  
  19. /**************************************************************/
  20.  
  21.     call OpenLibs()
  22.     call GlobalsRequester(macro_name)
  23.  
  24.     call LoadConfig()
  25.     item=Requester()
  26.     if (item=0) then call CleanExit()
  27.     call SaveConfig()
  28.     call DoManual()
  29.     call SaveConfig()
  30.  
  31.     call CloseLibs()
  32.     exit 0
  33.  
  34. /**************************************************************/
  35.  
  36. Requester:
  37.  
  38.     mes.ENGLISH.1="Select Topic"
  39.     mes.GERMAN.1="Auswahl des Themas"
  40.     mes.ENGLISH.2="General Overview About Requester Formulas Library ADPro Installation"
  41.     mes.GERMAN.2="Allgemeines Kurzübersicht Version Requester Formeln Library ADPro Installation"
  42.  
  43.     item=VariableChoice(mes.language.1,"",mes.language.2,words(mes.language.2),item)    
  44.     return item
  45.  
  46. /**************************************************************/
  47.  
  48. SaveConfig:
  49.  
  50.     if (open(state, config, 'W')) then do
  51.         call writeln(state, "CONF")
  52.         call writeln(state, item)
  53.         call writeln(state, text_path)
  54.         call close state
  55.     end
  56.     return
  57.  
  58. /**************************************************************/
  59.  
  60. LoadConfig:
  61.  
  62.     if (exists(config)) then do
  63.         if (open(state, config, 'R')) then do
  64.             if (readln(state)="CONF") then do
  65.                 parse value readln(state) with item .
  66.                 text_path=readln(state)
  67.             end
  68.         end
  69.         call close state
  70.     end
  71.     return
  72.  
  73. /**************************************************************/
  74. /**************************************************************/
  75.  
  76. DoManual:
  77.  
  78.     page=trunc(item)
  79.  
  80.     text_ext.ENGLISH=".ENG"
  81.     text_ext.GERMAN=".GER"
  82.  
  83.     names.1="GENERAL"
  84.     names.2="OVERVIEW"
  85.     names.3="ABOUT"
  86.     names.4="REQUEST"
  87.     names.5="FORMULAS"
  88.     names.6="LIBRARY"
  89.     names.7="ADPRO"
  90.     names.8="INSTALL"
  91.  
  92.     title.ENGLISH.1="General"
  93.     title.ENGLISH.2="Overwiev"
  94.     title.ENGLISH.3="About"
  95.     title.ENGLISH.4="Requester"
  96.     title.ENGLISH.5="Formulas"
  97.     title.ENGLISH.6="Library"
  98.     title.ENGLISH.7="ADPro"
  99.     title.ENGLISH.8="Installation"
  100.  
  101.     title.GERMAN.1="Allgemeines"
  102.     title.GERMAN.2="Übersicht"
  103.     title.GERMAN.3="Version"
  104.     title.GERMAN.4="Requester"
  105.     title.GERMAN.5="Formeln"
  106.     title.GERMAN.6="Library"
  107.     title.GERMAN.7="ADPro"
  108.     title.GERMAN.8="Installation"
  109.  
  110.     file_name=names.page||text_ext.language
  111.     page_title=title.language.page
  112.     
  113.     call LoadPage(file_name)
  114.     call TextRequester(page_title,"text",language)
  115.  
  116.     return
  117.  
  118. /**************************************************************/
  119.  
  120. LoadPage: parse arg name
  121.  
  122.     readed=0
  123.     page_name=LW_ADDFILE(text_path,name)
  124.     do while (~exists(page_name))
  125.         text_path=SelectFile(messages.language.TEXT_MESS,"TOASTER:","",selection1,"DRAWER")
  126.         if (text_path="") then call CleanExit()
  127.         page_name=LW_ADDFILE(text_path,name)
  128.     end    
  129.        if (open(state, page_name, 'R')) then do
  130.         lines=0
  131.         do until (text.language.readed="[END]" | lines>MAX_LINES)
  132.             readed=readed+1
  133.             text.language.readed=readln(state)
  134.             if (text.language.readed="[PAGE]") then lines=0
  135.             else lines=lines+1
  136.         end
  137.     end
  138.     if (text.language.readed~="[END]") then do
  139.         readed=readed+1
  140.         text.language.readed="[END]"
  141.     end
  142.  
  143.     return readed
  144.  
  145. /**************************************************************/
  146. /**************************************************************/
  147.  
  148. ErrorMessage: parse arg status, add_string, user_cancel
  149.  
  150.     continue=0
  151.     if (status~="") then do
  152.         if (user_cancel~="") then user_sel=2; else user_sel=1
  153.         if (verify(status,"0123456789")=0) then do
  154.             if (status>0 & status<INTERNAL_ERR) then do
  155.                 if (add_string~="") then do
  156.                     continue=notify(user_sel,! errors.language.status"!",add_string)
  157.                 end
  158.                 else do
  159.                     continue=notify(user_sel,! errors.language.status"!")
  160.                 end
  161.             end
  162.             else do
  163.                 continue=notify(1,! errors.language.INTERNAL_ERR"!")
  164.             end
  165.         end
  166.         else do
  167.             if (add_string~="") then continue=notify(user_sel,! status,add_string)
  168.             else continue=notify(user_sel,! status)
  169.         end            
  170.     end
  171.     return continue
  172.  
  173. /**************************************************************/
  174.  
  175. CleanExit: parse arg status, add_string, user_cancel
  176.  
  177.     call end_all()
  178.     call ErrorMessage(status, add_string, user_cancel)
  179.     call CloseLibs()
  180.     exit 0
  181.  
  182. /**************************************************************/
  183.  
  184. OpenLibs:
  185.  
  186.     if (~show('L',rexxlib)) then do
  187.         if ~addlib(rexxlib,0,-30,0) then do
  188.             call ErrorMessage(OPEN_LIB_ERR,rexxlib)
  189.             exit 10
  190.         end
  191.         if (~show('L',rexxlib)) then do
  192.             call ErrorMessage(OPEN_LIB_ERR,rexxlib)
  193.             exit 10
  194.         end
  195.     end
  196.     if (~show('L',mathlib)) then do
  197.         if ~addlib(mathlib,0,-30,0) then do
  198.             call ErrorMessage(OPEN_LIB_ERR,mathlib)
  199.             exit 10
  200.         end
  201.         if (~show('L',mathlib)) then do
  202.             call ErrorMessage(OPEN_LIB_ERR,mathlib)
  203.             exit 10
  204.         end
  205.     end
  206.     if (~show('L',supplib)) then do
  207.         if ~addlib(supplib,0,-30,0) then do
  208.             call ErrorMessage(OPEN_LIB_ERR,supplib)
  209.             exit 10
  210.         end
  211.         if (~show('L',supplib)) then do
  212.             call ErrorMessage(OPEN_LIB_ERR,mathlib)
  213.             exit 10
  214.         end
  215.     end
  216.     port=addlib("LWModelerARexx.port",0)
  217.     return 
  218.  
  219. /**************************************************************/
  220.  
  221. CloseLibs:
  222.  
  223.     if (port~="") then call remlib("LWModelerARexx.port")
  224.     return
  225.  
  226. /**************************************************************/
  227.  
  228. SelectFile: PROCEDURE EXPOSE selected_file selected_drawer
  229.     parse arg title, drawer_name, file_name, config_file, mode
  230.  
  231.     if (exists(config_file)) then do
  232.         if (open(state,config_file,'R')) then do
  233.             if (readln(state)="FSEL") then do
  234.                 drawer_name=readln(state)
  235.                 file_name=readln(state)
  236.             end
  237.             call close state
  238.         end
  239.     end
  240.     if (mode=DRAWER) then choice=getfilename(title,drawer_name,"")
  241.     else choice=getfilename(title,drawer_name,file_name)
  242.     if (choice="(none)") then return ""
  243.     selected_drawer=LW_Drawer(choice)
  244.     selected_file=LW_File(choice)
  245.     if (mode~="DRAWER") then do
  246.         if (selected_file="") then return ""
  247.     end        
  248.     if (open(state,config_file,'W')) then do
  249.         call writeln(state, "FSEL")
  250.         call writeln(state, selected_drawer)
  251.         call writeln(state, selected_file)
  252.         call close(state)
  253.     end
  254.     select 
  255.         when (mode="DRAWER") then choice=selected_drawer
  256.         when (mode="FILE") then choice=selected_file
  257.         otherwise nop
  258.     end
  259.  
  260.     return choice
  261.  
  262. /**************************************************************/
  263.  
  264. HelpRequester: parse arg title, text_array, language
  265.  
  266.     select 
  267.         when (help_type=HELP_NEVER) then return
  268.         when (help_type=HELP_FIRST) then do    
  269.             if (exists(config)) then return
  270.         end
  271.         otherwise nop
  272.     end    
  273.     if (~TextRequester(title,text_array,language)) then do
  274.         call GlobalsRequester(title,1)
  275.     end
  276.     return 
  277.  
  278. /**************************************************************/
  279.  
  280. TextRequester: parse arg title, text_array, language
  281.  
  282.     hpages=1
  283.     hline=1
  284.     do until (str="[END]")
  285.         interpret("str="text_array"."language"."hline)
  286.         if (str="[PAGE]") then hpages=hpages+1
  287.         hline=hline+1
  288.     end
  289.     call req_begin(title||pmes.language.1 "1" pmes.language.2 hpages) 
  290.     hline=1; continue=1; hpage=1
  291.     do while (continue)
  292.         interpret("htext="text_array"."language"."hline)
  293.         select
  294.             when (htext="[PAGE]") then do
  295.                 go_on=req_post()
  296.                 call req_end()
  297.                 if (go_on) then do
  298.                     hpage=hpage+1
  299.                     call req_begin(title||pmes.language.1 hpage pmes.language.2 hpages) 
  300.                 end
  301.                 else continue=0
  302.             end
  303.             when (htext="[END]") then do
  304.                 go_on=req_post()
  305.                 call req_end()
  306.                 continue=0
  307.             end
  308.             otherwise do
  309.                 id.hline=req_addcontrol("",'t',htext)
  310.             end    
  311.         end
  312.         hline=hline+1
  313.     end
  314.     return go_on
  315.  
  316. /**************************************************************/
  317.  
  318. SaveSettings: PROCEDURE EXPOSE ENV_ERR envpath globals language,
  319.     help_type verbose extension_digits
  320.  
  321.     if (~exists(envpath)) then do
  322.         address command "makedir" envpath
  323.         if (~exists(envpath)) then call CleanExit(ENV_ERR)
  324.     end
  325.     ok=0
  326.     if (open(state, globals, 'W')) then do
  327.         call writeln(state, "GLBS")
  328.         call writeln(state, language help_type verbose extension_digits)
  329.         call close(state)
  330.         ok=1
  331.     end
  332.     return ok
  333.  
  334. /**************************************************************/
  335.  
  336. LoadSettings: PROCEDURE EXPOSE ENV_ERR envpath globals language,
  337.     help_type verbose extension_digits
  338.  
  339.     if (~exists(envpath)) then do
  340.         address command "makedir" envpath
  341.         if (~exists(envpath)) then call CleanExit(ENV_ERR)
  342.     end
  343.     ok=0
  344.     if (exists(globals)) then do
  345.         if (open(state, globals, 'R')) then do
  346.             if (readln(state)="GLBS") then do
  347.                    parse value readln(state) with language help_type,
  348.                     verbose extension_digits .
  349.                 ok=1
  350.             end
  351.             call close(state)
  352.         end
  353.     end
  354.     return ok
  355.  
  356. /**************************************************************/
  357.  
  358. GlobalsRequester: PROCEDURE EXPOSE ENV_ERR envpath globals language,
  359.     help_type verbose extension_digits
  360.     parse arg title, force
  361.  
  362.     loaded=LoadSettings()
  363.     if (force="") then do
  364.         if (loaded) then return
  365.     end
  366.     call req_begin(title": Globals")
  367.     id_la=req_addcontrol("Language", 'ch',"English German")
  368.     id_he=req_addcontrol("Help", 'ch',"First Always Never")
  369.     id_ve=req_addcontrol("Verbose", 'b')
  370.     id_ex=req_addcontrol("Ext. Digits", 'n')
  371.     call req_setval(id_la, language)
  372.     call req_setval(id_he, help_type)
  373.     call req_setval(id_ve, verbose)
  374.     call req_setval(id_ex, extension_digits)
  375.     if (~req_post()) then do; call req_end(); return 0; end
  376.     language=req_getval(id_la)
  377.     help_type=req_getval(id_he)
  378.     verbose=req_getval(id_ve)
  379.     extension_digits=req_getval(id_ex)
  380.     call req_end()
  381.     if (extension_digits<2) then extension_digits=2
  382.     call SaveSettings()
  383.     return 
  384.  
  385. /**************************************************************/
  386.  
  387. GetExtension: PROCEDURE; parse arg exname
  388.  
  389.     l=length(exname)
  390.     s=verify(reverse(exname),"0123456789")
  391.     if (s>l) then return exname
  392.     if (s<2) then return ""
  393.     return substr(exname,length(exname)+2-s)
  394.     
  395. /**************************************************************/
  396.  
  397. GetBaseName: PROCEDURE; parse arg exname
  398.  
  399.     b=length(exname)-length(GetExtension(exname))
  400.     return substr(exname,1,b)
  401.     
  402. /**************************************************************/
  403.  
  404. GetExtensionDigits: PROCEDURE; parse arg exname
  405.  
  406.     return length(GetExtension(exname))
  407.  
  408. /**************************************************************/
  409.  
  410. MakeExtension: PROCEDURE; parse arg exname, ext_digits
  411.  
  412.     return right(exname,ext_digits,'0')
  413.  
  414. /**************************************************************/
  415.  
  416. VariableChoice: PROCEDURE EXPOSE language ENGLISH GERMAN pmes.
  417.     parse arg title, descriptor, array, visible, selected 
  418.  
  419.     vchoice=0
  420.     to_show=words(array); coffset=1; cpage=1; cpages=to_show/visible; 
  421.     if ((to_show//visible)>0) then cpages=cpages+1; cpages=trunc(cpages)
  422.     do while (to_show>0)
  423.         if (to_show>visible) then citems=visible; else citems=to_show
  424.         vc=""; do i=coffset to citems+coffset-1; vc=vc word(array,i); end
  425.         if (cpages>1) then call req_begin(title||pmes.language.1 cpage pmes.language.2 cpages)
  426.         else call req_begin(title)
  427.         vci=req_addcontrol(descriptor,'cv',vc)
  428.         call req_setval(vci,selected)
  429.         if (~req_post()) then do; call req_end(); return 0; end
  430.         vchoice=req_getval(vci)
  431.         call req_end()
  432.         to_show=to_show-citems; coffset=coffset+citems
  433.     end
  434.     return vchoice
  435.  
  436. /**************************************************************/
  437.  
  438. error:
  439. syntax:
  440.  
  441.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  442.     call CleanExit()
  443.  
  444. /**************************************************************/
  445. /**************************************************************/
  446.  
  447. InitVariables:
  448.  
  449. mathlib="rexxmathlib.library"
  450. rexxlib="rexxsupport.library"
  451. supplib="LWE.library"
  452. port=""
  453.  
  454. envpath="ENV:LWEnhancer"
  455. globals=envpath"/LWEN.GLB"
  456. envname=envpath||macro_path
  457. config=envname".CNF"
  458.  
  459. selection1=envname".1"
  460.  
  461. /**************************************************************/
  462.  
  463. ENGLISH=1
  464. GERMAN=2
  465.  
  466. HELP_FIRST=1
  467. HELP_ALWAYS=2
  468. HELP_NEVER=3
  469.  
  470. help_type=HELP_FIRST
  471. language=ENGLISH
  472. verbose=1
  473. extension_digits=3
  474.  
  475. /**************************************************************/
  476.  
  477. pmes.ENGLISH.1=": Page"
  478. pmes.ENGLISH.2="from"
  479. pmes.GERMAN.1=": Seite"
  480. pmes.GERMAN.2="von"
  481.  
  482. NO_ERROR=0
  483. FILE_ERR=1
  484. OPEN_LIB_ERR=2
  485. READ_ERR=3
  486. WRITE_ERR=4
  487. ENV_ERR=5
  488. INTERNAL_ERR=6
  489.  
  490. errors.ENGLISH.FILE_ERR="File not found"
  491. errors.ENGLISH.OPEN_LIB_ERR="Can't open Library"
  492. errors.ENGLISH.READ_ERR="Read Error"
  493. errors.ENGLISH.WRITE_ERR="Write Error"
  494. errors.ENGLISH.ENV_ERR="Can't create"
  495. errors.ENGLISH.INTERNAL_ERR="Internal Error"
  496.  
  497. errors.GERMAN.FILE_ERR="Datei nicht gefunden"
  498. errors.GERMAN.OPEN_LIB_ERR="Kann Library nicht öffnen"
  499. errors.GERMAN.READ_ERR="Fehler beim Lesen der Datei"
  500. errors.GERMAN.WRITE_ERR="Fehler beim Schreiben der Datei"
  501. errors.GERMAN.ENV_ERR="Kann Verzeichnis nicht anlegen"
  502. errors.GERMAN.INTERNAL_ERR="Interner Fehler"
  503.  
  504. /**************************************************************/
  505.  
  506. TEXT_MESS=1
  507.  
  508. messages.ENGLISH.TEXT_MESS="Please select the Help Directory"
  509. messages.GERMAN.TEXT_MESS="Bitte wählen Sie das Hilfeverzeichnis"
  510.  
  511. /**************************************************************/
  512.  
  513. return
  514.  
  515.