'===========================================================================
' Subject: Euro Exchange Rate                 Date: 03-15-02 (  :  )       
'  Author: Hermann Seegert                    Code: PB                     
'  Origin: hermann.seegert@freenet.de       Packet: MISC.ABC
'===========================================================================
 $if 0
   ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ Ü
   ³ Programm     : ALLEURO2.BAS                                  ³ Û
   ³ Version      : 1.1                                           ³ Û
   ³ Author (c)   : Hermann Seegert                               ³ Û
   ³ Date         : Feb 2002                                      ³ Û
   ³ Language     : PowerBASIC, version 3.2                       ³ Û
   ³ Status       : FREEWARE                                      ³ Û
   ³ Function     : creating a list from EURO to  your  currency. ³ Û
   ³                The 12 countries, which are "hit" by the EURO ³ Û
   ³                implemented. Enjoy! Feedback is wanted.       ³ Û
   ³ Email:       : hermann.seegert@freenet.de                    ³ Û
   ³ Author's URL : http://people.freenet.de/hermann.seegert      ³ Û
   ³ Remarks      : My homepage is only available in German  lan- ³ Û
   ³                guage (by now)!                               ³ Û
   ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Û
   ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß

 $endif
 $lib all off
 $string 1                                'we don't need more here
 $optimize speed                          'may be, you'll need it ;)
 $compile exe "alleuro.exe"
 '
 %false=0                                 'you like some boolean? ...
 %true=not %false                         '... I do!
 on error goto mistakes                   'an errormessage for all cases
                                          '(I hope, it's not needed)
 'As you like it!
 'If you are american, you want to have the results like: 1,50 - if
 'you are e.g. german or austrian, you want to have the results like
 '1.50, won't you? So if you want to have commas, then set
 '                  %american=%true,
 'otherwise set
 '                  %american=%false
 '
 %american=%false                         'ok, I'm German...
 $if not %american
   pbvusingchrs="*$,."                    'nice internal PB- variable....
 $else
   pbvusingchrs="*$.,"                    'carefully look, what I've changed
 $endif                                   'and what it does!
 '
 shared first#,last#,step_size#           'input- variables (user's inputs)
 shared euro_ex_rate#                     'exchange rate of EURO (ini- file)
 shared currency$                         'the currencie's name (ini- file)
 shared outputfile$                       'file deversion (created soon)....
 shared internetfile$                     'file deversion (created soon)....
 '
 '--- INI - File / output files....
 'Now INI- file and output files are created....
 'function Programe$  finds out the name and the path of the program
 'The rools for the creation of these two files are explained in
 '                  SUB inifileeval(inifile$)
 'Think about the point, that you have PB.INI, PB.EUR and PB.INT, if
 'you're running the program in the IDE!
 '
 call right_instr(Progname$,inifile1$,inipath$)       'split path / file
 inifile$=inipath$+extract$(inifile1$,".")+".INI"     'INI- file created
 outputfile$=inipath$+extract$(inifile1$,".")+".EUR"  'Output- file created
 internetfile$=inipath$+extract$(inifile1$,".")+".INT"'Output- file for
                                                      'Internet- prices
 '
 'Check out, if created Outputfiles exist; may be, it's good to extend
 'this a little bit (there was no time left)....
 '
 if dir$(outputfile$,55)<>"" or dir$(internetfile$,55)<>"" then
   call shortening(outputfile$,outputfile_short$,35)
   call shortening(internetfile$,internetfile_short$,35)
   ? tab(5) "Program aborts because "+outputfile_short$+" and / or"
   ? tab(5) internetfile_short$+" already exists................."; : end
 end if
 '
 'Now, program looks for variables in the INI- file. Further infos in
 '                    SUB inifileeval(inifile$)
 '
 call inifileeval(inifile$)
 '
 ' ---------------------------- INPUTS ------------------------------
 ' place the input mask with all stuff on the screen; it's created
 ' for a normal DOS- screen: 80 colums and 25 lines. I think, it's
 ' not necessary to change the current settings ;).
 cls                                      'it's showdown..
 row%=18                                  'mask occurs in line 18
 colum%=57                                'in colum 57 mask occurs
 '
 ' program is started, so we want to see something scrolling, won't
 ' we? If you don't like, you can change this fundamentaly in pro-
 ' cedure SUB frame(...) or you can type in %false instead of
 ' %true there in   call frame(row%,colum%,...)
 call frame(row%,colum%,%true)           'frame and short help
 '*** First element in list ........
 call inputts(row%,colum%,1)             'internetprices procedure is
                                         'called here.....
 '*** Last element in list ..........
 call inputts(row%+1,colum%,2)
 '*** Step- size .........
 call inputts(row%+2,colum%,3)
 '
 'Now we can call the working routine; we've all the user's inputs
 call make_list
 end
 '
 '------------------- generally errormessages -----------------------
 '
mistakes:
 ? tab(5) "Errornumber ";err;" occured on adress ";eradr; : end
 '
 '************************ procedures and Functions *****************
 '
 '-------------------- INI- file evaluation -------------------------
 '
sub inifileeval(inifile$)
  '
  'This procedure reads the INI- file and finds out the items, you've
  'done there! If you are using the program the first time, there is
  'no INI- file. Then you are asked to make an input, and the INI-
  'INI- file is created then.
  'The INI- file is stored in the folder, where the program is stored
  'too. The name of the INI- file is created in dependency of program's
  'name and path, as you possibly can see at the beginning of this
  'listing. E.g.: If you call the program EUROME.EXE and program is
  'in folder C:\DUMMY, then INI- file will be called EUROME.INI and
  'it's stored in C:\DUMMY too. It's the same rule for the two dever-
  'sion files (EUROME.EUR and EUROME.INT). By now, I've called the
  'program ALLEURO.EXE.
  '
  'We have to look for the following two shared- variables:
  'euro_ex_rate# = the exchanging rate for the EURO
  'and
  'currency$ = currencie's name, what else!
  '
  'Let's have a look, if there is an INI- file already there! If not:
  'Tell user, what to do to create one....
  if dir$(inifile$,55)="" then    'better 55 than 39, because 55 is
                                  'all; 39 only all kind of files!
    call ini_file_start_first(inifile$)
  end if
  'May be, we need shortened filenames ;)
  call shortening(progname$,progname_short$,69)
  call shortening(inifile$,inifile_short$,69)
  'Reading the settings out of the INI- file........
  open inifile$ for input as #2
    while not eof(2)
      incr llines
      line input #2,text$
      if llines=1 then            'check, if INI- file is probably valid
        'If the following text is NOT the first line of the INI- file,
        'program will abort.
        if text$<>"+*+* INI- file for EURO- exchanging rate tool +*+*" then
          cls
          call hermibox(5,11,4,77)
          locate 5,24 : color 0,7
          ? " *** Invalid INI- file! *** ";
          color 7,0 : print : locate,13
          ? "This file pobably isn't a valid INI- file for program"
          call center_it(progname_short$,z)       'center it!
          locate ,z : ? progname_short$
          locate,34 : ? "Kill the file"
          'we can use the variable 'z' here, because the two files
          'have the same length
          locate ,z : ? inifile_short$
          locate ,8
          ? "or rename it, because the program has to use t-h-i-s filename!";
          reset : end
        end if
      end if
      'Here program reads the EURO- exchange rate .....
      if left$(text$,19)="Euro_exchange_rate=" then
        euro_ex_rate$=mid$(text$,20)
        euro_ex_rate$=remove$(euro_ex_rate$, any chr$(0,9,32,255))
        replace "," with "." in euro_ex_rate$ 'for american inputs ;)...
        euro_ex_rate#=val(euro_ex_rate$)
      end if
      'Here program reads currencie's name .......
      if left$(text$,9)="Currency=" then
        currency$=mid$(text$,10)
        currency$=remove$(currency$, any chr$(0,9,32,255))
      end if
    wend
  reset
  'If there were made wrong inputs- e.g. letters, INI- file can't
  'give something valid back....
  if euro_ex_rate#=0 or currency$="" then
    cls
    call hermibox(9,15,4,77)
    locate 9,21 : color 0,7
    ? " *** Stop! Check your INI- File! *** " : color 7,0 : locate,5
    ? "Check out your inputs in your INI- file"
    'the shortened file we have created on top....
    call center_it(inifile_short$,z)
    locate,z
    ? inifile_short$
    locate ,5
    ? "because there are no valid  items there! The  best is, you'ld kill or"
    locate ,5
    ? "rename that file and let  the  program  itself make a new, valid INI-"
    locate,5
    ? "file." : end
  end if
end sub
 '
 '---------- check out, if program starts first and give help -------
 '                      and then make INI- file
 '
sub ini_file_start_first(inifile$)
  'Procedure checks out, if this is the first time, you start the
  'program. If so, you need- and get- some help.
  cls
  call hermibox(1,23,4,77)
  locate 1,13 : color 0,7
  ? " *** Welcome to the EURO- exchanging- rate tool! *** ";
  color 7,0 : print : locate,5
  ? "This is the first time, you've started the EURO exchanging- rate pro-"
  locate,5
  ? "gram.  Therefore  the program has to know, in which currency you want"
  locate,5
  ? "to  change  the  EURO.  The most important thing is to help all those"
  locate,5
  ? "people  with  an automatically input, who are hit by the new currency"
  locate,5
  ? "EURO  personally,  because it's now THEIR currency. I was looking for"
  locate,5
  ? "the 12 EURO- exchanging- rates in the internet. Here they are:"
  locate,9
  ? "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  locate,9
  ? "³ (a) BELGIUM  - 40.3399  BEF ³ (b) GERMANY    - 1.95583  DEM ³"
  locate,9
  ? "³ (c) GREECE   - 340.750  GRD ³ (d) SPAIN      - 166.386  ESP ³"
  locate,9
  ? "³ (e) FRANCE   - 6.55957  FRF ³ (f) IRELAND    - 0.787564 IEP ³"
  locate,9
  ? "³ (g) ITALY    - 1936.27  ITL ³ (h) LUXEMBOURG - 40.3399  LUF ³"
  locate,9
  ? "³ (i) HOLLAND  - 2.20371  NLG ³ (j) AUSTRIA    - 13.7603  ATS ³"
  locate,9
  ? "³ (k) PORTUGAL - 200.482  PTE ³ (l) FINLAND    - 5.94573  FIM ³"
  locate,9
  ? "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  locate,5
  ? "The  EURO can be changed easily in one of these 12 currencies, if you"
  locate,5
  ? "press  the letter in front of the country. If you want to change EURO"
  locate,5
  ? "in any other currency, simply press ENTER and then edit the file"
  locate,5
  call shortening(inifile$,inifile_short$,50)
  ? inifile_short$
  locate,5
  ? "in an editor, which is able to store ASCII- format. Never  change the"
  locate,5
  ? "letters in that file and never change the first line! Make your input"
  locate,5
  ? "just now: "
  do
    locate 22,15 : locate,,7
    do
      curr$=ucase$(inkey$)
      color 15 : ? curr$; : color 7
    loop until curr$<>""
    select case ucase$(curr$)
      case "A"                          'Belgium
        e$="40.3399"  : c$="BEF"
      case "B"                          'Germany
        e$="1.95583"  : c$="DEM"
      case "C"                          'Greece
        e$="340.750"  : c$="GRD"
      case "D"                          'Spain
        e$="166.386"  : c$="ESP"
      case "E"                          'France
        e$="6.55957"  : c$="FRF"
      case "F"                          'Ireland
        e$="0.787564" : c$="IEP"
      case "G"                          'Italy
        e$="1936.27"  : c$="ITL"
      case "H"                          'Luxembourg
        e$="40.3399"  : c$="LUF"
      case "I"                          'Holland
        e$="2.20371"  : c$="NLG"
      case "J"                          'Austria
        e$="13.7603"  : c$="ATS"
      case "K"                          'Portugal
        e$="200.482"  : c$="PTE"
      case "L"                          'Finland
        e$="5.94573"  : c$="FIM"
      case chr$(13)                     'any other country
        e$="???" : c$="???"
    end select
    if instr(curr$,any "ABCDEFGHIJKL"+chr$(13)) and _
      len(curr$)=1 then                 'because of e.g. F7
      exit loop
    else
      locate 22,15,0 : color 15
      ? "Make a valid input!! Press any key now...." : color 7
      while not instat : wend
        t$=inkey$
        locate 22,15 : ? string$(45,chr$(32))
        iterate loop
    end if
  loop
  '--- now create the ini- file
  locate ,,0                            'non visible cursor
  'now we have the values for the INI- file!
  open inifile$ for output as #1
    ? #1,"+*+* INI- file for EURO- exchanging rate tool +*+*"
    ? #1,"Euro_exchange_rate="+e$
    ? #1,"Currency="+c$
  close #1
  '--- we have NO values but '???' in line two and three. Then you've
  '    pressed ENTER and this means, you have to edit the INI- file
  '    now!
  if e$="???" then
    cls
    call hermibox(6,19,4,77)
    locate 6,10 : color 0,7
    ? " *** Stopp! Please read the following message carefully! *** ";
    color 7,0 : print : locate,5
    ? "There are no valid values in INI- file"
    locate,5
    ? inifile_short$
    locate,5
    ? "Please edit this file  with  an ASCII- editor. You have to  store the"
    locate,5
    ? "value for the EURO- exchanging- rate  in  line  2. Delete  the  three"
    locate,5
    ? "question  marks  behind  'Euro_exchange_rate='. Then  write  down the"
    locate,5
    ? "EURO- exchanging- rate  for  your currency. Then go in line three and"
    locate,5
    ? "write down the name of your currency  instead of  the  three question"
    locate,5
    ? "marks. You  can  write  down there, what  you want ;). Then store the"
    locate,5
    ? "file in ASCII- format! NOTE: Never change anything else but  only the"
    locate,5
    ? "question  marks, because otherwise the INI- file  is  getting invalid"
    locate,5
    ? "and the program can't work! Also don't  change the  name of the  INI-"
    locate,5
    ? "file!"; : print : print : end
  end if
end sub
 '
 '-------------------------- Inputs ---------------------------------
 '
sub inputts(row%,colum%,which_inp%)
  if which_inp%=1 then         'chars, which are allowed for input 1
    sign$="0123456789iI,."
  else
    sign$="0123456789,."       'chars for input 2 and 3
  end if
  'Generally valid inputs......
  while cop_back_here#<=0.01 or cop_back_here#>1000
    color 0,7 : locate row%,colum% : ? space$(4)
    back_here$=myinput$(row%,colum%,0,4,0,back$,sign$,which_inp%)
    color 7,0
    if back_here$="" then
      print : locate row%+4-which_inp%,colum%-37 : color 15,0
      'The LOCATE 24,1 in next line seems to be a little bit
      'rare, but think about that point, that the generally
      'variables row% and colum% can be changed easily without
      'producing a bad looking DOS prompt, when you exit to DOS.
      ? "Program aborts...."; : color 7,0 : locate 24,1 : end
    end if
    'first input, sign$ has i and I for "internet- prices" in euro....
    if instr(sign$,"iI") and instr(ucase$(back_here$),"I") then
      'you want to know the prices for internet surving; you've
      'pressed 'i' in the first input....
      call internet
    end if
    replace "," with "." in back_here$      'you like commas? no problem...
    back_here#=val(back_here$) : cop_back_here#=back_here#
    'now we want some names for the inputs ....
    if which_inp%=1 then first#=back_here#
    if which_inp%=2 then last#=back_here#
    if which_inp%=3 then step_size#=back_here#
    'general error: input has to be larger than or equal 0.01
    '               and smaller than or equal 1000. You can
    '               change that of course up to 9999, but think
    '               about the large file, that will be created,
    '               when list is going from 1 to 9999 in steps
    '               of 0.01 !
    if cop_back_here#<0.01 or cop_back_here#>1000 then
      call errormessages(row%,colum%,which_inp%)
      iterate         'otherwise sometimes message ocuurs twice
      'special errors: first element in list has to be smaller than last
      '                step- size can't be larger than the difference
      '                between last and first element in list. Of course:
      '                the variables must exist!
    elseif last#>0 and first#>0 then
      if first#=>last# then
        cop_back_here#=0
        call errormessages(row%,colum%,which_inp%)
        iterate
      elseif step_size#>0 then
        differ#=last#-first#       'better than step_size#>(last#-first#)
        if step_size#>differ# then 'but I don't know why..
          cop_back_here#=0
          call errormessages(row%,colum%,which_inp%)
          iterate
        end if
      end if
    end if
  wend
end sub
 '
 '------------------------- main procedure --------------------------
 '
sub make_list
  '
  'Here program is creating the list; all input variables
  '              first#,last# and step_size#
  'are shared. Here there are built some local variables for a more
  'beautiful outfit...
  '
  x1$=using$("####.##",first#)      'outfit for first element
  x2$=using$("####.##",last#)       'last element must have a
                                    'nice outfit too :) ...
  x3$=using$("####.##",step_size#)  'and of course step- size too :) ...
  xe$=using$("########.#######",euro_ex_rate#) 'enough for all, what's coming
  xe$=rtrim$(ltrim$(xe$),"0")                  'I hope
  '
  open outputfile$ for output as #1
    'writing a little file header....
    ? #1, tab(5) "From "+ltrim$(x1$)+" to "+ltrim$(x2$)+" EURO;";
    ? #1, " Step- size is: "+ltrim$(x3$)
    ? #1, tab(5) "Exchange rate is: 1 EURO = "+xe$+" "+currency$
    ? #1, ""
    'it's better to built the main message here instead of writing
    'it down into the for- next loop (try it, and you know, what I
    'mean :))....
    call look_working
    'see, what program is doing in main for- next loop....
    for a#=first# to last# step step_size#
      a#=round(a#,2)                 '2 is enough!
      res#=euro_ex_rate#*a#
      res#=round(res#,2)             '2 is enough!
      x_1$=using$("####.##",a#)
      x4$=using$("########.##",res#) 'even for Italy enough ;). If there will
                                     'be an exchanging- rate bigger than
                                     '9999.999999, you must set 9 # ...
      'looking progress.....
      locate 12,25 : ? x_1$          'a#
      locate 12,39 : ? x2$           'last#
      call abort_program
      ? #1, tab(5) x_1$+"  EURO = "+x4$+"  "+currency$
    next
    '
  close #1
  call ending(1)
end sub
 '
 '------------------------- Internetprices wanted! ------------------
 '
sub internet
  '
  'This procedure is only for very small numbers; smaller than 1
  'Cent. This seems to be nonsense, but it isn't. For all those, who
  'wants to know the exact prices for internet- providers in their
  'former currency!
  'Here using$ isn't necessary, because the list is fixed....
  '
  xe$=using$("########.#######",euro_ex_rate#)
  xe$=rtrim$(ltrim$(xe$),"0")
  call look_working
  open internetfile$ for output as #1
    'writing a little file header....
    $if %american
      ? #1, tab(5) "Internet- from 0,003 to 0,02 EURO "_
                   "in steps of 0,00001 EURO" : end_numb$="0,02"
    $else
      ? #1, tab(5) "Internet- from 0.003 to 0.02 EURO "_
                   "in steps of 0.00001 EURO" : end_numb$="0.02"
    $endif
    ? #1, tab(5) "Exchange rate is: 1 EURO = "+xe$+" "+currency$
    ? #1, ""
    '
    'main for- next loop....
    for a#=0.0003 to 0.020001 step 0.00001
      a#=round(a#,5)
      t$=inkey$
      res#=euro_ex_rate#*a#
      res#=round(res#,5)                 '5 is needed here!
      x1$=using$("#.#####",a#)
      x2$=using$("###.#####",res#)       'even for Italy enough ;)
      locate 12,25 : ? x1$               'a#
      locate 12,41 : ? end_numb$         'fixed!
      call abort_program                 'possibility for abort
      ? #1, tab(5) x1$+"  EURO = "+x2$+"  "+currency$
    next
    '
  close #1
  call ending(2)
end sub
 '
 '---------------- simple message on screen -------------------------
 '
sub look_working
  'while program is working, we want to see something, which shows
  'the progress.
  cls : locate 12,5 : ? "Busy working number ";
  locate 12,33 : ? " from "; : locate 12,47 : ? " ....      ";
end sub
 '
 '-------------------- possibility to abort program -----------------
 '
sub abort_program
  'possibility to abort- well, not nearly necessary, I assume,
  'but if there is a very big list or a very slow CPU, may be,
  'it's fine, that this is possible....
  t$=inkey$
  if t$=chr$(27) then             'possibility for abort....
    print : ? tab(5) "Program aborts...."; : close #1 : end
  end if
end sub
 '
 '-------------------- ending for the two main procedures -----------
 '
sub ending(numm)
  'Procedure is called by the two working procedures SUB make_list
  'and SUB internet. Let's come to an end now.....
  print : print
  ? tab(5) "Ready! Result in file:"
  if numm=1 then
    call shortening(outputfile$,outputfile_short$,60)
    ? tab(5) outputfile_short$; : end
  else
    call shortening(internetfile$,internetfile_short$,60)
    ? tab(5) internetfile_short$; : end
  end if
end sub
 '
 '--------------------- Input errormessages -------------------------
 '
sub errormessages(row%,colum%,which_inp%)
  '   small errormessages, which is called three times by
  '               SUB inputts(...)
  color 15,0 : print : locate row%+4-which_inp%,colum%-37
  ? "Wrong input! Press a key for a new one..." : color 7,0
  while not instat : wend
    t$=inkey$
    locate row%+4-which_inp%,colum%-37 : ? string$(41,chr$(32))
end sub
 '
 '------------------------- frame -----------------------------------
 '
sub frame(row%,colum%,help%)
  'remove or change the following, if you don't like it or simply
  'set help%=0 in the call of the procedure.
  if help%=%true then
    locate row%-16,5 : color 4,0
    ? string$(70,chr$(219)) : color 7,0
    delay .1
    locate row%-15,5
    for a=row%-14 to row%+7
      locate ,5 : ? string$(70,chr$(219))
      delay .05
    next a
    delay .3
    locate row%+6,5 : color 1,0
    ? string$(70,chr$(219)) : color 7,0
  end if
  'Here the box is created and a little text to help the user for the
  'first....
  call hermibox(row%-15,row%+5,colum%-38,colum%+7)
  locate row%-14,colum%-37
                    ? "This is  an EURO- exchanging  tool, which"
  locate,colum%-37: ? "allows you  to create a list from EURO to"
  locate,colum%-37: ? "your prefered  currency. May be, you  be-"
  locate,colum%-37: ? "long to one  of the (current) 12 nations,"
  locate,colum%-37: ? "who are "+chr$(34)+"hit"+chr$(34)+" by the";
                    ? " EURO. So  what?  You"
  locate,colum%-37: ? "don't want to go shopping with a calcula-"
  locate,colum%-37: ? "tor, won't you? So create a list with the"
  locate,colum%-37: ? "prices, you are looking for and print it!"
  locate,colum%-37: ? "For each input you get a special help  by"
  locate,colum%-37: ? "pressing F1. Use  it! You can  abort  the"
  locate,colum%-37: ? "program at  each time by  simply pressing"
  locate,colum%-37: ? "ENTER. Close  your inputs with ENTER too."
  locate,colum%-37: ? "All  right then! Good luck with the EURO!"
  locate,colum%-39: ? chr$(204)+string$(43,chr$(205))+chr$(185)
  '
  'little input- mask.....
  locate row%,colum%-37   : ? "1. First element in list: "
  locate row%+1,colum%-37 : ? "2. Last element in  list: "
  locate row%+2,colum%-37 : ? "3. Step- size in list:    "
  color 0,7 : locate row%,colum% : ? space$(4)
  color 0,7 : locate row%+1,colum% : ? space$(4)
  color 0,7 : locate row%+2,colum% : ? space$(4)
  locate row%-15,colum%-35 : ? " *** EURO- exchanging- rate tool *** "
  locate row%+5,colum%-35 :  ? " *** programed by Hermann Seegert ** "
  color 7,0
end sub
 '
 '------------------------- little pretty box -----------------------
 '
sub hermibox(zo%,zu%,lr%,rr%)
  'zo%=line above / zu%=bottom line / lr%=left margine / rr%=right margine
  locate zo%,lr%-1 : ? chr$(201)+string$(rr%-lr%-2,chr$(205))+chr$(187);
  locate zu%,lr%-1 : ? chr$(200)+string$(rr%-lr%-2,chr$(205))+chr$(188);
  for p%=zo%+1 to zu%-1
    locate p%,lr%-1 : ? chr$(186)+string$(rr%-lr%-2,32)+chr$(186);
  next p%
end sub
 '
 '---------------------- special help for each input -----------------
 '
sub little_help(row%,colum%,which_inp%)
  locate row%-15,colum%-35,0
  ? " **** Special help for input";which_inp%;"**** "
  color 7,0
  'each help line has 41 bytes
  if which_inp%=1 then           'help for input 1
    locate row%-14,colum%-37 : ? "Here you make your first  input. This  is"
    locate row%-13,colum%-37 : ? "the first element of  the list, which the"
    locate row%-12,colum%-37 : ? "program will  create. E.g.: You  want  to"
    locate row%-11,colum%-37 : ? "have a list  from 0.01 EURO to 100  EURO."
    locate row%-10,colum%-37 : ? "Then  type in 0.01 now. If  you  want  to"
    locate row%-9,colum%-37  : ? "know the prices for surving in the inter-"
    locate row%-8,colum%-37  : ? "net, then simply press 'i' here and  pro-"
    locate row%-7,colum%-37  : ? "gram  begins to work (it's a fixed list)."
    locate row%-6,colum%-37  : ? "Otherwise type in the first  element  and"
    locate row%-5,colum%-37  : ? "press ENTER. Note: You can  type  in num-"
    locate row%-4,colum%-37  : ? "bers between  0.01 and  1000; it  doesn't"
    locate row%-3,colum%-37  : ? "make sense to type in 1000  as to be  the"
    locate row%-2,colum%-37  : ? "first element in the self defined list ;)"
    locate row%-1,colum%-39  : ? chr$(186,32)+_
                                 "Smaller inputs than 0.01 normally make no";
                               ? chr$(32,186)
    locate row%,colum%-37    : ? "sense, because  there is  no  EURO- piece"
    locate row%+1,colum%-37  : ? "smaller than 1 Cent. For internet  prices"
    locate row%+2,colum%-37  : ? "- with 'i'- you get a list from 0.0003 to"
    locate row%+3,colum%-37  : ? "0.02 in steps of 0.00001- probably  small"
    locate row%+4,colum%-37  : ? "enough. Now make your input!!"
  elseif which_inp%=2 then       'help for input 2
    locate row%-14,colum%-37 : ? "You've done your first  input. All  right"
    locate row%-13,colum%-37 : ? "then! Now you have to type in  a  number,"
    locate row%-12,colum%-37 : ? "which is bigger  than  the first. I hope,"
    locate row%-11,colum%-37 : ? "you'll find that ok, because it's  a list"
    locate row%-10,colum%-37 : ? "from... to ;). The  border of your  high-"
    locate row%-9,colum%-37  : ? "est input is 1000. Good  luck!  Note: The"
    locate row%-8,colum%-37  : ? "'i' for internet-  prices isn't  possible"
    locate row%-7,colum%-37  : ? "here. If you want them, start the program"
    locate row%-6,colum%-37  : ? "again and  type in the 'i' in  the  first"
    locate row%-5,colum%-37  : ? "input!                                   "
    for x%=1 to 7
      locate row%-5+x%,colum%-37 : ? string$(42,chr$(32))
    next x%
    locate row%-1,colum%-39  : ? chr$(186,32)+string$(41,chr$(32))+_
                                 chr$(32,186)
  elseif which_inp%=3 then       'help for input 3
    locate row%-14,colum%-37 : ? "And now you  make  your last  input. I've"
    locate row%-13,colum%-37 : ? "called it 'step- size'. Probably  you as-"
    locate row%-12,colum%-37 : ? "sume the right thing behind  it. Your in-"
    locate row%-11,colum%-37 : ? "puts  you have done  are marking the low-"
    locate row%-10,colum%-37 : ? "est and the highest border  of your list."
    locate row%-9,colum%-37  : ? "Now you need  the  step. E.g.: Step- size"
    locate row%-8,colum%-37  : ? "1 means, that each element  in  your list"
    locate row%-7,colum%-37  : ? "will increase up to 1 (e.g.: 1,2,3,4...)."
    locate row%-6,colum%-37  : ? "That's it! Type ENTER and have a look  in"
    locate row%-5,colum%-37  : ? "the file, the results are stored. The na-"
    locate row%-4,colum%-37  : ? "me is shown at the end  of working. Note:"
    locate row%-3,colum%-37  : ? "If you choose  a  very small  step- size,"
    locate row%-2,colum%-37  : ? "program  will  work a  long time. May be,"
    locate row%-1,colum%-39  : ? chr$(186,32)+_
                               "you want to  abort  working  process. You"+_
                               chr$(32,186)
    locate row%,colum%-37    : ? "can do that by pressing ESC at any  time."
    locate row%+1,colum%-37  : ? "Generally remark: If there will be an ex-"
    locate row%+2,colum%-37  : ? "changing- rate "+chr$(62)+_
                                 " 9999,999999 for  the EU-"
    locate row%+3,colum%-37  : ? "RO, program will not work exactly!"
  end if
  color 0,7
  locate row%+5,colum%-35 : ? "    Press any key to program....    "
  color 7,0
  while not instat : wend
    eee$=inkey$
    'I don't want to see the scrolling entry all the time, therefore
    'I've put in here the "1".
    call frame(row%,colum%,0)
    color 0,7
end sub
 '
 '------------------------ make to long paths short -----------------
 '
sub shortening(file$,fileshort$,how_long)
  '
  'Remark: If length of file$ is smaller than or equal 'how_long',
  'then fileshort$ = file$
  '
  if len(file$)>how_long then
    fileshort$=left$(file$,3)+"..."+right$(file$,how_long-6)
  else              'no reason, to make file shorter
    fileshort$=file$
  end if
end sub
 '
 '---------------------- input function --------------------------------
 '
function myinput$(row%,colum%,position%,inputlength%,_
         iinsert%,back$,sign$,which_inp%)
  '
  'The original of this nice input function is much bigger and works
  'really fine. Here I've cut it, because I didn't need all its
  'features. If you like the original, you can send me an email. BUT:
  'The variables are in German language; may be, you will have some
  'work to change it!
  '
  'Variables, which are used:
  '
  '           row% = startline
  '         colum% = start position in line
  '      position% = position, where cursor has to be
  '   inputlength% = input border
  '       iinsert% = 0 = insert; 1 = overwrite
  '          back$ = key, when leaving function (e.g. chr$(13))
  '          sign$ = erlaubte eingabe Zeichen
  '
  DO
    locate row%,colum%
    ? text$;
    if iinsert%=0 then              'insert modus (cursor= þ)
      locate row%,colum%+position%,1,4,13
    else                            'overwrite modus (cursor= _)
      locate row%,colum%+position%,1,12,13
    end if
    do
      button$=inkey$                 'make your input
    loop while button$=""
    select case button$              'what key have you pressed?
      case chr$(8)                   'Backspace (delete sign left)
        if position%>0 then
          text$=mid$(text$,1,position%-1)+mid$(text$,position%+1)
          decr position%
          locate row%,colum%        'position
          ? space$(inputlength%);   'print spaces.....
        end if                      'text will be an screen at the end
      case chr$(0,71)               'Pos 1
        position%=0
      case chr$(0,79)               'End
        position%=len(text$)
      case chr$(0,82)               'insert
        if iinsert%=1 then
          iinsert%=0                'insert- modus
        else
          iinsert%=1                'overwrite- modus
        end if
      case chr$(0,75)               'arrow left
        if position%>0 then decr position%
      case chr$(0,77)               'arrow right
        if position%<len(text$) then incr position%
      case chr$(0,83)               'delete
        text$=mid$(text$,1,position%)+mid$(text$,position%+2)
        locate row%,colum%
        ? space$(inputlength%);
      case chr$(0,59)               'need a little help.....
        rw%=row%-which_inp%+1       'I had to keep the 'row%'- unfortunately
        call little_help(rw%,colum%,which_inp%)
        locate row%-which_inp%+1,colum%
        'May be, first# is already there, then it has to be on the
        'screen when help was called e.g. from second input....
        if first#>0 then
          f$=ltrim$(str$(first#))
          locate row%-which_inp%+1,colum% : ? f$
        end if
        'the same with last#
        if last#>0 then
          l$=ltrim$(str$(last#))
          locate row%-which_inp%+2,colum% : ? l$
        end if
      case chr$(27),chr$(13),chr$(0,59)         'keys for leaving..
        if button$=chr$(27) then function=""    'nothing will go back...
        if button$=chr$(13) then function=text$ 'Text will go back...
        locate ,,0                              'for all the keys this
        exit function                           'means: leave the function!
    end select
    'put the text on the screen .........
    if instr(sign$,button$) then       'valid sign in sign$ or full string
      'chr$(8,127,20) are keys, which are occupied by the function itself
      'so here: iterate!
      if instr(button$,any chr$(8,127,20)) then iterate
      if len(text$)=>inputlength% then
        if iinsert%=0 or iinsert%=1 and _
          position%=inputlength% then
          if iinsert%=0 then play "o3c64"
          if iinsert%=1 then play "o2c64"
          iterate do                'error-DO repeat
        elseif iinsert%=1 and position%<=inputlength% then
                                    'overwrite
          text$=mid$(text$,1,position%)+button$+mid$(text$,position%+2)
          incr position%
        end if
      else                          'string is not completely full
        if iinsert%=0 then          'insert
          text$=mid$(text$,1,position%)+button$+mid$(text$,position%+1)
        else                        'overwrite
          text$=mid$(text$,1,position%)+button$+mid$(text$,position%+2)
        end if
        incr position%
      end if
    end if
  loop
end function
 '
 '--------------------- Center a string -----------------------------
 '
sub center_it(to_center_string$,z)
  'it's to center a string, which has a variable length.
  x=len(to_center_string$) : z=((81-x)/2)-1 'center it!
end sub
 '
 '----------- Instr from right for check out path and file ----------
 '
sub right_instr(innput$,rright$,lleft$)
  '
  'Procedure is splitting path from file. The original string will
  'not be killed!
  '
  'Input of procedure: innput$ - the string, which has to be split
  'Output of procedure: rright$ and lleft$
  '               NOTE: right$ and left$ can't be used, because these
  '                     expressions are used by PowerBASIC!
  'Delimiter is the backslash (it's fixed here)!
  '
  local x,xz$
  for x=len(innput$) to 1 step -1
    xz$=mid$(innput$,x,1)
    if xz$="\" then exit for      'Backslash is the Delimiter
  next x
  rright$=mid$(innput$,x+1)       'File
  lleft$=left$(innput$,x)         'Path with Backslash
end sub
 '
 '--------------------- Path and file of program --------------------
 '
function ProgName$
  'written by Dieter Folger; valid for DOS 3.0 and higher. It gives
  'back the name and the path of program in one string. It's an ex-
  'cellent function and doesn't need much place....
  ! mov ax,&h6200
  ! int &h21
  ! mov es,bx
  ! mov ax, word ptr es:[&h2c]
  ! mov pbvDefSeg, ax
  for i=0 to 1024
    if peek$(i,4)=chr$(0,0,1,0) then exit for
  next
  while peek(i+4)<>0
    Tmp$=Tmp$+chr$(peek(i+4))
    incr i
  wend
  def seg
  ProgName$=Tmp$
end function
  '
  '*********************** end of file ******************************




