Author Topic: SELECT stringVar problem  (Read 5760 times)

0 Members and 2 Guests are viewing this topic.

JRS

  • Guest
Re: SELECT stringVar problem
« Reply #15 on: May 04, 2013, 09:32:06 PM »
Yep, that is what I would expect to see when you are only removing the quote at the start of the string. (length of string - 1) I had to stay at a Holiday Inn Express for a week to figure that one out.


Aurel

  • Guest
Re: SELECT stringVar problem
« Reply #16 on: May 04, 2013, 09:34:29 PM »
No
it looks that you don't see that start position is 2
expert... ;D

JRS

  • Guest
Re: SELECT stringVar problem
« Reply #17 on: May 04, 2013, 09:36:57 PM »
Why would you start reading the string at the beginning when you know your passing the function a quoted string to strip?

aka Expert

Aurel

  • Guest
Re: SELECT stringVar problem
« Reply #18 on: May 04, 2013, 10:23:49 PM »
Quote
Why would you start reading the string at the beginning when you know your passing the function a quoted string to strip?
yes,why?
you still don't get it,because this quoted string is argument or token and is used from token array
as string literal.
do you get it now?

Just to confirm that is null terminated i made test in EBasic ..
look shots...



X

Aurel

  • Guest
Re: SELECT stringVar problem
« Reply #19 on: May 04, 2013, 10:27:30 PM »
That is why i am confused ...on first look i think that string is trimmed
and that is why i think that is proper to use -1 with Mid() function.

JRS

  • Guest
Re: SELECT stringVar problem
« Reply #20 on: May 04, 2013, 10:37:43 PM »
Lets look at Charles example and comment it line by line.

function NoQuotes(string s) as string   ' s is going to be a string of some unknown length surrounded by quote characters
if asc(s)=34   ' check to see if a quoted string is being passed. (asc() only looks at the first character)
  return mid s,2,len(s)-2  ' return the second character on to the length of the string - 2 (which truncates the trailing quote)
else
  return s ' you didn't pass a quoted string so here is what you sent
end if
end function

print NoQuotes `"Hello"`   ' the single quote allows passing the double quotes as part of the argument

Aurel

  • Guest
Re: SELECT stringVar problem
« Reply #21 on: May 04, 2013, 10:51:43 PM »
You may comment what you whish and you again not look into screenshots,right?
my argument is
Quote
arg["qString"]
and not arg["qString" ]
do you get it now?
so -1
give this :
[qString"]
and -2
give this:
[qString]

JRS

  • Guest
Re: SELECT stringVar problem
« Reply #22 on: May 04, 2013, 10:57:15 PM »
Things seem to be bouncing off all the walls.

Are you testing O2's unique ability to use an array reference as function call?

I'm quickly losing your point.


Charles Pegge

  • Guest
Re: SELECT stringVar problem
« Reply #23 on: May 04, 2013, 11:52:11 PM »
Oxygen strings have an indexbase of 1 and the len function ignores null terminators.

Aurel

  • Guest
Re: SELECT stringVar problem
« Reply #24 on: May 05, 2013, 12:04:51 AM »
Quote
Oxygen strings have an indexbase of 1 and the len function ignores null terminators.
Hi Charles..
Good to know, and when is used - like in my case in function .
And is important to me ;)

Aurel

  • Guest
Re: SELECT stringVar problem
« Reply #25 on: May 06, 2013, 09:58:52 AM »
Charles...
Just one small question if is no problem.
For example if i decide to replace string array with integer array as
command code...like
Instead of PRINT i use int number 1.
( i see something similar in rexx-imc code /)
So then i can use SELECT , right?
like
SELECT keycode
CASE 1
.....
CASE 2
....

What you mean how much faster i can get execution ?
thanks..

Aurel ;)

Peter

  • Guest
Re: SELECT stringVar problem
« Reply #26 on: May 06, 2013, 11:12:36 AM »
You can do.
Code: [Select]
include "sw.inc"

window 320,240,1

while key(27)=0
  cls  RGB 255,255,255
  a = GetKey
  select a
  case vk_0
       Text 0,0,"pressed " + chr(a),0
  case vk_1
       Text 0,0,"pressed " + chr(a),0
  case vk_2
       Text 0,0,"pressed " + chr(a),0
  case vk_3
       Text 0,0,"pressed " + chr(a),0
  case vk_4
       Text 0,0,"pressed " + chr(a),0
  end select
  Sync
wend
 
Quit