Input question Fahrenheit

Started by Frank Brübach, November 24, 2023, 06:56:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Good evening I have a little question about OpenGL and Input Feature wanted to calculate Fahrenheit ,/ Celsius degrees Just AS an example how to Work with Input command  but Something is going wrong Here

  #compact
  % filename "t.exe"
 'uses RTL64
  % Title "Console Input Demo"
 '% Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
 '% NoEscape

  $ filename "t.exe"
 'uses RTL64
  uses ConsoleG

  procedure main()
  ================
  sys a,i,p,f,c
  static string ins
  static string s

  cls .10,.10,.20
  '
  'LINE INPUT
  '
  f=c*1.8+32 'fahrenheit/celsius degrees
  '
  PushState
  color .20,.80,.00,.88
  Scale 2
  move 1,-1
  print "Enter: "
  color .80,.80,.00,.88
  'a=input ins
  c=input ins
  lastchar=0
  if c>1
    s=ins*f+c
    ins="" : cp=1
  endif
  PopState
  move 0,-5
  PushState
  scale 2
  printl "result: "+s
  PopState
  lastkey=0
  lastchar=0
  '
  end procedure

  EndScript

Help is Welcome thx Frank

Charles Pegge

#1
Hi Frank,

Its basically:

    f=val(ins)*1.8+32 'Fahrenheit from Celsius degrees
    s=str(f,1) '1 decimal place


#compact
  % filename "t.exe"
 'uses RTL64
  % Title "Console Input Demo"
 '% Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
 '% NoEscape

  $ filename "t.exe"
 'uses RTL64
  uses ConsoleG

  procedure main()
  ================
  sys a,i,p,c
  float f
  static string ins
  static string s

  cls .10,.10,.20
  '
  'LINE INPUT
  '
  PushState
  color .20,.80,.00,.88
  Scale 2
  move 1,-1
  print "Enter Celcius: "
  color .80,.80,.00,.88
  c=input ins 'c is the last ascii code (13 etc)
  lastchar=0
  if c
    if len(ltrim(ins))
      f=val(ins)*1.8+32 'fahrenheit from celsius degrees
      s=str(f,1) '1 decimal place
      ins=""
      cp=1
    endif
  endif
  PopState
  move 0,-5
  PushState
  scale 2
  printl "Farenheit: "+s
  PopState
  lastkey=0
  lastchar=0
  '
  end procedure

  EndScript

Frank Brübach

#2
Yes :) my Problem was the String Input and how to multiplay with a value many thanks Charles!

simple one

dim c,f as double
c=40
f=1.8*c+32
Print "c: " + f ' result 104