4Dv11 ODBC Pro from Windows to connect to 4D 2004 Server on Mac

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

4Dv11 ODBC Pro from Windows to connect to 4D 2004 Server on Mac

by Balinder Walia :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a requirement to connect to 4D 2004.6 server running on OS X from
4Dv11 single user using 4D ODBC Pro and retrieve and set the some data. I
downloaded the ODBC Drivers for 4D2004.6 Server for windows on windows
machine and installed it. Then configured DSN as normal and connection to 4D
Server seemed to configured ok except when I hit Test Connection DSN admin
window crashes. Also while connecting ODBC_SQLConnect returns -1. The same
code works if I can connect to SYBASE instead. Am I missing something? 4Dv11
app is already added in DEP prefs to allow access to connect to service to
and from that machine.

Please help if you can. I don't think there is any other way to connect to
4D2004.6 from v11. SOAP is not the option as it requires us to add code and
compile etc and the code is frozen. Same issue programming txt/xml export
import stored procedures.

------------------------
Best regards,
Server Monitor Support

http://www.rootinternet.co.uk/server_monitor

This email and any attached files are confidential and intended only for
the addressee. It may contain confidential and privileged material. Any
review, retransmission, dissemination or reliance upon it, or use of this
information by other than the intended recipient is prohibited. If you have
received this email in error please contact the sender and delete it. Thank
you.
**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: 4Dv11 ODBC Pro from Windows to connect to 4D 2004 Server on Mac

by Spencer Hinsdale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 5/22/08 11:23 AM, "Balinder Walia" <balinder.walia@...> wrote:

> I have a requirement to connect to 4D 2004.6 server running on OS X from
> 4Dv11 single user using 4D ODBC Pro and retrieve and set the some data. I
> downloaded the ODBC Drivers for 4D2004.6 Server for windows on windows
> machine and installed it. Then configured DSN as normal and connection to 4D
> Server seemed to configured ok except when I hit Test Connection DSN admin
> window crashes. Also while connecting ODBC_SQLConnect returns -1. The same
> code works if I can connect to SYBASE instead. Am I missing something? 4Dv11
> app is already added in DEP prefs to allow access to connect to service to
> and from that machine.
>

Balinder,

The ODBC Driver requires 4D Open access.  Is 4D Open enabled?:
2004-Server Application menu, Preferences, Client Server, Connections, Allow
4D Open checkbox.  This setting can only be changed in the structure before
compiling...

-spencer

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

$0 as a pointer

by Doug Cottrill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I've been wanting for a while now to return multiple variable types in
$0 for the same method but could never figure out how to do it.  However,
I recently had an idea.

Could I set the type of $0 as a pointer and then in my method do something
like this:


CASE OF
:  (one thing is true)
     $0-> := "text value" `a string or text value
:  (a different thing is true)
     $0-> := 7000 `a number value
END CASE

Call to MyMethod would look something like this:

Code for case 1

C_POINTER($myReturnPtr)
c_text($mytextVal)

$myReturnPtr:=->$myTextVal

$myReturnPtr:=MyMethod

Code for case 2

C_POINTER($myReturnPtr)
C_LONGINT($myLongVal)

$myReturnPtr:=->$myLongVal

$myReturnPtr:=MyMethod



So, has anyone done this successfully?  I will try it out, but if
anyone else has done
this and found that

A)  it works just fine, no problems
B)  it looks like it works, but it really doesn't and causes huge
corruption problems
C)  it works in some circumstances, but beware of X, Y, or Z
D)  don't bother it won't work
E)  something else

your experiences would be appreciated.  Thanks!

DKC


--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Parent Message unknown Re: $0 as a pointer

by Douglas von Roeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Beer money says you this won't fly because a pointer cannot reference a
literal value - it has to reference a "thing" (to use the highly technical
term) such as a variable, a field, a table, an array, an array element, etc.



On Thu, May 22, 2008 at 1:01 PM, Doug Cottrill <dkc@...> wrote:

> Hi all,
>
> I've been wanting for a while now to return multiple variable types in
> $0 for the same method but could never figure out how to do it.  However,
> I recently had an idea.
>
> Could I set the type of $0 as a pointer and then in my method do something
> like this:
>
>
> CASE OF
> :  (one thing is true)
>    $0-> := "text value" `a string or text value
> :  (a different thing is true)
>    $0-> := 7000 `a number value
> END CASE
>
> Call to MyMethod would look something like this:
>
> Code for case 1
>
> C_POINTER($myReturnPtr)
> c_text($mytextVal)
>
> $myReturnPtr:=->$myTextVal
>
> $myReturnPtr:=MyMethod
>
> Code for case 2
>
> C_POINTER($myReturnPtr)
> C_LONGINT($myLongVal)
>
> $myReturnPtr:=->$myLongVal
>
> $myReturnPtr:=MyMethod
>
>
>
> So, has anyone done this successfully?  I will try it out, but if anyone
> else has done
> this and found that
>
> A)  it works just fine, no problems
> B)  it looks like it works, but it really doesn't and causes huge
> corruption problems
> C)  it works in some circumstances, but beware of X, Y, or Z
> D)  don't bother it won't work
> E)  something else
>
> your experiences would be appreciated.  Thanks!
>
> DKC
>
>
> --
> Doug Cottrill
> PTM Software, LLC
>
> **********************************************************************
> The 4D v11 SQL Roadshow - coming to a city near you!
> http://www.4D.com/roadshow/index.html
>
> 4th Dimension Internet Users Group (4D iNUG)
> FAQ:  http://www.4d.com/support/faqnug.html
> Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
> Unsub:  mailto:4D_Tech-Unsubscribe@...
> Post: mailto:4d_tech@...
> Options: https://lists.4d.com/mailman/listinfo/4d_tech
> **********************************************************************
>



--
Douglas von Roeder
Voice Phone 714.793.8496
**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Mark Schaake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here's how I do this :

`First, declare the return variable as a pointer
C_POINTER($0;$myPointer_ptr)

` Next, declare process variables for all possible data types so $0 can point to a value that continues to exist in memory until the process is terminated
C_LONGINT(vLongValue_l)
C_REAL(vRealValue_r)
C_DATE(vDateValue_d)
C_TEXT(vTextValue_t)

`Next, handle various cases
Case of
  :(int scenario)
     vLongValue_l:=1234
     $myPointer_ptr:=-> vLongValue_l

  :(real scenario)
     vRealValue_r:=12.34
     $myPointer_ptr:=->vRealValue_r

  :(text scenario)
    vTextValue_t:="1234"
    $myPointer_ptr:=->vTextValue_t

  :(date scenario)
    vDateValue_r:=!01/01/2008!
    $myPointer_ptr:=->vDateValue_d

End Case

`Lastly, return the pointer to a process variable that contains the value you need
$0:=$myPointer_ptr

Doug Cottrill wrote:
Hi all,

I've been wanting for a while now to return multiple variable types in
$0 for the same method but could never figure out how to do it.  However,
I recently had an idea.

Could I set the type of $0 as a pointer and then in my method do something
like this:


CASE OF
:  (one thing is true)
     $0-> := "text value" `a string or text value
:  (a different thing is true)
     $0-> := 7000 `a number value
END CASE

Call to MyMethod would look something like this:

Code for case 1

C_POINTER($myReturnPtr)
c_text($mytextVal)

$myReturnPtr:=->$myTextVal

$myReturnPtr:=MyMethod

Code for case 2

C_POINTER($myReturnPtr)
C_LONGINT($myLongVal)

$myReturnPtr:=->$myLongVal

$myReturnPtr:=MyMethod



So, has anyone done this successfully?  I will try it out, but if
anyone else has done
this and found that

A)  it works just fine, no problems
B)  it looks like it works, but it really doesn't and causes huge
corruption problems
C)  it works in some circumstances, but beware of X, Y, or Z
D)  don't bother it won't work
E)  something else

your experiences would be appreciated.  Thanks!

DKC


--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@lists.4D.com
Post: mailto:4d_tech@lists.4d.com
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Doug Cottrill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark,

What happens if you call this in a loop with the same type needed?
Doesn't it change the values of your previous calls?  Or do you then
copy the value outside of the method call before calling it again?

>Here's how I do this :
>
>`First, declare the return variable as a pointer
>C_POINTER($0;$myPointer_ptr)
>
>` Next, declare process variables for all possible data types so $0 can
>point to a value that continues to exist in memory until the process is
>terminated
>C_LONGINT(vLongValue_l)
>C_REAL(vRealValue_r)
>C_DATE(vDateValue_d)
>C_TEXT(vTextValue_t)
>
>`Next, handle various cases
>Case of
>   :(int scenario)
>      vLongValue_l:=1234
>      $myPointer_ptr:=-> vLongValue_l
>
>   :(real scenario)
>      vRealValue_r:=12.34
>      $myPointer_ptr:=->vRealValue_r
>
>   :(text scenario)
>     vTextValue_t:="1234"
>     $myPointer_ptr:=->vTextValue_t
>
>   :(date scenario)
>     vDateValue_r:=!01/01/2008!
>     $myPointer_ptr:=->vDateValue_d
>
>End Case
>
>`Lastly, return the pointer to a process variable that contains the value
>you need
>$0:=$myPointer_ptr
>
>
>Doug Cottrill wrote:
>>
>>  Hi all,
>>
>>  I've been wanting for a while now to return multiple variable types in
>>  $0 for the same method but could never figure out how to do it.  However,
>>  I recently had an idea.
>>
>>  Could I set the type of $0 as a pointer and then in my method do something
>>  like this:
>>
>>
>>  CASE OF
>>  :  (one thing is true)
>>       $0-> := "text value" `a string or text value
>>  :  (a different thing is true)
>>       $0-> := 7000 `a number value
>>  END CASE
>>
>>  Call to MyMethod would look something like this:
>>
>>  Code for case 1
>>
>>  C_POINTER($myReturnPtr)
>>  c_text($mytextVal)
>>
>>  $myReturnPtr:=->$myTextVal
>>
>>  $myReturnPtr:=MyMethod
>>
>>  Code for case 2
>>
>>  C_POINTER($myReturnPtr)
>>  C_LONGINT($myLongVal)
>>
>>  $myReturnPtr:=->$myLongVal
>>
>>  $myReturnPtr:=MyMethod
>>
>>
>>
>>  So, has anyone done this successfully?  I will try it out, but if
>>  anyone else has done
>>  this and found that
>>
>>  A)  it works just fine, no problems
>>  B)  it looks like it works, but it really doesn't and causes huge
>>  corruption problems
>>  C)  it works in some circumstances, but beware of X, Y, or Z
>>  D)  don't bother it won't work
>>  E)  something else
>>
>>  your experiences would be appreciated.  Thanks!
>>
>>  DKC
>>
>>
>>  --
>>  Doug Cottrill
>>  PTM Software, LLC
>>
>>  **********************************************************************
>>  The 4D v11 SQL Roadshow - coming to a city near you!
>>  http://www.4D.com/roadshow/index.html
>>
>>  4th Dimension Internet Users Group (4D iNUG)
>>  FAQ:  http://www.4d.com/support/faqnug.html
>>  Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
>>  Unsub:  mailto:4D_Tech-Unsubscribe@...
>>  Post: mailto:4d_tech@...
>>  Options: https://lists.4d.com/mailman/listinfo/4d_tech
>>  **********************************************************************
>>
>>
>
>--
>View this message in context:
>http://www.nabble.com/4Dv11-ODBC-Pro-from-Windows-to-connect-to-4D-2004-Server-on-Mac-tp17410537p17412823.html
>Sent from the 4D Tech mailing list archive at Nabble.com.
>
>**********************************************************************
>The 4D v11 SQL Roadshow - coming to a city near you!
>http://www.4D.com/roadshow/index.html
>
>4th Dimension Internet Users Group (4D iNUG)
>FAQ:  http://www.4d.com/support/faqnug.html
>Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
>Unsub:  mailto:4D_Tech-Unsubscribe@...
>Post: mailto:4d_tech@...
>Options: https://lists.4d.com/mailman/listinfo/4d_tech
>**********************************************************************


--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Doug Cottrill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You may be right about it not flying, but I'm not sure what you mean here.

Douglas von Roeder says:
>Beer money says you this won't fly because a pointer cannot reference a
>literal value - it has to reference a "thing" (to use the highly technical
>term) such as a variable, a field, a table, an array, an array element, etc.
>

$x->:="test"

is a perfectly valid statement, I do it frequently.

So what I'm trying to do is

$0-> := "test"

where $0 is assigned as a pointer to a variable

C_POINTER($myPtrVal)  `this is valid

$myPtrVal:=->myVar    `this is valid- myVar could be text or numeric
or date, or whatever

$myPtrVal:=MyMethodCall  `will this be valid?


Any more takers before I set up a test DB to try this?

>
>On Thu, May 22, 2008 at 1:01 PM, Doug Cottrill <dkc@...> wrote:
>
>>  Hi all,
>>
>>  I've been wanting for a while now to return multiple variable types in
>>  $0 for the same method but could never figure out how to do it.  However,
>>  I recently had an idea.
>>
>>  Could I set the type of $0 as a pointer and then in my method do something
>>  like this:
>>
>>
>>  CASE OF
>>  :  (one thing is true)
>>     $0-> := "text value" `a string or text value
>>  :  (a different thing is true)
>>     $0-> := 7000 `a number value
>>  END CASE
>>
>>  Call to MyMethod would look something like this:
>>
>>  Code for case 1
>>
>>  C_POINTER($myReturnPtr)
>>  c_text($mytextVal)
>>
>>  $myReturnPtr:=->$myTextVal
>>
>>  $myReturnPtr:=MyMethod
>>
>>  Code for case 2
>>
>>  C_POINTER($myReturnPtr)
>>  C_LONGINT($myLongVal)
>>
>>  $myReturnPtr:=->$myLongVal
>>
>>  $myReturnPtr:=MyMethod
>>
>>
>>
>>  So, has anyone done this successfully?  I will try it out, but if anyone
>>  else has done
>>  this and found that
>>
>>  A)  it works just fine, no problems
>>  B)  it looks like it works, but it really doesn't and causes huge
>>  corruption problems
>>  C)  it works in some circumstances, but beware of X, Y, or Z
>>  D)  don't bother it won't work
>>  E)  something else
>>
>>  your experiences would be appreciated.  Thanks!
>>
>>  DKC
>>
>>
>>  --
>>  Doug Cottrill
>>  PTM Software, LLC
>>
>>  **********************************************************************
>>  The 4D v11 SQL Roadshow - coming to a city near you!
>>  http://www.4D.com/roadshow/index.html
>>
>>  4th Dimension Internet Users Group (4D iNUG)
>>  FAQ:  http://www.4d.com/support/faqnug.html
>>  Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
>>  Unsub:  mailto:4D_Tech-Unsubscribe@...
>>  Post: mailto:4d_tech@...
>>  Options: https://lists.4d.com/mailman/listinfo/4d_tech
>>  **********************************************************************
>>
>
>
>
>--
>Douglas von Roeder
>Voice Phone 714.793.8496
>**********************************************************************
>The 4D v11 SQL Roadshow - coming to a city near you!
>http://www.4D.com/roadshow/index.html
>
>4th Dimension Internet Users Group (4D iNUG)
>FAQ:  http://www.4d.com/support/faqnug.html
>Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
>Unsub:  mailto:4D_Tech-Unsubscribe@...
>Post: mailto:4d_tech@...
>Options: https://lists.4d.com/mailman/listinfo/4d_tech
>**********************************************************************


--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Mark Schaake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Doug,

Could you share your loop code within which you are calling your pointer-returning method?  I'm not sure what you are trying to accomplish.  My guess is arrays will allow you to do what you want.

Doug Cottrill wrote:
Mark,

What happens if you call this in a loop with the same type needed?
Doesn't it change the values of your previous calls?  Or do you then
copy the value outside of the method call before calling it again?

>Here's how I do this :
>
>`First, declare the return variable as a pointer
>C_POINTER($0;$myPointer_ptr)
>
>` Next, declare process variables for all possible data types so $0 can
>point to a value that continues to exist in memory until the process is
>terminated
>C_LONGINT(vLongValue_l)
>C_REAL(vRealValue_r)
>C_DATE(vDateValue_d)
>C_TEXT(vTextValue_t)
>
>`Next, handle various cases
>Case of
>   :(int scenario)
>      vLongValue_l:=1234
>      $myPointer_ptr:=-> vLongValue_l
>
>   :(real scenario)
>      vRealValue_r:=12.34
>      $myPointer_ptr:=->vRealValue_r
>
>   :(text scenario)
>     vTextValue_t:="1234"
>     $myPointer_ptr:=->vTextValue_t
>
>   :(date scenario)
>     vDateValue_r:=!01/01/2008!
>     $myPointer_ptr:=->vDateValue_d
>
>End Case
>
>`Lastly, return the pointer to a process variable that contains the value
>you need
>$0:=$myPointer_ptr
>
>
>Doug Cottrill wrote:
>>
>>  Hi all,
>>
>>  I've been wanting for a while now to return multiple variable types in
>>  $0 for the same method but could never figure out how to do it.  However,
>>  I recently had an idea.
>>
>>  Could I set the type of $0 as a pointer and then in my method do something
>>  like this:
>>
>>
>>  CASE OF
>>  :  (one thing is true)
>>       $0-> := "text value" `a string or text value
>>  :  (a different thing is true)
>>       $0-> := 7000 `a number value
>>  END CASE
>>
>>  Call to MyMethod would look something like this:
>>
>>  Code for case 1
>>
>>  C_POINTER($myReturnPtr)
>>  c_text($mytextVal)
>>
>>  $myReturnPtr:=->$myTextVal
>>
>>  $myReturnPtr:=MyMethod
>>
>>  Code for case 2
>>
>>  C_POINTER($myReturnPtr)
>>  C_LONGINT($myLongVal)
>>
>>  $myReturnPtr:=->$myLongVal
>>
>>  $myReturnPtr:=MyMethod
>>
>>
>>
>>  So, has anyone done this successfully?  I will try it out, but if
>>  anyone else has done
>>  this and found that
>>
>>  A)  it works just fine, no problems
>>  B)  it looks like it works, but it really doesn't and causes huge
>>  corruption problems
>>  C)  it works in some circumstances, but beware of X, Y, or Z
>>  D)  don't bother it won't work
>>  E)  something else
>>
>>  your experiences would be appreciated.  Thanks!
>>
>>  DKC
>>
>>
>>  --
>>  Doug Cottrill
>>  PTM Software, LLC
>>
>>  **********************************************************************
>>  The 4D v11 SQL Roadshow - coming to a city near you!
>>  http://www.4D.com/roadshow/index.html
>>
>>  4th Dimension Internet Users Group (4D iNUG)
>>  FAQ:  http://www.4d.com/support/faqnug.html
>>  Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
>>  Unsub:  mailto:4D_Tech-Unsubscribe@lists.4D.com
>>  Post: mailto:4d_tech@lists.4d.com
>>  Options: https://lists.4d.com/mailman/listinfo/4d_tech
>>  **********************************************************************
>>
>>
>
>--
>View this message in context:
>http://www.nabble.com/4Dv11-ODBC-Pro-from-Windows-to-connect-to-4D-2004-Server-on-Mac-tp17410537p17412823.html
>Sent from the 4D Tech mailing list archive at Nabble.com.
>
>**********************************************************************
>The 4D v11 SQL Roadshow - coming to a city near you!
>http://www.4D.com/roadshow/index.html
>
>4th Dimension Internet Users Group (4D iNUG)
>FAQ:  http://www.4d.com/support/faqnug.html
>Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
>Unsub:  mailto:4D_Tech-Unsubscribe@lists.4D.com
>Post: mailto:4d_tech@lists.4d.com
>Options: https://lists.4d.com/mailman/listinfo/4d_tech
>**********************************************************************


--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@lists.4D.com
Post: mailto:4d_tech@lists.4d.com
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Parent Message unknown Re: $0 as a pointer

by Derrell Thomason :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I've been wanting for a while now to return multiple variable types in
> $0 for the same method but could never figure out how to do it.  However,
> I recently had an idea.

Any time I want to do this type of thing, I generally write something like
this:

MyFunction(param1, param2, ->returnVal)

As an alternative, I suppose you could shove your return value into a blob,
return a blob from your function call, and then parse the blob in the
calling routine, but that seems really messy.

// Derrell Thomason
// IT Programming Supervisor
// Pensacola Christian College

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Bill Weale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe $0 could be a pointer to a "structured" blob, the structure  
consisting of a header area describing contents (value type, or  
description of more complex object) and the content area?

--www

On May 22, 2008, at 4:01 PM, Doug Cottrill wrote:

> Hi all,
>
> I've been wanting for a while now to return multiple variable types in
> $0 for the same method but could never figure out how to do it.  
> However,
> I recently had an idea.
>
> Could I set the type of $0 as a pointer and then in my method do  
> something
> like this:
>
>
> CASE OF
> :  (one thing is true)
>     $0-> := "text value" `a string or text value
> :  (a different thing is true)
>     $0-> := 7000 `a number value
> END CASE
>
> Call to MyMethod would look something like this:
>
> Code for case 1
>
> C_POINTER($myReturnPtr)
> c_text($mytextVal)
>
> $myReturnPtr:=->$myTextVal
>
> $myReturnPtr:=MyMethod
>
> Code for case 2
>
> C_POINTER($myReturnPtr)
> C_LONGINT($myLongVal)
>
> $myReturnPtr:=->$myLongVal
>
> $myReturnPtr:=MyMethod
>
>
>
> So, has anyone done this successfully?  I will try it out, but if  
> anyone else has done
> this and found that
>
> A)  it works just fine, no problems
> B)  it looks like it works, but it really doesn't and causes huge  
> corruption problems
> C)  it works in some circumstances, but beware of X, Y, or Z
> D)  don't bother it won't work
> E)  something else
>
> your experiences would be appreciated.  Thanks!
>
> DKC
>
>
> --
> Doug Cottrill
> PTM Software, LLC
>
>
**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Doug Cottrill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark and Bill

>Doug,
>
>Could you share your loop code within which you are calling your
>pointer-returning method?  I'm not sure what you are trying to accomplish.
>My guess is arrays will allow you to do what you want.




Not really, since I haven't written it yet, but I'll give an example that
I'm interested in trying:

FOR($curRec;1;$numRecs)
   CREATE RECORD([MyTable])
    [MyTable]IDField:=UID_GetNextUID($tableNum)
    SAVE RECORD([MyTable])
END FOR

This is the straight forward use of a call to UID_GetNextUID

The problem is that in some tables/DBs [MyTable]IDField will be a
text value and
in some it will be a numeric value.

The obvious solution is to use 2 methods, one that returns a string and one
that returns a numeric value OR on the one that needs a string value call it
as  [MyTable]IDField:=String(UID_GetNextUID($tableNum))

I do not particularly like either option though.  What I'd like to do is call

-> [MyTable]IDField:=UID_GetNextUID($tableNum)

and have UID_GetNextUID determine whether $0-> is a numeric or text and
then assign it as a text or numeric value as necessary.

I could also just pass in  ->[MyTable]IDField as $1 but it'd be cool
if I could do
this with $0



--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Doug Cottrill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, that would work, and I've done that in some cases.   I guess it is
offending my sense of propriety.  IE, a function call should return a
value in $0.

What I really want is the ability to overload parameters including $0
so that they can be different types instead of passing in pointers when
I don't need to otherwise.

>  > I've been wanting for a while now to return multiple variable types in
>>  $0 for the same method but could never figure out how to do it.  However,
>>  I recently had an idea.
>
>Any time I want to do this type of thing, I generally write something like
>this:
>
>MyFunction(param1, param2, ->returnVal)
>
>As an alternative, I suppose you could shove your return value into a blob,
>return a blob from your function call, and then parse the blob in the
>calling routine, but that seems really messy.

--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
Post: mailto:4d_tech@...
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Mark Schaake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Doug, I'm not sure if it was just a typo, but I think you are trying to use a returned pointer from a method in the wrong way.  You will need to dereference the returned pointer :

[MyTable]IDField:=UID_GetNextUID($tableNum)->

Now, here is how I would handle what you are trying to do:

UID_GetNextUID method:

C_LONGINT($1;$tableNumber_l)
C_POINTER($0;$idValue_ptr)
C_POINTER($idField_ptr)

`Process vars for accessing from returned pointer
C_LONGINT(vLongValue_l)
C_TEXT(vTextValue_t)

$tableNumber_l:=$1

`Assuming your id field is always field 1
$idField_ptr:=Field($tableNumber_l;1)

`Handle dynamic data types
Case of
   :(Type($idField_ptr->)=Is LongInt)
      vLongValue_l:=`some value you determine in your method
      $idValue_ptr:=-> vLongValue_l

   :(Type($idField_ptr->)=Is Alpha)
      vTextValue_t:=`some value you determine in your method
      $idValue_ptr:=-> vTextValue_t

End Case

$0:=$idValue_ptr



ASSIGN_IDS_METHOD:

FOR($curRec;1;$numRecs)
   CREATE RECORD([MyTable])
    [MyTable]IDField:=UID_GetNextUID($tableNum)->
    SAVE RECORD([MyTable])
END FOR

Doug Cottrill wrote:
Mark and Bill

>Doug,
>
>Could you share your loop code within which you are calling your
>pointer-returning method?  I'm not sure what you are trying to accomplish.
>My guess is arrays will allow you to do what you want.




Not really, since I haven't written it yet, but I'll give an example that
I'm interested in trying:

FOR($curRec;1;$numRecs)
   CREATE RECORD([MyTable])
    [MyTable]IDField:=UID_GetNextUID($tableNum)
    SAVE RECORD([MyTable])
END FOR

This is the straight forward use of a call to UID_GetNextUID

The problem is that in some tables/DBs [MyTable]IDField will be a
text value and
in some it will be a numeric value.

The obvious solution is to use 2 methods, one that returns a string and one
that returns a numeric value OR on the one that needs a string value call it
as  [MyTable]IDField:=String(UID_GetNextUID($tableNum))

I do not particularly like either option though.  What I'd like to do is call

-> [MyTable]IDField:=UID_GetNextUID($tableNum)

and have UID_GetNextUID determine whether $0-> is a numeric or text and
then assign it as a text or numeric value as necessary.

I could also just pass in  ->[MyTable]IDField as $1 but it'd be cool
if I could do
this with $0



--
Doug Cottrill
PTM Software, LLC

**********************************************************************
The 4D v11 SQL Roadshow - coming to a city near you!
http://www.4D.com/roadshow/index.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  http://www.4d.com/support/faqnug.html
Archive:  http://dir.gmane.org/gmane.comp.lang.inug-4d.tech
Unsub:  mailto:4D_Tech-Unsubscribe@lists.4D.com
Post: mailto:4d_tech@lists.4d.com
Options: https://lists.4d.com/mailman/listinfo/4d_tech
**********************************************************************

Re: $0 as a pointer

by Doug Cottrill :: Rate this Message: