Results 1 to 6 of 6

Thread: console_attach description?

  1. #1

    console_attach description?

    Hi,

    tried to find out what console_attach does, but there is no info in the on/offline help and I didn't find any information in the forum.
    If added iinto code, it has no effect.

  2. #2
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: console_attach description?

    same question here, dear oli.

    but you can get some results look at the end of tb script example. the description for manual help will follow I am sure, if eros or anybody else read this one.

    [code=thinbasic]Uses "Console"

    dim sx, sy as number
    dim cx, cy as number
    Dim ta,tz As Number

    ' Save some info
    sx = Console_GetSizeX()
    sy = Console_GetSizeY()
    cx = Console_GetCursorX()
    cy = Console_GetCursorY()
    ta = Console_GetTextAttribute()
    tz = Rnd(10,255)

    Console_SetTextAttribute(Console_ForegroundRGB(1,1,1,1))

    Console_WriteLine(" CONSOLE INFO")
    Console_WriteLine("----------------")

    Console_SetTextAttribute(ta)

    Console_WriteLine("Title : " + Console_GetTitle())

    Console_WriteLine("Size :" + str$(sx) + "x" + ltrim$(str$(sy)) + " (" + ltrim$(str$(sx*sy*2)) + " bytes)")

    Console_WriteLine("Origin in :" + str$(cx) + "," + ltrim$(str$(cy)))

    Console_WriteLine("Text attribute :" + str$(ta))

    Console_Attach(tz)

    Console_WriteLine "console_attach exists but what's purpose good for? " + tz

    Console_SetCursorPosition(30, 23)
    Console_WriteLine("Press any key to exit.")
    Console_WaitKey
    [/code]

    frank
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  3. #3

    Re: console_attach description?

    Hm, in thinBasic history I found for version 1.0.9.1 mention of a Windows API call:
    http://msdn.microsoft.com/en-us/libr...52(VS.85).aspx - Attaches the calling process to the console of the specified process.

    Also FreeConsole and AllocConsole are mentioned in MSDN so I guess that's it.
    Would be interested in some working example - I guess the parameter is some parent process ID,
    but where do I get such process ID and what is the purpose of attaching?

    I ask because I'm working on some kind of "extended" cmdline or Dos box, which will have some additional commands (prefixed with ! for example).
    The problem is if you type CD C:\something and in the next line want to delete some file in that folder the environment is not preserved - for each
    execution I call something like:
    OS_Shell($cmdline, %OS_WNDSTYLE_NORMAL, %OS_SHELL_SYNC)
    And my idea is to use this console_attach to somehow preserve the enviroment.
    Or does anyone have a better idea how to solve this env problem?

    Bye,
    Oli

  4. #4

    Re: console_attach description?

    Quote Originally Posted by oli
    Hm, in thinBasic history I found for version 1.0.9.1 mention of a Windows API call:
    http://msdn.microsoft.com/en-us/libr...52(VS.85).aspx - Attaches the calling process to the console of the specified process.

    Also FreeConsole and AllocConsole are mentioned in MSDN so I guess that's it.
    Would be interested in some working example - I guess the parameter is some parent process ID,
    but where do I get such process ID and what is the purpose of attaching?

    I ask because I'm working on some kind of "extended" cmdline or Dos box, which will have some additional commands (prefixed with ! for example).
    The problem is if you type CD C:\something and in the next line want to delete some file in that folder the environment is not preserved - for each
    execution I call something like:
    OS_Shell($cmdline, %OS_WNDSTYLE_NORMAL, %OS_SHELL_SYNC)
    And my idea is to use this console_attach to somehow preserve the enviroment.
    Or does anyone have a better idea how to solve this env problem?

    Bye,
    Oli
    Actually I found now following http://www.codeguru.com/forum/showthread.php?t=293668:
    "AttachConsole gives the ability for a GUI application to write to the console window of the console from which it was started."

    So this will not really help me solving my environment problem

    Bye,
    Oli

  5. #5
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: console_attach description?

    hello.

    perhaps this example can help. although I am not sure what the result should be for "Console_attach" or "console_alloc" here's a way how I have understood what your intention for finding infos with links may be. send a message from ui module to console.

    [code=thinbasic]'---------------------------------
    '- test example 1 for oli by frank
    '---------------------------------

    Uses "console", "ui"
    %messageWorkout = 1
    %ButtonCopy = 1002
    %ButtonClose = 1003

    Dim hDlg As Long
    Dim x,y,z As Long


    Function TBMain() As Long
    Dim myconsole As Long
    Dim getStdHandle(2) As String

    Dialog NEW hDlg, "myConsole_test",-1,-1, 330, 203, _
    %WS_POPUP Or _
    %WS_VISIBLE Or _
    %WS_CLIPCHILDREN Or _
    %WS_CAPTION Or _
    %WS_SYSMENU Or _
    %WS_MINIMIZEBOX, _
    0 To hDlg

    Control ADD BUTTON, hDlg, %ButtonClose, "Click to kill", 160, 50, 60, 24
    Control ADD BUTTON, hDlg, %ButtonCopy, "TextInfos_Send!", 40,90,80,44 Call cbSendDialog

    Console_Attach(x)
    Console_Alloc 'no parameters, 0=failure, nonzero=success
    myConsole = GetStdHandle (%messageWorkout)

    Dialog SHOW MODAL hDlg Call cbDialog

    End Function

    CallBack Function cbSendDialog() As Long
    Static i As Long
    Local txt As ASCIIZ*256
    Local Out As String
    Local myConsole As String
    Local WriteConsole As Long

    Select Case CBMSG
    Case %WM_COMMAND
    If CBWPARAM = %ButtonCopy Then
    Incr i
    txt = "TestLine " + Str$(i) + $CRLF
    Console_Write myConsole, txt, Len(txt), Out, 0
    End If

    Case %WM_DESTROY
    MsgBox 0, "Window is to be destroyed."
    End Select

    End Function

    CallBack Function cbDialog() As Long

    Select Case CBMSG
    Case %WM_COMMAND
    If CBWPARAM = %ButtonClose Then Dialog End CBHNDL

    Case %WM_DESTROY
    MsgBox 0, "Window is to be destroyed."

    End Select

    End Function
    [/code]

    write a message to eros and ask for these both console commands so you will get detailled infos, I am sure

    maybe I could help for the first step in your direction. But I am not sure.

    servus, frank
    Attached Images Attached Images
    Attached Files Attached Files
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  6. #6

    Re: console_attach description?

    Hi Frank,

    thank you for the example - I'm quite new to thinBasic and the example showed me some use of thinBasic I wasn't aware of

    Unfortunately we didn't yet figure out what the console_attach and console_alloc do - In your example if I comment out both commands it still works
    I'll really have to ask Eros

    Anyway it looks I'll solve the "environment" problem in a different way for now as it looks like console_attach is not what I need.

    Bye,
    Oli

Similar Threads

  1. XML module, command description?
    By Michael Hartlef in forum General
    Replies: 11
    Last Post: 02-07-2007, 21:57

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •