Author Topic: Problem with mid or maybe somtehing else  (Read 1483 times)

0 Members and 1 Guest are viewing this topic.

  • Guest
Problem with mid or maybe somtehing else
« on: October 09, 2018, 03:46:26 PM »
The following code aborts execution:

Code: [Select]
wchar buffer[260] = "1234567890"
dim i as long
for i =  len(buffer) to 1 step -1
   if mid(buffer, i, 1) = wstring("5") or mid(buffer, i, 1) = wstring("4") then print i : exit for
next
« Last Edit: October 09, 2018, 03:57:02 PM by José Roca »

José Roca

  • Guest
Re: Problem with mid or maybe somtehing else
« Reply #1 on: October 09, 2018, 07:56:12 PM »
Something is wrong with MID:

Code: [Select]
wchar buffer[260] = "C:\xxxx\xxx.bas"
dim i as long, pch as word at strptr(buffer)
for i = len(buffer) to 1 step -1
   if pch[i] = asc(":") or pch[i] = asc("\") or pch[i] = asc("/") then
      buffer = mid(buffer, i + 1)
print buffer + " " + i
      exit for
   end if
next

After buffer = mid(buffer, i + 1), buffer becomes empty.

  • Guest
Re: Problem with mid or maybe somtehing else
« Reply #2 on: October 09, 2018, 08:17:31 PM »
Right also seems to have a problem.

left(buffer, 3)   ' works
mid(buffer, 1, 3)   ' works
mid(buffer, 1)   ' does not work
right(buffer, 3)   ' does not work

You need beta testers for unicode...
« Last Edit: October 09, 2018, 08:34:59 PM by José Roca »