demo issues

Started by James C. Fuller, March 15, 2024, 12:23:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

Charles,
  Just poking around the demos with the latest: 0.7.0 2024-03-10
James


cO2m64 -m -64 D:\OxygenBasic\demos\System\SystemTime

ERROR: parameters mismatch for procedure mid_
params given : #string#long@00

OPTIONS:
mid_(gstr_,sys,gstr_) returns sys
mid_(cstr_,sys,gstr_) returns sys


WORD: -
COL: 23
LINE: 21
FILE: "d:\oxygenbasic\demos\system\systemtime.o2bas"

Error(s) occured.

  •  

Charles Pegge

#1
Thanks James,

I have reworked this example:

type SYSTEMTIME
  word wYear,
       wMonth,
       wDayOfWeek,
       wDay,
       wHour,
       wMinute,
       wSecond,
       wMilliseconds
end type

extern lib "kernel32.dll"
!  GetSystemTime (SYSTEMTIME*lpSystemTime)
!  GetLocalTime  (SYSTEMTIME*lpSystemTime)
end extern


function timestr (int locl=0) as string
=======================================
  '
  function f (word v) as string
  -----------------------------
    return mid( "0"+str(v) , -2)
  end function
  '
  function  m (word v) as string
  ------------------------------
    return mid("00"+str(v), -3)
  end function
  '
  SYSTEMTIME t
  if locl
    GetLocalTime t
  else
    GetSystemTime t
  endif
  return str(t.wYear) "." + f(t.wMonth) "." f(t.wDay) " " +
  f(t.wHour) ":" f(t.wMinute) ":" f(t.wSecond) +
  "." str(t.wMilliseconds)
end function

print "System DateTime: " timestr()
print "Local DateTime: " timestr(1)