Author Topic: Small request for "direct string" parameters.  (Read 491 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Sr. Member
  • ****
  • Posts: 392
    • PluriBASIC
Small request for "direct string" parameters.
« on: December 10, 2018, 08:11:44 PM »
 I Noticed that when you pass a literal string as a parameter, you cannot assign text to it, but
when you pass the reference to the string you can.

At least on 32 bit mode, because in 64 bit mode it crashes.

 My small request is, can we alter the text of "direct string" parameters in 64 bit mode just like
in 32 bit mode? I dont care to alter the text of these parameters:

Code: [Select]
string param
I need it only for these:

Code: [Select]
string *param
Otherwise i have to make an ugly hack.

 In other words, i think what i am really asking is either:
  • Allow string ("") to be passed as parameter....
  • Allow non byref parameters to be modified in the target modules.
  • A way to pass string parameters bycopy.

 If possible. Thanks!


Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4128
    • Oxygen Basic
Re: Small request for "direct string" parameters.
« Reply #1 on: December 11, 2018, 05:03:48 AM »
Brian,

I can't reproduce your crash problem, but I will implement bycopy (same usage as in PowerBasic). Should be ready later today.

When passing a string literal byref, the compiler automatically makes a copy so that overwriting the original string constant is made impossible.

Code: [Select]
'11:37 11/12/2018
'check literals passed byref
$filename "c.exe"
uses rtl64
string f(string *s){s+=s+s : return s}
#show print f "ok"

Brian Alvarez

  • Sr. Member
  • ****
  • Posts: 392
    • PluriBASIC
Re: Small request for "direct string" parameters.
« Reply #2 on: December 11, 2018, 05:27:40 AM »
 Great news charles! Looking forward to give it a try!

 This thing is working awesomely!, so, rest assured all your hard work is being put to good use!! :D

Added:
 If possible, make it work also for other string parameters besides literal strings.  ;D

 By the way, notice that, your example crashes on 64 bit mode and works fine in 32 bit mode,
just as i said in my first post. Too bad you cant reproduce it... is there a way i can provide you
info to make it work?
« Last Edit: December 11, 2018, 05:37:44 AM by Brian Alvarez »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4128
    • Oxygen Basic
Re: Small request for "direct string" parameters.
« Reply #3 on: December 11, 2018, 11:13:34 AM »
Updated with OXSC181211.

Please make sure you have the right RTLs in the inc folder.

Brian Alvarez

  • Sr. Member
  • ****
  • Posts: 392
    • PluriBASIC
Re: Small request for "direct string" parameters.
« Reply #4 on: December 11, 2018, 11:27:03 AM »
Cool, i am on it. :)

Brian Alvarez

  • Sr. Member
  • ****
  • Posts: 392
    • PluriBASIC
Re: Small request for "direct string" parameters.
« Reply #5 on: December 11, 2018, 11:30:36 AM »
Where can i check the OXSC181211 id charles?

Disregard, i got it:
https://github.com/Charles-Pegge/OxygenBasic

Brian Alvarez

  • Sr. Member
  • ****
  • Posts: 392
    • PluriBASIC
Re: Small request for "direct string" parameters.
« Reply #6 on: December 11, 2018, 11:44:14 AM »
 Working great Charles! the new bycopy switch works great so far also iun 64 bit mode!
And this update catched one small error that i didnt know i was making... :)